TWiki
>
Public Web
>
DpHipe
>
DpHipeViews
(revision 7) (raw view)
Edit
Attach
Tags:
view all tags
---+ !!Creating a View %STARTINCLUDE% <!-- summary --> You can develop new views and add them to the work-bench of [[DpHipe][HIPE]]. This section briefly explains how to do this. %STOPINCLUDE% %TOC% <br clear="all"/> <!-- Some short-cuts * Set VIEWABLE = [[HcssDoc:api/herschel/ia/gui/kernel/parts/Viewable.html][Viewable]] * Set VIEWPART = [[HcssDoc:api/herschel/ia/gui/kernel/parts/ViewPart.html][ViewPart]] * Set JCOMPONENT = [[Java2Api:javax/swing/JComponent.html][javax.swing.JComponent]] * Set REGISTRY = [[DpHipeRegistry][Extension Registry]] * Set INIT_PY = [[JythonModules][__init__.py]] * Set SELISTENER = [[HcssDoc:api/herschel/ia/gui/kernel/SiteEventListener.html][SiteEventListener]] --> ---++ Basic Steps <blockquote> <img src="%ATTACHURLPATH%/hipe-menu-view.jpg" align="RIGHT" alt="HIPE View menu" width='297' height='318' /> The aim is that your contribution is automatically picked up by the [[DpHipeOverview][infrastructure]], such that your view is added to the view menu, as shown in the picture on the right. To make this happen, you will have to: * Implement the %VIEWABLE% interface by sub-classing any %JCOMPONENT% implementation. * Register your implementation to the %REGISTRY% in the %INIT_PY% file of your sub-system. The %VIEWABLE% interface is a light-weight interface that provides the contents of a View. Your implementation should take the following into account: * The implementation must be an extension of a swing component * The implementation requires a default, but light-weight constructor. Actual construction of a popup menu, a view menu, or a tool bar or contributions to the main tool bar or main menu (or combinations of them) should be done in the ==init(%VIEWPART% part)== method. * In principle only one instance of a view should exist. * The ID returned by your implementation must be unique <br clear="all"/> </blockquote> ---++ Example <blockquote> ---+++ Implementation <blockquote> <pre> public class MyView extends SomeSwingComponent implements Viewable { private ViewPart _part; // Viewable implementation public MyView() {} public void dispose() {} public Icon getIcon() { return getPart().getIcon(); } public String getId() { return getPart().getId(); } public String getTitle() { return getPart().getTitle(); } public void init(ViewPart part) { _part = part; makeActions(); } // private stuff private ViewPart getPart() { return _part; } private void makeActions() { // create tool bars, menus and other stuff } } </pre> <br clear="all"/> </blockquote> ---+++ Registry <blockquote> The following snippet registers the above view within your package's %INIT_PY%: <pre> REGISTRY.register(VIEWABLE, Extension( "site.view.myview", "resides.in.java.package.MyView", "My View", "resides/in/java/package/myview.gif" )); </pre> See also the %REGISTRY% documentation for more details. </blockquote> </blockquote> </pre> ---++ Adding features <blockquote> ---+++ Trigger events <blockquote> Your viewable may want to trigger site events which might be interesting to other views. The %VIEWPART% interface that is passed on through the ==init== method gives you the means of triggering site events: <pre> private void somemethod() { : getPart().getEventHandler().trigger(aSiteEvent) : } </pre> </blockquote> ---+++ Receiving events <blockquote> Your viewable may want to listen to site events produced by other views. For that you have to implement the %SELISTENER% interface and inform the event handler that you are interested in one or more event types, e.g.: <pre> public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener { public void init(ViewPart part) { : part.getEventHandler().addEventListener(SelectionEvent.class, this); : } public void selectionChanged(SiteEvent event) { // we *know* that we only receive a SelectionEvent, so: SelectionEvent selection=(SelectionEvent)event; : } } </pre> </blockquote> ---+++ Menus and toolbars <blockquote> _TODO_ </blockquote> </blockquote> <!-- Author: Main.JorgoBakker -->
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r19
|
r9
<
r8
<
r7
<
r6
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r7 - 2008-03-28
-
LijunZhang
Public
Log In
Public Web
Create New Topic
Index
Search
Changes
Notifications
Statistics
Preferences
Webs
Public
TWiki