META TOPICPARENT |
name="DpHipe" |
Adding Components to existing Views
<-- summary -->
Certain views as well can be extended by developers such as the Outline View and the Editor Area. Both are examples of the system reacting on a data selection by the user.
Outline View
Whenever the user selects a session variable e.g. the Variables View, a SelectionEvent is sent around. The Outline View is listening to such an event and it tries to find the appropriate component that can show the outline information of that variable.
<-- If you follow the contract on outline components -->
- Implement the
herschel.ia.gui.views.OutlineComponent interface by extending a javax.swing.JComponent
- Register your implementation to the
herschel.ia.core.ExtensionRegistry in the __init__.py
An example:
Suppose you would like to create an outline for herschel.share.fltdyn.time.FineTime and you would like to show the contents in the outline view whenever a session variable of that type is selected by the user.
Component Implementation
In this example, we simply use a javax.swing.JLabel and write the contents of the FineTime object into the text of that label.
public class FineTimeOutline extends JLabel implements OutlineComponent {
public boolean setOutline(Selection selection, OutlineView view) {
VariableSelection var=(VariableSelection)selection;
setText(var.getValue().toString());
return true;
}
}
Component Registry
The following snippet, could then go into your __init__.py :
# convenience short-cuts
from herschel.ia.core import ExtensionRegistry, Extension
FACTORY=ExtensionRegistry.FACTORY
COMPONENT=ExtensionRegistry.COMPONENT
REGISTRY=ExtensionRegistry.getInstance()
# Register to the variable outline factory
REGISTRY.register(COMPONENT,Extension(
"My FineTime Outline",
"resides.in.java.package.FineTimeOutline",
"factory.outline.variable",
"herschel.share.fltdyn.time.FineTime"))
# clean-up
del(FACTORY,COMPONENT,REGISTRY)
More information about the extension registry can be found in its Java API (herschel.ia.core.ExtensionRegistry ).
Editor Area
The above showed an example of extending the outline view by adding a OutlineComponent . Similarly, you can contribute by developing a specific editor component.
Editor components are browsers or editors of data contents of a specific variable that is selected in the HIPE session.
- Implement the
herschel.ia.core.EditorComponent interface by extending a javax.swing.JComponent
- Register your implementation to the
herschel.ia.core.ExtensionRegistry in the __init__.py
TODO: Example |