public abstract class AbstractMenuAction
extends java.lang.Object
implements java.io.Serializable
Provider
,
Serialized FormModifier and Type | Field and Description |
---|---|
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 radio button menu item 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 menu 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 menu container for relative 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 localized
String name
for the action, used for a menu or button. |
static java.lang.String |
NOT_VOICE_COMMAND
Indicates that this menu action cannot be commanded by voice because it depends on context that can't be provided by speech.
|
static java.lang.String |
PERMITTED
Indicates whether this AbstractMenuAction should be included in menus.
|
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 menu containers
of a menu item.
|
protected java.util.HashMap<java.lang.String,java.lang.Object> |
properties
Stores any properties of the menu action that are not specially handled
(such as
enabled ). |
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 localized
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 . |
static java.lang.String |
UI_TYPE
Indicates that this menu action should only be available for UI views of the specified content type.
|
static java.lang.String |
WARNING_IF_REMOVED
Resource tag of warning that should be displayed in whatever UI tries to globally
disable an AbstractMenuAction with this property.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractMenuAction(java.lang.String name)
Defines an
AbstractMenuAction object with the specified
description string and a default icon. |
protected |
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 menus.
|
protected |
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 menus.
|
protected |
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 menus.
|
protected |
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 menus.
|
protected |
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 menus.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static final java.lang.String PRE_LOCALIZE_MENU_TAG_NAME
public static final java.lang.String PRE_LOCALIZED_MENU_HIERARCHY
public static final java.lang.String LOCALIZED_MENU_HIERARCHY
public static final java.lang.String MENU_PRIORITY
Provider.getMenuItems()
method.public static final java.lang.String BUTTON_GROUP_NAME
public static final java.lang.String NOT_VOICE_COMMAND
public static final java.lang.String UI_TYPE
public static final java.lang.String PERMITTED
public static final java.lang.String WARNING_IF_REMOVED
PERMITTED
,
Constant Field Valuespublic static final java.lang.String NAME
String
name
for the action, used for a menu or button.public static final java.lang.String SHORT_DESCRIPTION
String
description for the action, used for tooltip text. This class will
automatically fill this in if a ResourceBundle entry with the key name of
PRE_LOCALIZE_MENU_TAG_NAME
appended with ".tooltip" exists.public static final java.lang.String LONG_DESCRIPTION
String
description for the action, could be used for context-sensitive help.public static final java.lang.String SMALL_ICON
Icon
, such
as ImageIcon
.public static final java.lang.String ACTION_COMMAND_KEY
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
.public static final java.lang.String ACCELERATOR_KEY
KeyStroke
to be used as the
accelerator for the action.public static final java.lang.String MNEMONIC_KEY
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'.public static final java.lang.String SELECTED_KEY
Boolean
that corresponds
to the selected state. This is typically used only for components
that have a meaningful selection state. For example,
radio button
and check box
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 check box
the selected state of the check box
will be set from
that of the Action
. If the user clicks on the
check box
the selected state of the check box
and the Action
will both be updated.
Note: the value of this field is prefixed with 'Swing' to
avoid possible collisions with existing Actions
.
public static final java.lang.String DISPLAYED_MNEMONIC_INDEX_KEY
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
.
public static final java.lang.String LARGE_ICON_KEY
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
.
protected boolean enabled
protected final java.util.HashMap<java.lang.String,java.lang.Object> properties
enabled
).protected AbstractMenuAction(java.lang.String name)
AbstractMenuAction
object with the specified
description string and a default icon.name
- already localized String name of action (to appear on menu element)protected AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames)
nameTag
- lookup String for the name of this action in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the parent menu name stringsprotected AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent menus to contain the generated menuItempriority
- int relative priority of this menu item relative to otherprotected AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority, boolean initialState)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent menus to contain the generated menuItempriority
- int relative priority of this menu item relative to otherinitialState
- initial state of check box menu item to be createdprotected AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, java.lang.String buttonGroupName)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent menus to contain the generated radio button menu itembuttonGroupName
- String name of ButtonGroup this radio button menu itemprotected AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority, java.lang.String buttonGroupName)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent menus to contain the generated radio button menu itempriority
- int relative priority of this menu item relative to other
menu items on its lowest menubuttonGroupName
- String name of ButtonGroup for this radio button menu itempublic boolean init(java.lang.Object item, java.lang.Object view)
item
- GUI-specific menu item that is associated with the AbstractMenuAction subclassview
- GUI window containing this menu.MainGui.buildMenus(java.util.ArrayList<org.ka2ddo.yaac.pluginapi.AbstractMenuAction>, javax.swing.JMenuBar, java.awt.Window)
public abstract void actionPerformed(java.lang.Object e)
e
- UI-specific Object describing the actionpublic java.lang.Object getValue(java.lang.String key)
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).key
- a string containing the specified key
Object
stored with this key; if there
are no keys, it will return null
public void putValue(java.lang.String key, java.lang.Object newValue)
PropertyChangeEvent
is sent
to listeners.key
- a String
containing the keynewValue
- an Object
valuepublic boolean isEnabled()
Action
. When enabled,
any component associated with this object is active and
able to fire this object's actionPerformed
method.Action
is enabledpublic void setEnabled(boolean newValue)
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.newValue
- true to enable this Action
, false to disable itpublic void setPropertyListener(AbstractMenuActionPropertyListener propertyListener)
propertyListener
- AbstractMenuActionPropertyListenerpublic AbstractMenuActionPropertyListener getPropertyListener()
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
PropertyChangeEvent
to any registered
PropertyChangeListeners
.propertyName
- String name of property that was changedoldValue
- former value of propertynewValue
- current value of propertypublic static int[] parseMnemonics(java.lang.String mnemonics)
mnemonics
- String of mnemonic letters