Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ka2ddo.yaac.pluginapi
Class AbstractMenuAction

    java.lang.Object
      org.ka2ddo.yaac.pluginapi.AbstractMenuAction

Direct Known Subclasses:
  AbstractPopupMenuAction

    public abstract class AbstractMenuAction

extends java.lang.Object

This abstract class functions more or less the same as the javax.swing.AbstractAction class, but is not subclassed from that class, so that it can be used in non-Swing environments (such as Android).

See Also:
  `Provider`

Field Summary
`static java.lang.String` | `ACCELERATOR_KEY` The key used for storing a `KeyStroke` to be used as the accelerator for the action.
`static java.lang.String` | `ACTION_COMMAND_KEY` The key used to determine the command `String` for the `ActionEvent` that will be created when an `Action` is going to be notified as the result of residing in a `Keymap` associated with a `JComponent`.
`static java.lang.String` | `BUTTON_GROUP_NAME` Identifies the ButtonGroup a JRadioButtonMenuItem is associated with.
`static java.lang.String` | `DISPLAYED_MNEMONIC_INDEX_KEY` The key used for storing an `Integer` that corresponds to the index in the text (identified by the `NAME` property) that the decoration for a mnemonic should be rendered at.
`protected boolean` | `enabled` Specifies whether action is enabled; the default is true.
`static java.lang.String` | `LARGE_ICON_KEY` The key used for storing an `Icon`.
`static java.lang.String` | `LOCALIZED_MENU_HIERARCHY` Identifies the hierarchy path for the JMenu containers of a menu item.
`static java.lang.String` | `LONG_DESCRIPTION` The key used for storing a longer `String` description for the action, could be used for context-sensitive help.
`static java.lang.String` | `MENU_PRIORITY` Identifies the sort priority on the lowest JMenu container for positioning a menu item.
`static java.lang.String` | `MNEMONIC_KEY` The key used for storing an `Integer` that corresponds to one of the `KeyEvent` key codes.
`static java.lang.String` | `NAME` The key used for storing the `String` name for the action, used for a menu or button.
`static java.lang.String` | `PRE_LOCALIZE_MENU_TAG_NAME` Identifies a specific menu item in the accumulated hierarchy.
`static java.lang.String` | `PRE_LOCALIZED_MENU_HIERARCHY` Identifies the ResourceBundle tags for the hierarchy path for the JMenu containers of a menu item.
`protected java.util.HashMap<java.lang.String,java.lang.Object>` | `properties`
`static java.lang.String` | `SELECTED_KEY` The key used for storing a `Boolean` that corresponds to the selected state.
`static java.lang.String` | `SHORT_DESCRIPTION` The key used for storing a short `String` description for the action, used for tooltip text.
`static java.lang.String` | `SMALL_ICON` The key used for storing a small `Icon`, such as `ImageIcon`.

Constructor Summary
`AbstractMenuAction(java.lang.String name)` Defines an `AbstractMenuAction` object with the specified description string and a default icon.
`AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames)` Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.
`AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority)` Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.
`AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority, boolean initialState)` Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.
`AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority, java.lang.String buttonGroupName)` Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.
`AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, java.lang.String buttonGroupName)` Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.

Method Summary
`abstract void` | `actionPerformed(java.lang.Object e)` Invoked when an action occurs.
`protected void` | `firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)` Supports reporting bound property changes.
`AbstractMenuActionPropertyListener` | `getPropertyListener()` Get the currently associated GUI-specific PropertyListener.
`java.lang.Object` | `getValue(java.lang.String key)` Gets the `Object` associated with the specified key.
`boolean` | `init(java.lang.Object item, java.lang.Object view)` Additional processing to be done when the action is attached to the menu structure.
`boolean` | `isEnabled()` Returns the enabled state of the `Action`.
`static int[]` | `parseMnemonics(java.lang.String mnemonics)` Convert a localized string of mnemonic letters into an array of ints, suitable for use by the above constructors.
`void` | `putValue(java.lang.String key, java.lang.Object newValue)` Sets one of this object's properties using the associated key.
`void` | `setEnabled(boolean newValue)` Sets the enabled state of the `Action`.
`void` | `setPropertyListener(AbstractMenuActionPropertyListener propertyListener)` Specify who should be informed of changes to properties.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PRE_LOCALIZE_MENU_TAG_NAME

    public static final java.lang.String PRE_LOCALIZE_MENU_TAG_NAME

  Identifies a specific menu item in the accumulated hierarchy. Must be a String.

  See Also:
    Constant Field Values

### PRE_LOCALIZED_MENU_HIERARCHY

    public static final java.lang.String PRE_LOCALIZED_MENU_HIERARCHY

  Identifies the ResourceBundle tags for the hierarchy path for the JMenu containers of a menu item. Must be an array of String.

  See Also:
    Constant Field Values

### LOCALIZED_MENU_HIERARCHY

    public static final java.lang.String LOCALIZED_MENU_HIERARCHY

  Identifies the hierarchy path for the JMenu containers of a menu item. Must be an array of String.

  See Also:
    Constant Field Values

### MENU_PRIORITY

    public static final java.lang.String MENU_PRIORITY

  Identifies the sort priority on the lowest JMenu container for positioning a menu item. Must be a Number, and will be treated like an int. If not specified, assumes a priority of 2.

  See Also:
    Constant Field Values

### BUTTON_GROUP_NAME

    public static final java.lang.String BUTTON_GROUP_NAME

  Identifies the ButtonGroup a JRadioButtonMenuItem is associated with. Must be a String.

  See Also:
    Constant Field Values

### NAME

    public static final java.lang.String NAME

  The key used for storing the `String` name for the action, used for a menu or button.

  See Also:
    Constant Field Values

### SHORT_DESCRIPTION

    public static final java.lang.String SHORT_DESCRIPTION

  The key used for storing a short `String` description for the action, used for tooltip text.

  See Also:
    Constant Field Values

### LONG_DESCRIPTION

    public static final java.lang.String LONG_DESCRIPTION

  The key used for storing a longer `String` description for the action, could be used for context-sensitive help.

  See Also:
    Constant Field Values

### SMALL_ICON

    public static final java.lang.String SMALL_ICON

  The key used for storing a small `Icon`, such as `ImageIcon`. This is typically used with menus such as `JMenuItem`.

  If the same `Action` is used with menus and buttons you'll typically specify both a `SMALL_ICON` and a `LARGE_ICON_KEY`. The menu will use the `SMALL_ICON` and the button will use the `LARGE_ICON_KEY`.

  See Also:
    Constant Field Values

### ACTION_COMMAND_KEY

    public static final java.lang.String ACTION_COMMAND_KEY

  The key used to determine the command `String` for the `ActionEvent` that will be created when an `Action` is going to be notified as the result of residing in a `Keymap` associated with a `JComponent`.

  See Also:
    Constant Field Values

### ACCELERATOR_KEY

    public static final java.lang.String ACCELERATOR_KEY

  The key used for storing a `KeyStroke` to be used as the accelerator for the action.

  See Also:
    Constant Field Values

### MNEMONIC_KEY

    public static final java.lang.String MNEMONIC_KEY

  The key used for storing an `Integer` that corresponds to one of the `KeyEvent` key codes. The value is commonly used to specify a mnemonic. For example: `myAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A)` sets the mnemonic of `myAction` to 'a'.

  See Also:
    Constant Field Values

### SELECTED_KEY

    public static final java.lang.String SELECTED_KEY

  The key used for storing a `Boolean` that corresponds to the selected state. This is typically used only for components that have a meaningful selection state. For example, `JRadioButton` and `JCheckBox` make use of this but instances of `JMenu` don't.

  This property differs from the others in that it is both read by the component and set by the component. For example, if an `Action` is attached to a `JCheckBox` the selected state of the `JCheckBox` will be set from that of the `Action`. If the user clicks on the `JCheckBox` the selected state of the `JCheckBox` and the `Action` will both be updated.

  Note: the value of this field is prefixed with 'Swing' to avoid possible collisions with existing `Actions`.

  Since:
    1.6
  See Also:
    Constant Field Values

### DISPLAYED_MNEMONIC_INDEX_KEY

    public static final java.lang.String DISPLAYED_MNEMONIC_INDEX_KEY

  The key used for storing an `Integer` that corresponds to the index in the text (identified by the `NAME` property) that the decoration for a mnemonic should be rendered at. If the value of this property is greater than or equal to the length of the text, it will treated as -1.

  Note: the value of this field is prefixed with 'Swing' to avoid possible collisions with existing `Actions`.

  See Also:
    Constant Field Values

### LARGE_ICON_KEY

    public static final java.lang.String LARGE_ICON_KEY

  The key used for storing an `Icon`. This is typically used by buttons, such as `JButton` and `JToggleButton`.

  If the same `Action` is used with menus and buttons you'll typically specify both a `SMALL_ICON` and a `LARGE_ICON_KEY`. The menu will use the `SMALL_ICON` and the button the `LARGE_ICON_KEY`.

  Note: the value of this field is prefixed with 'Swing' to avoid possible collisions with existing `Actions`.

  See Also:
    Constant Field Values

### enabled

    protected boolean enabled

  Specifies whether action is enabled; the default is true.

### properties

    protected java.util.HashMap<java.lang.String,java.lang.Object> properties

Constructor Detail

### AbstractMenuAction

    public AbstractMenuAction(java.lang.String name)

  Defines an `AbstractMenuAction` object with the specified description string and a default icon.

  Parameters:
    `name` - already localized String name of action (to appear on menu element)

### AbstractMenuAction

    public AbstractMenuAction(java.lang.String nameTag,
                              java.lang.String[] menuPositionNames)

  Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.

  Parameters:
    `nameTag` - lookup String for the name of this action in ResourceBundles
    `menuPositionNames` - array of Strings identifying the ResourceBundle tags for the parent menu name strings

### AbstractMenuAction

    public AbstractMenuAction(java.lang.String nameTag,
                              java.lang.String[] menuPositionNames,
                              int priority)

  Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.

  Parameters:
    `nameTag` - lookup String for the above name in ResourceBundles
    `menuPositionNames` - array of Strings identifying the ResourceBundle tags for the menu name strings of the parent JMenus to contain the generated JMenuItem
    `priority` - int relative priority of this menu item relative to other

### AbstractMenuAction

    public AbstractMenuAction(java.lang.String nameTag,
                              java.lang.String[] menuPositionNames,
                              int priority,
                              boolean initialState)

  Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.

  Parameters:
    `nameTag` - lookup String for the above name in ResourceBundles
    `menuPositionNames` - array of Strings identifying the ResourceBundle tags for the menu name strings of the parent JMenus to contain the generated JMenuItem
    `priority` - int relative priority of this menu item relative to other
    `initialState` - initial state of JCheckBoxMenuItem to be created

### AbstractMenuAction

    public AbstractMenuAction(java.lang.String nameTag,
                              java.lang.String[] menuPositionNames,
                              java.lang.String buttonGroupName)

  Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.

  Parameters:
    `nameTag` - lookup String for the above name in ResourceBundles
    `menuPositionNames` - array of Strings identifying the ResourceBundle tags for the menu name strings of the parent JMenus to contain the generated JRadioButtonMenuItem
    `buttonGroupName` - String name of ButtonGroup this JRadioButtonMenuItem

### AbstractMenuAction

    public AbstractMenuAction(java.lang.String nameTag,
                              java.lang.String[] menuPositionNames,
                              int priority,
                              java.lang.String buttonGroupName)

  Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus.

  Parameters:
    `nameTag` - lookup String for the above name in ResourceBundles
    `menuPositionNames` - array of Strings identifying the ResourceBundle tags for the menu name strings of the parent JMenus to contain the generated JRadioButtonMenuItem
    `priority` - int relative priority of this menu item relative to other menu items on its lowest JMenu
    `buttonGroupName` - String name of ButtonGroup this JRadioButtonMenuItem

Method Detail

### init

    public boolean init(java.lang.Object item,
                        java.lang.Object view)

  Additional processing to be done when the action is attached to the menu structure. Intended to be overridden by subclasses that need to initialize state that is not available when the Providers are loaded, but only after the MainFrame is created and the collected menu hierarchy is actually being created.

  Parameters:
    `item` - GUI-specific menu item that is associated with the AbstractMenuAction subclass
    `view` - GUI window containing this menu.
  Returns:
    boolean true if menu item should be included in menus, false if it should be skipped
  See Also:
    `MainFrame.buildMenus(java.util.ArrayList, javax.swing.JMenuBar, java.awt.Window)`

### actionPerformed

    public abstract void actionPerformed(java.lang.Object e)

  Invoked when an action occurs.

  Parameters:
    `e` - UI-specific Object describing the action

### getValue

    public java.lang.Object getValue(java.lang.String key)

  Gets the `Object` associated with the specified key. This arranges for value substitution from ResourceBundles at menu creation time (after all the alternate ResourceBundle variants have been placed upon the classpath).

  Parameters:
    `key` - a string containing the specified `key`
  Returns:
    the binding `Object` stored with this key; if there are no keys, it will return `null`

### putValue

    public void putValue(java.lang.String key,
                         java.lang.Object newValue)

  Sets one of this object's properties using the associated key. If the value has changed, a `PropertyChangeEvent` is sent to listeners.

  Parameters:
    `key` - a `String` containing the key
    `newValue` - an `Object` value

### isEnabled

    public boolean isEnabled()

  Returns the enabled state of the `Action`. When enabled, any component associated with this object is active and able to fire this object's `actionPerformed` method.

  Returns:
    true if this `Action` is enabled

### setEnabled

    public void setEnabled(boolean newValue)

  Sets the enabled state of the `Action`. When enabled, any component associated with this object is active and able to fire this object's `actionPerformed` method. If the value has changed, a `PropertyChangeEvent` is sent to listeners.

  Parameters:
    `newValue` - true to enable this `Action`, false to disable it

### setPropertyListener

    public void setPropertyListener(AbstractMenuActionPropertyListener propertyListener)

  Specify who should be informed of changes to properties.

  Parameters:
    `propertyListener` - AbstractMenuActionPropertyListener

### getPropertyListener

    public AbstractMenuActionPropertyListener getPropertyListener()

  Get the currently associated GUI-specific PropertyListener.

  Returns:
    AbstractMenuActionPropertyListener associated with this AbstractMenuAction, or null if none associated

### firePropertyChange

    protected void firePropertyChange(java.lang.String propertyName,
                                      java.lang.Object oldValue,
                                      java.lang.Object newValue)

  Supports reporting bound property changes. This method can be called when a bound property has changed and it will send the appropriate `PropertyChangeEvent` to any registered `PropertyChangeListeners`.

  Parameters:
    `propertyName` - String name of property that was changed
    `oldValue` - former value of property
    `newValue` - current value of property

### parseMnemonics

    public static int[] parseMnemonics(java.lang.String mnemonics)

  Convert a localized string of mnemonic letters into an array of ints, suitable for use by the above constructors.

  Parameters:
    `mnemonics` - String of mnemonic letters
  Returns:
    int array of mnemonic letter codes, or null if no string was provided

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD