Here's how to write Action classes for Kepler (This allows your code to be reusable and easily incorporated into the new menu framework when the time comes):
1) Write a public Action class that extends ptolemy.vergil.toolbox.FigureAction, and add your actual action code to the method:
public void actionPerformed(ActionEvent e)
(this is an abstract method, so it must be implemented in your class)
- See example code below for MyNewAction
2) Edit the file:
configs/ptolemy/configs/kepler/uiMenuMappings_en_US.properties
and add a mapping (note that the order in the file is the same order as on the menu).
Specifically, look in the documentation at the beginning of that file, under "# 2) INSTANTIATING NEW KEPLER ACTIONS"
A sample entry looks like:
Tools->~My\ New\ Menu\ Item=org.kepler.gui.MyNewAction, where MyNewAction is your class that extends FigureAction, as described above
================================================
// Example code for MyNewAction
public class MyNewAction extends FigureAction {
// Display Text pulled from resourcebundle:
private static String DISPLAY_NAME
= StaticResources.getDisplayString("actions.mynewaction.displayName", "");
private static String TOOLTIP
= StaticResources.getDisplayString("actions.mynewaction.tooltip", "");
/**
* Constructor
*
* @param parent the "frame" (derived from ptolemy.gui.Top)
* where the menu is being added.
*/
public MyNewAction (TableauFrame parent) {
super("");
this.parent = parent;
this.putValue(Action.NAME, DISPLAY_NAME);
this.putValue("tooltip", TOOLTIP);
}
/**
* Invoked when an action occurs.
*
*@param e ActionEvent
*/
public void actionPerformed(ActionEvent e) {
//YOUR CODE GOES HERE - like:
//dialog = new MyDialog(parent);
//dialog .setVisible(true);
//...etc
}