Menu System
Description of adding menus and context menus to Kepler.
Kepler includes an extensible menuing system which can be modified by modules at startup or manually via configuration file editing. The menu system is controlled by two different configuration files. One for the main Kepler menu bar and the other for context specific (right click) menus.
Adding a main menu item
The main menu configuration file can be found at $KEPLER/gui/resources/configurations/uiMenuMappings_en_US.xml. This file contains name/value pairs for each menu item in the Kepler menu bar. There are two different types of values. The first allows you to map a Kepler menu to an existing Ptolemy menu. They look like this:
<pair> <name>~File->Open ~File...</name> <value>File->Open File</value> </pair>
The name is the name that appears in the GUI. The tilda (~) denoted the key combo letter for Windows alt-key navigation. The value in this case is a pointer to the Ptolemy menu item.
The other type of map allows you to create a menu item and write a Kepler-only action for that item. It looks like this:
<pair> <name>File->Open Archive (KAR)</name> <value>org.kepler.gui.kar.OpenArchiveAction</value> </pair>
This creates the File/Open Archive (KAR) menu item and maps it's action to org.kepler.gui.kar.OpenArchiveAction. The class OpenArchiveAction extends ptolemy.vergil.toolbox.FigureAction, which includes the actionPerformed method called when the menu item is chosen by a user.
Adding a context menu item
Editing the context menu is similar to the main menu system. The configuration file that controls context menus is gui/resources/configurations/uiContextMenuMappings_en_US.xml. This file is formatted similar to the main menu configuration file with the main exception that the item that the context menu is activated from is listed in the <name> field as an all-caps keyword.
<pair> <name>DIRECTOR->Configure Director</name> <value>DIRECTOR->Customize->Configure</value> </pair>
In the example above, we are adding the "Configure Director" menu item which is only activated when right clicking on a Director.
Context menus can also be linked directly to actions.
<pair> <name>ACTOR->Get Metadata</name> <value>org.ecoinformatics.seek.ecogrid.quicksearch.GetMetadataAction</value> </pair>
Once again, the GetMetadataAction class extends FigureAction to provide API access to the user event.
Extending the configuration in a module
The menu configuration files can be edited directly for an instance of Kepler, or a module can programatically modify them at startup time for a more permanent change based on a custom distribution of Kepler. See the section "Overriding Configuration Properties from a Custom Module at Startup Time" in the configuration system documentation for more information.