|
|
META TOPICPARENT |
name="DpHipe" |
<-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END --> | |
Editor area |
ia_gui_kernel |
herschel.ia.gui.kernel.parts.EditorArea herschel.ia.gui.kernel.parts.impl.EditorAreaImpl |
Menus & toolbars |
ia_gui_kernel |
herschel.ia.gui.kernel.menus.MenuManager herschel.ia.gui.kernel.menus.MenuManagerImpl |
Look & feel |
ia_gui_kernel |
herschel.ia.gui.kernel.parts.impl.AbstractSite |
| |
< < |
Start-up |
ia_gui_kernel ia_gui_apps |
herschel.ia.gui.kernel.util.SplashWindow herschel.ia.gui.apps.Hipe herschel.ia.gui.apps.HipeStarter |
| > > |
Start-up |
ia_gui_apps ia_gui_kernel |
herschel.ia.gui.apps.HipeStarter herschel.ia.gui.kernel.SiteApplication herschel.ia.gui.kernel.util.SplashWindow |
| |
Welcome pages |
ia_gui_apps |
herschel.ia.gui.apps.views.welcome.WelcomeView |
Navigator |
ia_gui_apps |
herschel.ia.gui.apps.views.navigator.NavigatorView |
Outline |
ia_gui_apps |
herschel.ia.gui.apps.views.outline.OutlineView herschel.ia.gui.apps.views.outline.OutlineComponent herschel.ia.gui.apps.components.outline.* |
Script editor |
ia_jconsole |
herschel.ia.jconsole.views.JythonEditorComponent herschel.ia.jconsole.views.TextEditorComponent |
Console |
ia_jconsole |
herschel.ia.jconsole.views.ConsoleView herschel.ia.jconsole.jython.Interpreter herschel.ia.jconsole.jython.CommandExecutor |
Variables view |
ia_gui_apps |
herschel.ia.gui.apps.views.variables.VariablesView herschel.ia.gui.apps.views.variables..NameSpaceTree |
| |
< < |
Tasks view |
ia_task |
herschel.ia.task.views.TasksView herschel.ia.task.views..TaskTree |
| > > |
Tasks view |
ia_task |
herschel.ia.task.views.TasksView herschel.ia.task.views.TaskTree |
| | | | <-- END OF COMMENT BOX CODE -->
| |
< < |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="Script for Google Analytics" date="1350657576" name="GoogleAnalytics.txt" path="GoogleAnalytics.txt" size="549" user="Main.DavideRizzo" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like information dialog" date="1219146551" name="java-information.png" path="java-information.png" size="16352" user="Main.JaimeSaiz" version="1" |
| |
< < |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like error dialog" date="1219146474" name="hipe-error.png" path="hipe-error.png" size="11671" user="Main.JaimeSaiz" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="" date="1322143188" name="Developing_GUIs_in_HIPE.pdf" path="Developing_GUIs_in_HIPE.pdf" size="395374" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like confirmation dialog" date="1219146514" name="java-confirmation.png" path="java-confirmation.png" size="11085" user="Main.JaimeSaiz" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="Script for Google Analytics" date="1350657576" name="GoogleAnalytics.txt" path="GoogleAnalytics.txt" size="549" user="Main.DavideRizzo" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like confirmation dialog" date="1219146453" name="hipe-confirmation.png" path="hipe-confirmation.png" size="11328" user="Main.JaimeSaiz" version="1" |
META TOPICMOVED |
by="DavideRizzo" date="1272528356" from="Hcss.DpHipeCommonUtilities" to="Public.DpHipeCommonUtilities" |
|
|
META TOPICPARENT |
name="DpHipe" |
<-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END --> | |
Outline |
ia_gui_apps |
herschel.ia.gui.apps.views.outline.OutlineView herschel.ia.gui.apps.views.outline.OutlineComponent herschel.ia.gui.apps.components.outline.* |
Script editor |
ia_jconsole |
herschel.ia.jconsole.views.JythonEditorComponent herschel.ia.jconsole.views.TextEditorComponent |
Console |
ia_jconsole |
herschel.ia.jconsole.views.ConsoleView herschel.ia.jconsole.jython.Interpreter herschel.ia.jconsole.jython.CommandExecutor |
| |
< < |
Variables view |
ia_inspector |
herschel.ia.inspector.views.VariablesView herschel.ia.inspector.JNameSpaceTree |
Tasks view |
ia_inspector |
herschel.ia.inspector.views.TaskView herschel.ia.inspector.JTaskTree |
| > > |
Variables view |
ia_gui_apps |
herschel.ia.gui.apps.views.variables.VariablesView herschel.ia.gui.apps.views.variables..NameSpaceTree |
Tasks view |
ia_task |
herschel.ia.task.views.TasksView herschel.ia.task.views..TaskTree |
| | | | <-- END OF COMMENT BOX CODE -->
| |
> > |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="Script for Google Analytics" date="1350657576" name="GoogleAnalytics.txt" path="GoogleAnalytics.txt" size="549" user="Main.DavideRizzo" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like information dialog" date="1219146551" name="java-information.png" path="java-information.png" size="16352" user="Main.JaimeSaiz" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like error dialog" date="1219146474" name="hipe-error.png" path="hipe-error.png" size="11671" user="Main.JaimeSaiz" version="1" |
| |
< < |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="" date="1322143188" name="Developing_GUIs_in_HIPE.pdf" path="Developing_GUIs_in_HIPE.pdf" size="395374" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like confirmation dialog" date="1219146514" name="java-confirmation.png" path="java-confirmation.png" size="11085" user="Main.JaimeSaiz" version="1" |
| |
< < |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="Script for Google Analytics" date="1350657576" name="GoogleAnalytics.txt" path="GoogleAnalytics.txt" size="549" user="Main.DavideRizzo" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like confirmation dialog" date="1219146453" name="hipe-confirmation.png" path="hipe-confirmation.png" size="11328" user="Main.JaimeSaiz" version="1" |
META TOPICMOVED |
by="DavideRizzo" date="1272528356" from="Hcss.DpHipeCommonUtilities" to="Public.DpHipeCommonUtilities" |
|
|
META TOPICPARENT |
name="DpHipe" |
| |
> > | <-- ANALYTICS CODE - DO NOT EDIT -->
<-- Google Analytics script BEGIN -->
<-- Google Analytics script END -->
<-- END OF ANALYTICS CODE --> | | <--
- Set TOPICTITLE = Common utilities in HIPE
--> | | <-- END OF COMMENT BOX CODE -->
| |
< < |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like information dialog" date="1219146551" name="java-information.png" path="java-information.png" size="16352" user="Main.JaimeSaiz" version="1" |
| |
< < |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like error dialog" date="1219146474" name="hipe-error.png" path="hipe-error.png" size="11671" user="Main.JaimeSaiz" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="" date="1322143188" name="Developing_GUIs_in_HIPE.pdf" path="Developing_GUIs_in_HIPE.pdf" size="395374" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like confirmation dialog" date="1219146514" name="java-confirmation.png" path="java-confirmation.png" size="11085" user="Main.JaimeSaiz" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="h" autoattached="1" comment="Script for Google Analytics" date="1350657576" name="GoogleAnalytics.txt" path="GoogleAnalytics.txt" size="549" user="Main.DavideRizzo" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like confirmation dialog" date="1219146453" name="hipe-confirmation.png" path="hipe-confirmation.png" size="11328" user="Main.JaimeSaiz" version="1" |
META TOPICMOVED |
by="DavideRizzo" date="1272528356" from="Hcss.DpHipeCommonUtilities" to="Public.DpHipeCommonUtilities" |
|
|
META TOPICPARENT |
name="DpHipe" |
| |
If you are a maintainer of the HIPE framework, you might find useful the section below as well. | |
< < | The following advices comprise both common development in a Java application and some HIPE specific matters. | > > | The following advice includes common development in a Java application and some HIPE specific matters. | |
Choose appropriate log levels | |
< < | Log messages written with java.util.logging.Logger are now shown in the Log view. | > > | Log messages written with java.util.logging.Logger are shown in the Log view. | |
Please choose the log level appropriately, i.e. | |
Let the Stop button work | |
< < | One of the hot topics when working with HIPE is the little but important Stop button, which is meant for cancelling the current job. Letting it work properly is a cooperative issue. | > > | One of the hot topics when working with HIPE is the Stop button, which is meant for cancelling the current job. Letting it work properly is a cooperative issue. | |
When talking about cancellation in HIPE, we may divide three main areas: | |
- Avoid calling
SiteUtil.execAndWait(String command) and its variants from EDT even when the command does not perform any GUI stuff, since it could lead to a deadlock. If you want to execute a Jython command from EDT that involves any GUI operation, please call SiteUtil.execLater(String command) or use a SwingWorker .
| |
< < |
- Do not instantiate Swing's
JColorChooser directly; it has a bug that can lead the GUI to suffer deadlock. The ColorChooser class of ia_gui_kernel should be used instead.
| > > |
- Do not instantiate Swing's JColorChooser
directly; it has a bug that can lead the GUI to suffer deadlock. Use the ColorChooser class of ia_gui_kernel instead.
| |
Further information | |
< < | More advices can be found in the presentation Developing GUIs in HIPE . | > > | More advice can be found in the presentation Developing GUIs in HIPE . | |
| |
The Java Development Toolkit provides lots of libraries that developers coming from other languages like C/C++ find wonderful, because almost all basic funcionality in these languages need to be re-invented, copied or buyed. | |
< < | The Herschel Java code base is plenty of common utilities as well. Knowing them could help you in developing your tools with much less effort. | > > | The Herschel Java code base has plenty of common utilities as well. Knowing them could help you in developing your tools with much less effort. | |
Here is a list of some of these common packages: | |
< < |
# Share functionality
herschel.share.interpreter
herschel.share.io
herschel.share.predicate
herschel.share.unit
herschel.share.util
# Utilities related to GUIs
herschel.ia.gui.kernel.util
herschel.ia.gui.apps.components.util
herschel.ia.gui.apps.modifier
| > > |
- Share functionality
- Utilities related to GUIs
| |
Here are some classes that can be highlighted among them. Please consult their Javadoc for more information.
| |
< < |
herschel.ia.gui.apps.components.util |
BottomPanel |
Panel whose contents occupy all the available space from its position to the panel's container's bottom. |
ColumnsPanel |
Panel organizing components in columns. |
Dereferencer |
Loads an object or resource in the background, by informing HIPE of its busy status. |
ListModelAdapter |
Adapter of a ListModel to a ComboBoxModel . |
FoldingSectionsPanel |
Panel with sections in a vertical layout, where each section can be folded (hidden) or unfolded (shown) by the user with single clicks. |
herschel.ia.gui.apps.components.variable |
AbstractVariableTree |
Holds a VariableSelection that can be represented in a tree, triggering SelectionEvent when a node is clicked, providing a popup menu for opening children nodes, etc. |
herschel.ia.gui.kernel.util |
ImageUtil |
Fit an image to the given dimensions, make an image from a Java component. |
TableUtil |
Resize columns and rows of a JTable according to its contents, allow sorting the table by clicking on a column, by also letting to unsort the table afterwards. |
TreeUtil |
Some utilities for managing a JTree . |
herschel.share.io |
IOUtil |
Converts objects into byte array back and forth, through serialization, taking into account also objects handled by resolvers (like Product , Dataset , etc.). |
FileUtil |
Write and read text files in a line of code, avoid Windows' path separator problems in Jython commands, and more. |
ResolverRegistry |
Registers resolver instances that know how to serialize or deserialize objects not implementing Serializable . |
herschel.share.interpreter |
InterpreterUtil |
Utility methods regarding Jython. |
InterpreterNameSpaceUtil |
More on the same area. |
JythonConverters |
Generates the Jython code that would create a given object. |
herschel.share.util |
ClassMap |
Specialization of Map holding classes as keys, where values can be found taking into account class hierarchies of the key classes. |
InvertibleMap |
Specialization of Map that allows getting keys from values too. |
ObjectUtil |
Test of object equality taking nulls into account, straightforward implementation of hashCode() , create instances from class names with nice handling of exceptions, non wordy casts... |
StringUtil |
Fit a string to a given length, escape characters, flatten and unflatten string collections, encode and decode URLs... |
WeakHashSet |
Specialization of Set holding WeakReference internally, which means that they can be removed in the background if no pointed by any other reference. Useful for listener collections. |
| > > |
herschel.ia.gui.apps.components.util |
BottomPanel |
Panel whose contents occupy all the available space from its position to the panel's container's bottom. |
ColumnsPanel |
Panel organizing components in columns. |
Dereferencer |
Loads an object or resource in the background, by informing HIPE of its busy status. |
ListModelAdapter |
Adapter of a ListModel to a ComboBoxModel . |
FoldingSectionsPanel |
Panel with sections in a vertical layout, where each section can be folded (hidden) or unfolded (shown) by the user with single clicks. |
herschel.ia.gui.apps.components.variable |
AbstractVariableTree |
Holds a VariableSelection that can be represented in a tree, triggering SelectionEvent when a node is clicked, providing a popup menu for opening children nodes, etc. |
herschel.ia.gui.kernel.util |
ImageUtil |
Fit an image to the given dimensions, make an image from a Java component. |
TableUtil |
Resize columns and rows of a JTable according to its contents, allow sorting the table by clicking on a column, by also letting to unsort the table afterwards. |
TreeUtil |
Some utilities for managing a JTree . |
herschel.share.io |
IOUtil |
Converts objects into byte array back and forth, through serialization, taking into account also objects handled by resolvers (like Product , Dataset , etc.). |
FileUtil |
Write and read text files in a line of code, avoid Windows' path separator problems in Jython commands, and more. |
ResolverRegistry |
Registers resolver instances that know how to serialize or deserialize objects not implementing Serializable . |
herschel.share.interpreter |
InterpreterUtil |
Utility methods regarding Jython. |
InterpreterNameSpaceUtil |
More on the same area. |
JythonConverters |
Generates the Jython code that would create a given object. |
herschel.share.util |
ClassMap |
Specialization of Map holding classes as keys, where values can be found taking into account class hierarchies of the key classes. |
InvertibleMap |
Specialization of Map that allows getting keys from values too. |
ObjectUtil |
Test of object equality taking nulls into account, straightforward implementation of hashCode() , create instances from class names with nice handling of exceptions, non wordy casts... |
StringUtil |
Fit a string to a given length, escape characters, flatten and unflatten string collections, encode and decode URLs... |
WeakHashSet |
Specialization of Set holding WeakReference internally, which means that they can be removed in the background if no pointed by any other reference. Useful for listener collections. |
| |
This list can be expanded; feel free to enrich it with more useful classes (please respect the alphabetical order when doing so). | |
Trigger events | |
< < | The standard way of triggering events is to get a reference to the %EVENTHADLER% interface, which contains all related methods to the HIPE event system. This is typically done via the ViewPart interface that is passed on through the init method of the Viewable. | > > | The standard way of triggering events is to get a reference to the SiteEventHandler interface, which contains all related methods to the HIPE event system. This is typically done via the ViewPart interface that is passed on through the init method of the Viewable. | |
private void someMethod() {
:
| | <-- END OF COMMENT BOX CODE -->
| |
> > |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like information dialog" date="1219146551" name="java-information.png" path="java-information.png" size="16352" user="Main.JaimeSaiz" version="1" |
| |
> > |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like error dialog" date="1219146474" name="hipe-error.png" path="hipe-error.png" size="11671" user="Main.JaimeSaiz" version="1" |
| |
< < |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="" date="1322143188" name="Developing_GUIs_in_HIPE.pdf" path="Developing_GUIs_in_HIPE.pdf" size="395374" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like confirmation dialog" date="1219146514" name="java-confirmation.png" path="java-confirmation.png" size="11085" user="Main.JaimeSaiz" version="1" |
| |
< < |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
| |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like confirmation dialog" date="1219146453" name="hipe-confirmation.png" path="hipe-confirmation.png" size="11328" user="Main.JaimeSaiz" version="1" |
META TOPICMOVED |
by="DavideRizzo" date="1272528356" from="Hcss.DpHipeCommonUtilities" to="Public.DpHipeCommonUtilities" |
|
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
|
META TOPICPARENT |
name="DpHipe" |
| |
> > | <--
- Set TOPICTITLE = Common utilities in HIPE
-->
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! | | Common utilities in HIPE | | | |
> > | Please add your comments!
| | <--
--> |
|
META TOPICPARENT |
name="DpHipe" |
Common utilities in HIPE | |
Object variable = ...;
| |
< < | VariablesUtil.setVariable("yourVariable", variable); | > > | VariablesUtil.addVariable("yourVariable", variable); | |
|
|
META TOPICPARENT |
name="DpHipe" |
Common utilities in HIPE | |
The PopupDialog class
| |
< < | The Java Swing library provides a class for showing popup dialogs: JOptionPane . | > > | The Java Swing library provides a class for showing popup dialogs: JOptionPane . | | This class is used in different modules along the project.
Now, in order to unify the look and feel of dialogs, and to simplify the API as well (the calls to JOptionPane are normally too long), there is a wrapper class which should be used for showing popup dialogs in HIPE: PopupDialog. | |
Instead of needing to work with the Java API directly, when you want to load icons, HIPE provides some utilities for making the job easier: | |
< < |
- ia.gui.kernel.util.IconLibrary provides some static icons already loaded. If the icon you want to use is there, you are done.
- ia.gui.kernel.util.IconLoader provides static methods for loading an icon:
getIcon accepts a full path to an icon image, while getKernelIcon gets the provided icon image from the ia_gui_kernel location for icons.
| > > |
-
ia.gui.kernel.util.IconLibrary provides some static icons already loaded. If the icon you want to use is there, you are done.
-
ia.gui.kernel.util.IconLoader provides static methods for loading an icon: getIcon accepts a full path to an icon image, while getKernelIcon gets the provided icon image from the ia_gui_kernel location for icons.
| |
If you want to add an icon to the system in your own module, use IconLoader.getIcon with the full path. |
|
META TOPICPARENT |
name="DpHipe" |
Common utilities in HIPE | |
| |
 | |
< < |
PopupDialog belongs to ia_gui_kernel , so it can be used from virtually any module in the project (see jake.depend for exceptions). | > > | <-- PopupDialog belongs to ia_gui_kernel , so it can be used from virtually any module in the project (see jake.depend for exceptions). --> | |
You can use PopupDialog as well if your component is used by both HIPE and JIDE. It internally checks whether to show the HIPE style icons or the Java standard ones.
| |
Instead of needing to work with the Java API directly, when you want to load icons, HIPE provides some utilities for making the job easier: | |
< < |
- IconLibrary
provides some static icons already loaded. If the icon you want to use is there, you are done.
- IconLoader
provides static methods for loading an icon: getIcon accepts a full path to an icon image, while getKernelIcon gets the provided icon image from the ia_gui_kernel location for icons.
| > > |
- ia.gui.kernel.util.IconLibrary provides some static icons already loaded. If the icon you want to use is there, you are done.
- ia.gui.kernel.util.IconLoader provides static methods for loading an icon:
getIcon accepts a full path to an icon image, while getKernelIcon gets the provided icon image from the ia_gui_kernel location for icons.
| | | |
< < | If you want to add a new icon to the system in your own module, just use IconLoader.getIcon with the full path. | > > | If you want to add an icon to the system in your own module, use IconLoader.getIcon with the full path. | | |
|
META TOPICPARENT |
name="DpHipe" |
| |
< < | Common Utilities In Hipe | > > | Common utilities in HIPE | |
<-- summary --> | |
< < | This section explains some common and recurrent tasks in Hipe, like: | > > | This section explains some common and recurrent tasks in HIPE, like: | |
- Communicating Views or Components with other Views or Components, by triggering events.
- Send Jython statements for being executed by the Console.
| | Triggering events
SiteEventHandler interface
| |
< < | The standard way of triggering events is to get a reference to the %EVENTHADLER% interface, which contains all related methods to the Hipe event system. This is typically done via the ViewPart interface that is passed on through the init method of the Viewable. | > > | The standard way of triggering events is to get a reference to the %EVENTHADLER% interface, which contains all related methods to the HIPE event system. This is typically done via the ViewPart interface that is passed on through the init method of the Viewable. | |
private void someMethod() {
:
| |
SiteUtil class
| |
< < | The SiteUtil class provides a set of convenience methods to get access to the Hipe architecture. In order to get its access one condition must be met: | > > | The SiteUtil class provides a set of convenience methods to get access to the HIPE architecture. In order to get its access one condition must be met: | | | |
< < | you know at least a reference to a Component that is part of Hipe (i.e. you know at least one java.awt.Component visible in Hipe). | > > | you know at least a reference to a Component that is part of HIPE (i.e. you know at least one java.awt.Component visible in HIPE). | | | |
< < | Just assume that you are developing a Modifier for a task dialog and you want to inform Hipe about executing a required statement: the Modifier interface gives you no reference to a ViewPart so that you cannot trigger events in the previous way.
However you know that the Modifier is visible in Hipe and therefore you accomplish the SiteUtil constraint: | > > | Just assume that you are developing a Modifier for a task dialog and you want to inform HIPE about executing a required statement: the Modifier interface gives you no reference to a ViewPart so that you cannot trigger events in the previous way.
However you know that the Modifier is visible in HIPE and therefore you accomplish the SiteUtil constraint: | |
private void someMethod() {
:
| |
Sending execution events
| |
< < | Hipe has a dedicated Event for asking the execution of Jython statement: CommandExecutionRequestEvent. | > > | HIPE has a dedicated Event for asking the execution of Jython statement: CommandExecutionRequestEvent. | | The event is served by the ConsoleView and the result of its execution is visible both in the screen of the ConsoleView and in the list of the HistoryView (but you don't need to know about these views and their api). | |
< < | Every time a CommandExecutionRequestEvent event is served, Hipe generates an equivalent CommandExecutedEvent tracing the original CommandExecutionRequestEvent, so you can easily synchronize on the completion of the execution. However, this is not needed either, since SiteUtil class provides a convenient method for doing it: execAndWait . | > > | Every time a CommandExecutionRequestEvent event is served, HIPE generates an equivalent CommandExecutedEvent tracing the original CommandExecutionRequestEvent, so you can easily synchronize on the completion of the execution. However, this is not needed either, since SiteUtil class provides a convenient method for doing it: execAndWait . | |
private void someMethod() {
| | The Java Swing library provides a class for showing popup dialogs: JOptionPane .
This class is used in different modules along the project. | |
< < | Now, in order to unify the look and feel of dialogs, and to simplify the API as well (the calls to JOptionPane are normally too long), there is a wrapper class which should be used for showing popup dialogs in Hipe: PopupDialog. | > > | Now, in order to unify the look and feel of dialogs, and to simplify the API as well (the calls to JOptionPane are normally too long), there is a wrapper class which should be used for showing popup dialogs in HIPE: PopupDialog. | | | |
< < | Using this class we ensure that we use Hipe-like icons instead of Java-like icons: | > > | Using this class we ensure that we use HIPE-like icons instead of Java-like icons: | | | |
< < | Dialogs with Hipe-like icons | > > | Dialogs with HIPE-like icons | |
 | |
How to load icons | |
< < | Icons are widely used in Hipe. | > > | Icons are widely used in HIPE. | | | |
< < | Instead of needing to work with the Java API directly, when you want to load icons, Hipe provides some utilities for making the job easier: | > > | Instead of needing to work with the Java API directly, when you want to load icons, HIPE provides some utilities for making the job easier: | |
- IconLibrary
provides some static icons already loaded. If the icon you want to use is there, you are done.
- IconLoader
provides static methods for loading an icon: getIcon accepts a full path to an icon image, while getKernelIcon gets the provided icon image from the ia_gui_kernel location for icons.
|
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | | | |
> > | <--
--> | |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like information dialog" date="1219146551" name="java-information.png" path="java-information.png" size="16352" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like error dialog" date="1219146474" name="hipe-error.png" path="hipe-error.png" size="11671" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
|
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like confirmation dialog" date="1219146514" name="java-confirmation.png" path="java-confirmation.png" size="11085" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like confirmation dialog" date="1219146453" name="hipe-confirmation.png" path="hipe-confirmation.png" size="11328" user="Main.JaimeSaiz" version="1" |
| |
< < |
META TOPICMOVED |
by="JaimeSaiz" date="1219135252" from="Hcss.DpHipeEventExecution" to="Hcss.DpHipeCommonUtilities" |
| > > |
META TOPICMOVED |
by="DavideRizzo" date="1272528356" from="Hcss.DpHipeCommonUtilities" to="Public.DpHipeCommonUtilities" |
|
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
Prefer this way when you want the variable creation be recorded in the history, so it can be reproduced later. | |
< < | Example :
For the PolygonHistogramPanel we need to construct a Double1d with the corners of the polygon (which are listed in Double1d edges) and add it to the variables map of the task panel : | > > | Example:
For the PolygonHistogramPanel we need to construct a Double1d with the corners of the polygon (which are listed in Double1d edges) and add it to the variables map of the task panel : | |
Command c = SiteUtil.execAndWait("Double1d(" + edges.toString() + ")", "pyedges");
String name = c.getOutputName();
| |
< < | Object value = InterpreterFactory.getInterpreter().get(name, Double1d.class); | > > | Object value = c.getOutputValue(); | | VariableSelection edgesPixel = new VariableSelection(name, value); | |
< < | this.getMap().put(this.getTask().getSignature().getTaskParameter("edgesPixel"), edgesPixel); | > > | getMap().put(getTask().getSignature().getTaskParameter("edgesPixel"), edgesPixel); | |
|
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
Prefer this way when you want the variable creation be recorded in the history, so it can be reproduced later. | |
> > | Example :
For the PolygonHistogramPanel we need to construct a Double1d with the corners of the polygon (which are listed in Double1d edges) and add it to the variables map of the task panel :
Command c = SiteUtil.execAndWait("Double1d(" + edges.toString() + ")", "pyedges");
String name = c.getOutputName();
Object value = InterpreterFactory.getInterpreter().get(name, Double1d.class);
VariableSelection edgesPixel = new VariableSelection(name, value);
this.getMap().put(this.getTask().getSignature().getTaskParameter("edgesPixel"), edgesPixel);
| | Without echo to the console
In this case, you can create the variable with any Java code (not to be executed by the interpreter), and then publish it like this: |
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
Object variable = ...;
| |
< < | InterpreterFactory.getInterpreter().set("yourVariable", variable);
SiteUtil.trigger(new VariablesCreatedEvent(this, Collections.singletonMap("yourVariable", variable))); | > > | VariablesUtil.setVariable("yourVariable", variable); | |
|
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
| |
> > | | |
<--
--> | |
If you want to add a new icon to the system in your own module, just use IconLoader.getIcon with the full path. | |
> > | | |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like information dialog" date="1219146551" name="java-information.png" path="java-information.png" size="16352" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like error dialog" date="1219146474" name="hipe-error.png" path="hipe-error.png" size="11671" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
|
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
| |
> > |
Creating variables
During the processing of a particular view, it may be wanted to create a variable, so that it is shown in the Variables view and the user can do a further work with it.
Creating a variable can be done either with or without echo to the console.
With echo to the console
Just use one of the methods provided by SiteUtil :
- Synchronous call:
Command result = SiteUtil.execAndWait("yourVariable", "Something()"); // result will inform about the executed command
- Asynchronous call:
SiteUtil.execLater("yourVariable", "Something()"); // request execution to the interpreter but return immediately
Prefer this way when you want the variable creation be recorded in the history, so it can be reproduced later.
Without echo to the console
In this case, you can create the variable with any Java code (not to be executed by the interpreter), and then publish it like this:
Object variable = ...;
InterpreterFactory.getInterpreter().set("yourVariable", variable);
SiteUtil.trigger(new VariablesCreatedEvent(this, Collections.singletonMap("yourVariable", variable)));
Prefer this way when the creation of the variable is so complex that doing it with Jython commands would be too difficult.
| | Showing popup dialogs
The PopupDialog class |
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
| |
< < | from herschel.ia.gui.kernel import SiteUtil | > > | from herschel.ia.gui.kernel.util import SiteUtil | | from javax.swing import *
frame = JFrame("Hello Jython") |
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe |
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
PopupDialog belongs to ia_gui_kernel , so it can be used from virtually any module in the project (see jake.depend for exceptions). | |
> > |
You can use PopupDialog as well if your component is used by both HIPE and JIDE. It internally checks whether to show the HIPE style icons or the Java standard ones. | |
Sample Java code |
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |  | |
< < | PopupDialog belongs to ia_gui_kernel , so it can be used from any module in the project. | > > | PopupDialog belongs to ia_gui_kernel , so it can be used from virtually any module in the project (see jake.depend for exceptions). | |
Sample Java code |
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | | int option = PopupDialog.YES_NO_CANCEL_OPTION;
String title = "Unsaved changes";
String message = fileName + " has unsaved changes.\nSave before closing?"; | |
< < | int res = PopupDialog.showConfirm(this, message, title, option); | > > | int res = PopupDialog.showConfirm(this, message, option, title); | | if (res == PopupDialog.YES) {
saveFile();
} |
|
META TOPICPARENT |
name="DpHipe" |
Common Utilities In Hipe | |
Using this class we ensure that we use Hipe-like icons instead of Java-like icons: | |
< < | Dialogs with Hipe-like icons | > > | Dialogs with Hipe-like icons | | | |
< < | Dialogs with Java-like icons | > > |
Dialogs with Java-like icons
PopupDialog belongs to ia_gui_kernel , so it can be used from any module in the project. | |
Sample Java code | |
| |
> > | How to load icons
Icons are widely used in Hipe.
Instead of needing to work with the Java API directly, when you want to load icons, Hipe provides some utilities for making the job easier:
- IconLibrary
provides some static icons already loaded. If the icon you want to use is there, you are done.
- IconLoader
provides static methods for loading an icon: getIcon accepts a full path to an icon image, while getKernelIcon gets the provided icon image from the ia_gui_kernel location for icons.
If you want to add a new icon to the system in your own module, just use IconLoader.getIcon with the full path.
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like information dialog" date="1219146551" name="java-information.png" path="java-information.png" size="16352" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like error dialog" date="1219146474" name="hipe-error.png" path="hipe-error.png" size="11671" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like warning dialog" date="1219146496" name="hipe-warning.png" path="hipe-warning.png" size="13301" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like confirmation dialog" date="1219146514" name="java-confirmation.png" path="java-confirmation.png" size="11085" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Java-like error dialog" date="1219146531" name="java-error.png" path="java-error.png" size="13505" user="Main.JaimeSaiz" version="1" |
META FILEATTACHMENT |
attr="" autoattached="1" comment="Hipe-like confirmation dialog" date="1219146453" name="hipe-confirmation.png" path="hipe-confirmation.png" size="11328" user="Main.JaimeSaiz" version="1" |
| |
META TOPICMOVED |
by="JaimeSaiz" date="1219135252" from="Hcss.DpHipeEventExecution" to="Hcss.DpHipeCommonUtilities" |
|
|
META TOPICPARENT |
name="DpHipe" |
| |
< < | Triggering Events and Executing Statements In Hipe | > > | Common Utilities In Hipe | |
<-- summary --> | |
< < | It is possible to communicate to Hipe and to all its Views by triggering events, with this you can also achieve to execute
Jython statement whenever is necessary. | > > | This section explains some common and recurrent tasks in Hipe, like: | | | |
< < | This section explains how you can send events to Hipe. | > > |
- Communicating Views or Components with other Views or Components, by triggering events.
- Send Jython statements for being executed by the Console.
- The common way of showing errors and messages.
- How to load icons.
| |
| | <--
--> | |
< < |
SiteEventHandler interface | > > | Triggering events
SiteEventHandler interface | | | |
< < | The standard way to trigger events is to get a reference to the %EVENTHADLER% interface, which contains all related methods to the Hipe event system. This is typically done via the ViewPart interface that is passed on through the init method of the Viewable. | > > | The standard way of triggering events is to get a reference to the %EVENTHADLER% interface, which contains all related methods to the Hipe event system. This is typically done via the ViewPart interface that is passed on through the init method of the Viewable. | |
private void someMethod() {
:
| | However there are cases where you do not have access to a Viewable and you still want to trigger events for informing the rest of the system about something. In order to achieve this you can use a utility method available in a dedicated utility class.
| |
< < | SiteUtil class | > > | SiteUtil class | |
The SiteUtil class provides a set of convenience methods to get access to the Hipe architecture. In order to get its access one condition must be met: | |
| |
< < | Executing Jython statements via the Event system | > > | Executing Jython statements
Sending execution events | |
Hipe has a dedicated Event for asking the execution of Jython statement: CommandExecutionRequestEvent.
The event is served by the ConsoleView and the result of its execution is visible both in the screen of the ConsoleView and in the list of the HistoryView (but you don't need to know about these views and their api). | |
< < | Every time a CommandExecutionRequestEvent event is served Hipe generates an equivalent CommandExecutedEvent event tracing the original CommandExecutionRequestEvent so you can easily synchronize on the completion of the execution. However this is not needed neither as SiteUtil class provides a convenient method for doing it: execAndWait . | > > | Every time a CommandExecutionRequestEvent event is served, Hipe generates an equivalent CommandExecutedEvent tracing the original CommandExecutionRequestEvent, so you can easily synchronize on the completion of the execution. However, this is not needed either, since SiteUtil class provides a convenient method for doing it: execAndWait . | |
private void someMethod() {
| | :
}
| |
< < | The execAndWait method returns a Command tracing all the information about its execution including the statement result (isSuccesful() ),
last but not least, SiteUtil contains other utility methods that allow for more options including a un-synchronized execution method. | | | |
< < | See SiteUtil for the full detail. | > > | The execAndWait method returns a Command tracing all the information about its execution including the statement result (isSuccesful() ).
Last but not least, SiteUtil contains other utility methods that allow for more options including a un-synchronized execution method. See SiteUtil for the full detail.
| | | |
< < | A Jython Example | > > | A Jython Example | | | |
< < | This example provides a quick script for testing the SiteUtil execution functionality directly from the console. | > > | This example provides a short script for testing the SiteUtil execution functionality directly from the console. | | Please note: | |
< < |
- the reference used is
_jconsole which is name available in jython and pointing to the jconsole (indeed visible)
- the call is synchronous and therefore it stops the gui thread for the time of the execution (see http://java.sun.com/docs/books/tutorial/uiswing/concurrency/
for a general discussion about gui and thread).
| > > |
- the reference used is
_jconsole , which is a name available in jython and pointing to the jconsole (indeed visible).
- the call is synchronous and therefore it stops the gui thread for the time of the execution (see http://java.sun.com/docs/books/tutorial/uiswing/concurrency/
for a general discussion about gui and threads).
| | | |
> > | | |
from herschel.ia.gui.kernel import SiteUtil
from javax.swing import *
| | frame.setSize(300, 300)
frame.show()
| |
> > |
Showing popup dialogs
The PopupDialog class
The Java Swing library provides a class for showing popup dialogs: JOptionPane .
This class is used in different modules along the project.
Now, in order to unify the look and feel of dialogs, and to simplify the API as well (the calls to JOptionPane are normally too long), there is a wrapper class which should be used for showing popup dialogs in Hipe: PopupDialog. | | | |
> > | Using this class we ensure that we use Hipe-like icons instead of Java-like icons:
Dialogs with Hipe-like icons
Dialogs with Java-like icons
Sample Java code
The API is easy and self-explanatory, just consult PopupDialog.
For example, the first dialog above could be generated with the following code:
int option = PopupDialog.YES_NO_CANCEL_OPTION;
String title = "Unsaved changes";
String message = fileName + " has unsaved changes.\nSave before closing?";
int res = PopupDialog.showConfirm(this, message, title, option);
if (res == PopupDialog.YES) {
saveFile();
}
if (res != PopupDialog.CANCEL && res != PopupDialog.CLOSED) {
closeEditor();
}
| | | |
> > | | | | |
< < | -- NicolaDeCandussio - 05 Jun 2008 | > > |
META TOPICMOVED |
by="JaimeSaiz" date="1219135252" from="Hcss.DpHipeEventExecution" to="Hcss.DpHipeCommonUtilities" |
|
|
META TOPICPARENT |
name="DpHipe" |
Triggering Events and Executing Statements In Hipe | | | |
< < | | > > | | | | | Every time a CommandExecutionRequestEvent event is served Hipe generates an equivalent CommandExecutedEvent event tracing the original CommandExecutionRequestEvent so you can easily synchronize on the completion of the execution. However this is not needed neither as SiteUtil class provides a convenient method for doing it: execAndWait .
| |
< < | private void somemethod() { | > > | private void someMethod() { | | :
// this is the reference to the modifier | |
< < | Command c = SiteUtil.execAndWait(this, "PRINT \"SOMETHING\""); | > > | Command c = SiteUtil.execAndWait(this, "print 'something'"); | | :
}
|
|
META TOPICPARENT |
name="DpHipe" |
Triggering Events and Executing Statements In Hipe | |
The SiteUtil class provides a set of convenience methods to get access to the Hipe architecture. In order to get its access one condition must be met: | |
< < | you know at least a reference to a Component that is part of Hipe (i.e. you know at least one javax.swing.Component visible in Hipe). | > > | you know at least a reference to a Component that is part of Hipe (i.e. you know at least one java.awt.Component visible in Hipe). | |
Just assume that you are developing a Modifier for a task dialog and you want to inform Hipe about executing a required statement: the Modifier interface gives you no reference to a ViewPart so that you cannot trigger events in the previous way.
However you know that the Modifier is visible in Hipe and therefore you accomplish the SiteUtil constraint: |
|
META TOPICPARENT |
name="DpHipe" |
| |
< < | Triggering Events and Executing Statement In Hipe | > > | Triggering Events and Executing Statements In Hipe | |
<-- summary --> | | -->
| |
< < | | > > | SiteEventHandler interface | | | |
< < | The standard way to trigger events is to get a reference to the %EVENTHADLER% interface which contains all related methods to the Hipe event system. This is typically achieved via the the ViewPart interface that is passed on through the init method of the Viewable. | > > | The standard way to trigger events is to get a reference to the %EVENTHADLER% interface, which contains all related methods to the Hipe event system. This is typically done via the ViewPart interface that is passed on through the init method of the Viewable. | |
| |
< < | private void somemethod() { | > > | private void someMethod() { | | : | |
< < | getPart().getEventHandler().trigger(aSiteEvent) | > > | getPart().getEventHandler().trigger(aSiteEvent); | | :
}
| |
< < | However there are cases where you do not have access to a Viewable and you still want to trigger events for informing the rest of the system about something. In order to achieve it you can use a utility method available in a dedicated utility class. | > > | However there are cases where you do not have access to a Viewable and you still want to trigger events for informing the rest of the system about something. In order to achieve this you can use a utility method available in a dedicated utility class. | | | |
< < | | > > | SiteUtil class | |
The SiteUtil class provides a set of convenience methods to get access to the Hipe architecture. In order to get its access one condition must be met: | |
< < | you know at least a reference to a Component that is part of Hipe (i.e. you know at lest one javax.swing.Component visible in Hipe). | > > | you know at least a reference to a Component that is part of Hipe (i.e. you know at least one javax.swing.Component visible in Hipe). | | | |
< < | Just assume that you are developing a Modifier for a task dialog and you want inform Hipe about executing a required statement: the Modifier interface gives you no reference to a VIEWPART so that you cannot trigger events. | > > | Just assume that you are developing a Modifier for a task dialog and you want to inform Hipe about executing a required statement: the Modifier interface gives you no reference to a ViewPart so that you cannot trigger events in the previous way. | | However you know that the Modifier is visible in Hipe and therefore you accomplish the SiteUtil constraint:
| |
< < | private void somemethod() { | > > | private void someMethod() { | | :
// this is the reference to the modifier
SiteUtil.trigger(this, aSiteEvent); | |
| |
< < | Executing Jython statements via the Event system. | > > | Executing Jython statements via the Event system | |
Hipe has a dedicated Event for asking the execution of Jython statement: CommandExecutionRequestEvent.
The event is served by the ConsoleView and the result of its execution is visible both in the screen of the ConsoleView and in the list of the HistoryView (but you don't need to know about these views and their api). | |
See SiteUtil for the full detail. | |
< < | A Jtyhon Example | > > | A Jython Example | |
This example provides a quick script for testing the SiteUtil execution functionality directly from the console.
Please note: |
|
> > |
META TOPICPARENT |
name="DpHipe" |
Triggering Events and Executing Statement In Hipe
<-- summary -->
It is possible to communicate to Hipe and to all its Views by triggering events, with this you can also achieve to execute
Jython statement whenever is necessary.
This section explains how you can send events to Hipe.
<--
Some short-cuts
-->
<--
-->
The standard way to trigger events is to get a reference to the %EVENTHADLER% interface which contains all related methods to the Hipe event system. This is typically achieved via the the ViewPart interface that is passed on through the init method of the Viewable.
private void somemethod() {
:
getPart().getEventHandler().trigger(aSiteEvent)
:
}
However there are cases where you do not have access to a Viewable and you still want to trigger events for informing the rest of the system about something. In order to achieve it you can use a utility method available in a dedicated utility class.
The SiteUtil class provides a set of convenience methods to get access to the Hipe architecture. In order to get its access one condition must be met:
you know at least a reference to a Component that is part of Hipe (i.e. you know at lest one javax.swing.Component visible in Hipe).
Just assume that you are developing a Modifier for a task dialog and you want inform Hipe about executing a required statement: the Modifier interface gives you no reference to a VIEWPART so that you cannot trigger events.
However you know that the Modifier is visible in Hipe and therefore you accomplish the SiteUtil constraint:
private void somemethod() {
:
// this is the reference to the modifier
SiteUtil.trigger(this, aSiteEvent);
:
}
Executing Jython statements via the Event system.
Hipe has a dedicated Event for asking the execution of Jython statement: CommandExecutionRequestEvent.
The event is served by the ConsoleView and the result of its execution is visible both in the screen of the ConsoleView and in the list of the HistoryView (you don't need to know about these views and their api).
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/
Every time an CommandExecutionRequestEvent event is served Hipe generates an equivalent CommandExecutedEvent event traces the original CommandExecutionRequestEvent event so that you can easily synchronize on the completion of execution. However this is not needed neither as SiteUtil class provides a convenient method for doing it: execAndWait .
private void somemethod() {
:
// this is the reference to the modifier
Command c = SiteUtil.execAndWait(this, "PRINT \"SOMETHING\"");
:
}
The execAndWait method returns a Command tracing all the information about its execution including the statement result (isSuccesful() ),
last but not least, SiteUtil contains other utility methods that allow for more options including a un-synchronized execution method.
See SiteUtil for the full detail.
A Jtyhon Example
This example provides a quick script for testing the SiteUtil execution functionality directly from the console.
Please note:
- the reference used is
_jconsole which is name available in jython and pointing to the jconsole (indeed visible)
- the call is synchronous and therefore it stops the gui thread for the time of the execution (see http://java.sun.com/docs/books/tutorial/uiswing/concurrency/
for a general discussion about gui and thread).
from herschel.ia.gui.kernel import SiteUtil
from javax.swing import *
frame = JFrame("Hello Jython")
def perform(event):
SiteUtil.execAndWait(_jconsole, "2*2", "A")
button = JButton("Press me", actionPerformed=perform)
frame.add(button)
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
frame.setSize(300, 300)
frame.show()
-- NicolaDeCandussio - 05 Jun 2008 |
|
|
|
|
|
|
|
|
|
|