|
|
META TOPICPARENT |
name="DpHipe" |
| |
> > | <-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END -->
<-- END OF ANALYTICS CODE --> | | <--
- Set TOPICTITLE = Creating a view
--> | |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="HIPE View menu" date="1341414796" name="hipe-menu-view.png" path="hipe-menu-view.png" size="29796" user="Main.DavideRizzo" version="1" |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="HIPE View menu" date="1200329384" name="hipe-menu-view.jpg" path="hipe-menu-view.jpg" size="24016" user="Main.JorgoBakker" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="Script for Google Analytics" date="1350657986" name="GoogleAnalytics.txt" path="GoogleAnalytics.txt" size="549" user="Main.DavideRizzo" version="1" |
| |
META TOPICMOVED |
by="DavideRizzo" date="1272527966" from="Hcss.DpHipeViews" to="Public.DpHipeViews" |
|
|
META TOPICPARENT |
name="DpHipe" |
Basic steps | | The aim is that your contribution is automatically picked up by the 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.
| > > |
- Implement the Viewable interface by sub-classing any %JCOMPONENT% implementation.
| |
- Register your implementation to the Extension 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 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.
| |
Triggering events
| |
< < | 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: | > > | 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: | |
private void someMethod() {
:
| |
Receiving events
| |
< < | Your viewable may want to listen to site events produced by other views. For that you have to implement the SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.: | > > | Your viewable may want to listen to site events produced by other views. For that you have to implement the SiteEventListener interface and inform the event handler that you are interested in one or more event types, for instance: | |
public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener {
| | <-- END OF COMMENT BOX CODE -->
| |
< < |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="HIPE View menu" date="1200329384" name="hipe-menu-view.jpg" path="hipe-menu-view.jpg" size="24016" user="Main.JorgoBakker" version="1" |
| |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="HIPE View menu" date="1341414796" name="hipe-menu-view.png" path="hipe-menu-view.png" size="29796" user="Main.DavideRizzo" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="HIPE View menu" date="1200329384" name="hipe-menu-view.jpg" path="hipe-menu-view.jpg" size="24016" user="Main.JorgoBakker" version="1" |
| |
META TOPICMOVED |
by="DavideRizzo" date="1272527966" from="Hcss.DpHipeViews" to="Public.DpHipeViews" |
|
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
| |
< < | Creating a View | > > | <--
- Set TOPICTITLE = Creating a view
-->
Did you spot something wrong or missing on this page? If you have an account on this TWiki, you can fix it yourself by editing the page. If you don't have an account, you can send a message to the Editorial Board to tell us about it. Thank you in advance!
Creating a view | |
<-- summary --> | |
- Set SELISTENER = SiteEventListener
--> | |
< < | Basic Steps | > > | Basic steps | |
 | | Adding features
| |
< < | Trigger events | > > | Triggering events | |
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:
| | | | | |
> > | Please add your comments!
| | <-- Author: JorgoBakker -->
|
META TOPICPARENT |
name="DpHipe" |
Creating a View |
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
Basic Steps | |
| |
> > | | |
|
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
<-- Author: JorgoBakker --> | |
> > | <--
--> | |
META FILEATTACHMENT |
attachment="hipe-menu-view.jpg" attr="h" comment="HIPE View menu" date="1200329384" name="hipe-menu-view.jpg" path="hipe-menu-view.jpg" size="24016" stream="hipe-menu-view.jpg" user="Main.JorgoBakker" version="1" |
META TOPICMOVED |
by="DavideRizzo" date="1272527966" from="Hcss.DpHipeViews" to="Public.DpHipeViews" |
|
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | | | |
< < | | > > | | |
--> | |
Menus, toolbars and other features
| |
< < | You can learn about adding actions to your view, and more, following this link . | > > | You can learn about adding actions to your view, and more, following this link . | |
| | <-- Author: JorgoBakker -->
META FILEATTACHMENT |
attachment="hipe-menu-view.jpg" attr="h" comment="HIPE View menu" date="1200329384" name="hipe-menu-view.jpg" path="hipe-menu-view.jpg" size="24016" stream="hipe-menu-view.jpg" user="Main.JorgoBakker" version="1" |
| |
> > |
META TOPICMOVED |
by="DavideRizzo" date="1272527966" from="Hcss.DpHipeViews" to="Public.DpHipeViews" |
|
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
| |
> > | | |
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
- 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
| |
< < |
| | | | makeActions();
} | |
< < | // private stuff
private ViewPart getPart() { return _part; } | > > | public ViewPart getPart() { return _part; } | |
private void makeActions() {
// create tool bars, menus and other stuff
}
}
| |
< < |
| |
Registry | | "site.view.myview",
"resides.in.java.package.MyView",
"My View", | |
< < | "resides/in/java/package/myview.gif"
)); | > > | "resides/in/java/package/myview.gif")) | |
See also the Extension Registry documentation for more details. | |
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:
| |
< < | private void somemethod() { | > > | private void someMethod() { | | :
getPart().getEventHandler().trigger(aSiteEvent)
: | |
| |
< < | Menus and toolbars | > > | Menus, toolbars and other features | | | |
< < | TODO | > > | You can learn about adding actions to your view, and more, following this link . | |
|
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
| |
< < | Example: Add a TableDataset viewer to Hipe (using TablePlotter as an example)
# Create a Component class for the view, for example, TablePlotterComponent
and overrde makeEditorContent method
package herschel.ia.gui.explorer.table;
import java.awt.BorderLayout;
import herschel.ia.dataset.gui.Explorer;
import herschel.ia.gui.apps.components.editor.AbstractExplorerComponent;
import herschel.ia.gui.kernel.util.IconLoader;
import javax.swing.Icon;
import javax.swing.JComponent;
public class TablePlotterComponent extends AbstractExplorerComponent {
private static final long serialVersionUID = 1L;
private static final Icon ICON = IconLoader.getKernelIcon("data/ImageDataset.gif");
public TablePlotterComponent() {
super(ICON);
}
@Override
protected boolean makeEditorContent() {
Object o = getSelection().getValue();
Explorer explorer = new TablePlotter();
explorer.setObject(o);
JComponent component = explorer.getComponent();
add(component, BorderLayout.CENTER);
component.addMouseListener(getArea().getMouseListener());
return true;
}
}
#Register the viewer (TablePlotter in init.py file)
import herschel
herschel.recursive_module_lookup(__name__,__path__,__file__)
del(herschel)
# --- End required code
from herschel.ia.gui.kernel import ExtensionRegistry, Extension
COMPONENT=ExtensionRegistry.COMPONENT
REGISTRY=ExtensionRegistry.getInstance()
print 'reading init.py'
REGISTRY.register(COMPONENT,Extension(
"TableDataset viewer",
"herschel.ia.gui.explorer.table.TablePlotterComponent",
"factory.editor.variable",
"herschel.ia.dataset.TableDataset"));
__all__=[]
#Create all.py file if it is not exist in its parent directory (explorer, for example)
""
Imports all ia sub packages either using "from pck.all import *" or "from pck import *"
"""
import herschel
herschel.loadpckg(globals(),
"herschel.ia.gui.explorer",
['table'])
del(herschel)
| |
Adding features |
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
| |
> > | Example: Add a TableDataset viewer to Hipe (using TablePlotter as an example)
# Create a Component class for the view, for example, TablePlotterComponent
and overrde makeEditorContent method
package herschel.ia.gui.explorer.table;
import java.awt.BorderLayout;
import herschel.ia.dataset.gui.Explorer;
import herschel.ia.gui.apps.components.editor.AbstractExplorerComponent;
import herschel.ia.gui.kernel.util.IconLoader;
import javax.swing.Icon;
import javax.swing.JComponent;
public class TablePlotterComponent extends AbstractExplorerComponent {
private static final long serialVersionUID = 1L;
private static final Icon ICON = IconLoader.getKernelIcon("data/ImageDataset.gif");
public TablePlotterComponent() {
super(ICON);
}
@Override
protected boolean makeEditorContent() {
Object o = getSelection().getValue();
Explorer explorer = new TablePlotter();
explorer.setObject(o);
JComponent component = explorer.getComponent();
add(component, BorderLayout.CENTER);
component.addMouseListener(getArea().getMouseListener());
return true;
}
}
#Register the viewer (TablePlotter in init.py file)
import herschel
herschel.recursive_module_lookup(__name__,__path__,__file__)
del(herschel)
# --- End required code
from herschel.ia.gui.kernel import ExtensionRegistry, Extension
COMPONENT=ExtensionRegistry.COMPONENT
REGISTRY=ExtensionRegistry.getInstance()
print 'reading init.py'
REGISTRY.register(COMPONENT,Extension(
"TableDataset viewer",
"herschel.ia.gui.explorer.table.TablePlotterComponent",
"factory.editor.variable",
"herschel.ia.dataset.TableDataset"));
__all__=[]
#Create all.py file if it is not exist in its parent directory (explorer, for example)
""
Imports all ia sub packages either using "from pck.all import *" or "from pck import *"
"""
import herschel
herschel.loadpckg(globals(),
"herschel.ia.gui.explorer",
['table'])
del(herschel)
| | Adding features
|
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
| |
< < | | |
| |
> > | <--
Some short-cuts
--> | | Basic Steps
 | | The aim is that your contribution is automatically picked up by the 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
herschel.ia.kernel.parts.Viewable interface by extended a JComponent implementation.
- Register your implementation to the
herschel.ia.kernel.ExtensionRegistry in the __init__.py
| > > |
- Implement the Viewable interface by sub-classing any %JCOMPONENT% implementation.
- Register your implementation to the Extension 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 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 method.
| > > |
- 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
| |
Registry
| |
< < | The following snippet registers the above view within your package __init__.py : | > > | The following snippet registers the above view within your package's init.py: | |
REGISTRY.register(VIEWABLE, Extension(
| |
< < | "site.view.myview", # a unique ID, could be the same as ...
"resides.in.java.package.MyView", # the class holding the implementation
"My View", # how it should be called in the menu
"resides/in/java/package/myview.gif" # resource of possible icon (can be None) | > > | "site.view.myview",
"resides.in.java.package.MyView",
"My View",
"resides/in/java/package/myview.gif" | | ));
| |
< < | See also the Extension Registry documentation for more details. | > > | See also the Extension Registry documentation for more details. | |
| |
Trigger events
| |
< < | Your viewable may want to trigger site events which might be interesting to other views. The herschel.ia.kernel.parts.ViewPart interface that is passed on through the init method gives you the means of triggering site events: | > > | 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: | |
private void somemethod() {
:
| |
Receiving events
| |
< < | Your viewable may want to listen to site events produced by other views. For that you have to implement the herschel.ia.kernel.SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.: | > > | Your viewable may want to listen to site events produced by other views. For that you have to implement the SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.: | |
| |
< < | public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener { | > > | public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener { | |
public void init(ViewPart part) {
: |
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | | The aim is that your contribution is automatically picked up by the 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
herschel.ia.core.parts.Viewable interface by extended a JComponent implementation.
- Register your implementation to the
herschel.ia.core.ExtensionRegistry in the __init__.py
| > > |
- Implement the
herschel.ia.kernel.parts.Viewable interface by extended a JComponent implementation.
- Register your implementation to the
herschel.ia.kernel.ExtensionRegistry in the __init__.py
| |
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
| |
Trigger events
| |
< < | Your viewable may want to trigger site events which might be interesting to other views. The herschel.ia.core.parts.ViewPart interface that is passed on through the init method gives you the means of triggering site events: | > > | Your viewable may want to trigger site events which might be interesting to other views. The herschel.ia.kernel.parts.ViewPart interface that is passed on through the init method gives you the means of triggering site events: | |
private void somemethod() {
:
| |
Receiving events
| |
< < | Your viewable may want to listen to site events produced by other views. For that you have to implement the herschel.ia.core.SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.: | > > | Your viewable may want to listen to site events produced by other views. For that you have to implement the herschel.ia.kernel.SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.: | |
public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener {
|
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
Basic Steps | |
> > | | |
The aim is that your contribution is automatically picked up by the infrastructure, such that your view is added to the view menu, as shown in the picture on the right. | |
- In principle only one instance of a view should exist.
- The ID returned by your implementation must be unique
| |
> > | | |
Example | |
> > | | |
Implementation | |
> > | | |
public class MyView extends SomeSwingComponent implements Viewable {
private ViewPart _part;
| |
| |
> > | | |
Registry | |
> > | | | The following snippet registers the above view within your package __init__.py :
| |
< < | # import and short-cuts
from herschel.ia.core import ExtensionRegistry, Extension
VIEWABLE=ExtensionRegistry.VIEWABLE
REGISTRY=ExtensionRegistry.getInstance()
# registry | | REGISTRY.register(VIEWABLE, Extension(
"site.view.myview", # a unique ID, could be the same as ...
"resides.in.java.package.MyView", # the class holding the implementation
"My View", # how it should be called in the menu
"resides/in/java/package/myview.gif" # resource of possible icon (can be None) | |
< < | ));
# cleanup
del(ExtensionRegistry,Extension,REGISTRY,VIEWABLE) | > > | )); | |
| |
> > | See also the Extension Registry documentation for more details.
| |
Adding features | |
> > | | |
Trigger events | |
> > | | | Your viewable may want to trigger site events which might be interesting to other views. The herschel.ia.core.parts.ViewPart interface that is passed on through the init method gives you the means of triggering site events:
private void somemethod() {
| | :
}
| |
> > | | |
Receiving events | |
> > | | | Your viewable may want to listen to site events produced by other views. For that you have to implement the herschel.ia.core.SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.:
public class MyView extends SomeSwingComponent implements Viewable, SiteEventListener {
| |
}
| |
< < | | > > | | |
Menus and toolbars | |
> > | | | TODO | |
> > |
| |
<-- Author: JorgoBakker --> |
|
META TOPICPARENT |
name="DpHipe" |
Creating a View | |
| |
< < | TODO | | \ No newline at end of file | |
> > | Basic Steps
The aim is that your contribution is automatically picked up by the 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
herschel.ia.core.parts.Viewable interface by extended a JComponent implementation.
- Register your implementation to the
herschel.ia.core.ExtensionRegistry in the __init__.py
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 method.
- In principle only one instance of a view should exist.
- The ID returned by your implementation must be unique
Example
Implementation
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
}
}
Registry
The following snippet registers the above view within your package __init__.py :
# import and short-cuts
from herschel.ia.core import ExtensionRegistry, Extension
VIEWABLE=ExtensionRegistry.VIEWABLE
REGISTRY=ExtensionRegistry.getInstance()
# registry
REGISTRY.register(VIEWABLE, Extension(
"site.view.myview", # a unique ID, could be the same as ...
"resides.in.java.package.MyView", # the class holding the implementation
"My View", # how it should be called in the menu
"resides/in/java/package/myview.gif" # resource of possible icon (can be None)
));
# cleanup
del(ExtensionRegistry,Extension,REGISTRY,VIEWABLE)
Adding features
Trigger events
Your viewable may want to trigger site events which might be interesting to other views. The herschel.ia.core.parts.ViewPart interface that is passed on through the init method gives you the means of triggering site events:
private void somemethod() {
:
getPart().getEventHandler().trigger(aSiteEvent)
:
}
Receiving events
Your viewable may want to listen to site events produced by other views. For that you have to implement the herschel.ia.core.SiteEventListener interface and inform the event handler that you are interested in one or more event types, e.g.:
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;
:
}
}
Menus and toolbars
TODO
<-- Author: JorgoBakker -->
META FILEATTACHMENT |
attachment="hipe-menu-view.jpg" attr="h" comment="HIPE View menu" date="1200329384" name="hipe-menu-view.jpg" path="hipe-menu-view.jpg" size="24016" stream="hipe-menu-view.jpg" user="Main.JorgoBakker" version="1" |
|
|
> > |
META TOPICPARENT |
name="DpHipe" |
Creating a View
<-- summary -->
You can develop new views and add them to the work-bench of HIPE. This section briefly explains how to do this.
TODO |
|
|
|
|
|