@OpenApiAll
public abstract class NMAction
extends javax.swing.AbstractAction
implements java.lang.Comparable
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACTION_SHORTCUTS
Key for storing command keys.
|
static java.lang.String |
BELONGS_TO_SEPARATE_GROUP_IN_UI
A name of property to put this action into a dedicate special group.
|
static java.lang.String |
DO_NO_SHOW_ACTION_NAME_IN_UI
A name of property to hide action name text in create UI.
|
static java.lang.String |
GENERATED_ID_PREFIX |
static java.lang.String |
GROUP
Key for storing group.
|
static java.lang.String |
ID
Key for storing id.
|
static java.lang.String |
LARGE_ICON
Key for storing large icon.
|
static int |
MENU_SHORTCUT_MASK
Menu shortcut mask used to create shortcuts.
|
| Constructor and Description |
|---|
NMAction(java.lang.String id,
java.lang.String name,
int mnemonic)
Constructs the action with given id, name, mnemonic key.
|
NMAction(java.lang.String id,
java.lang.String name,
int mnemonic,
java.lang.String group)
Constructs the action with given id, name, mnemonic key and group.
|
NMAction(java.lang.String id,
java.lang.String name,
javax.swing.KeyStroke stroke)
Constructs the action with given id, name, keystroke.
|
NMAction(java.lang.String id,
java.lang.String name,
javax.swing.KeyStroke stroke,
java.lang.String group)
Constructs the action with given id, name, keystroke and group.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(ActionsVisitor visitor)
Accepts ActionsVisitor using Visitor pattern.
|
abstract void |
actionPerformed(java.awt.event.ActionEvent e)
Executes given action.
|
void |
addAction(NMAction action)
Adds action.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a
PropertyChangeListener to the listener list. |
void |
addShotcut(javax.swing.KeyStroke key)
Adds the shortcut to the action.
|
void |
addWeakPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a
PropertyChangeListener to the weak listener list. |
java.lang.Object |
clone()
Clones the object.
|
int |
compareTo(java.lang.Object o)
Compares the name of the action.
|
javax.swing.JMenuItem |
createMenuItem(com.nomagic.actions.MenuComponentFactory factory)
Action can return preferred representation of itself as menu item.
|
boolean |
equals(java.lang.Object o)
Checks if given object is equal to the current action.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Supports reporting bound property changes.
|
java.util.List<NMAction> |
getActions()
Returns the list of the actions.
|
javax.swing.KeyStroke |
getCommandKey()
Returns the shortcut of the action.
|
java.lang.String |
getDescription()
Returns description of this action.
|
java.lang.String |
getGroup()
Returns the name of the related actions group.
|
javax.swing.Icon |
getIcon() |
java.lang.String |
getID()
Returns the id of the action.
|
javax.swing.Icon |
getLargeIcon()
Returns the large icon of the action.
|
int |
getMnemonicKey()
Returns the mnemonic of the action.
|
java.lang.String |
getName()
Returns the name of the action.
|
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all the
PropertyChangeListeners added
to this action with addPropertyChangeListener(). |
java.util.List<javax.swing.KeyStroke> |
getShortcuts()
Returns all shortcuts of the the action.
|
javax.swing.Icon |
getSmallIcon()
Returns the small icon of the action.
|
int |
hashCode()
Creates hashcode from id.
|
boolean |
isIDGenerated()
Returns true if id was generated.
|
void |
removeAction(NMAction action)
Remove action.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a
PropertyChangeListener from the listener list. |
void |
removeShortcut(javax.swing.KeyStroke key)
Removes the shortcut from the action.
|
void |
removeWeakPropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a
PropertyChangeListener from the weak listener list. |
void |
setActions(java.util.List<? extends NMAction> actions)
Sets the list of the actions(do nothing here).
|
void |
setDescription(java.lang.String descrp)
Sets new action description.
|
protected void |
setGroup(java.lang.String group)
Sets new group for this action.
|
void |
setLargeIcon(javax.swing.Icon icon)
Sets the large icon of the action.
|
void |
setMnemonicKey(int key)
Sets the mnemonic key of the action.
|
void |
setName(java.lang.String name)
Sets new name of action, method implemented by putting value with key Action.NAME
|
void |
setShortcuts(java.util.List<javax.swing.KeyStroke> shortcuts)
Sets the shortcuts list.
|
void |
setSmallIcon(javax.swing.Icon icon)
Sets the small icon of the action.
|
java.lang.Object |
shallowClone()
Returns itself
|
java.lang.String |
toString()
toString returns the action's name.
|
void |
updateState()
Method should update action state (enabled or disabled, checked or unchecked).
|
public static final java.lang.String DO_NO_SHOW_ACTION_NAME_IN_UI
public static final java.lang.String BELONGS_TO_SEPARATE_GROUP_IN_UI
public static final java.lang.String ACTION_SHORTCUTS
public static final java.lang.String ID
public static final java.lang.String LARGE_ICON
public static final java.lang.String GROUP
public static final int MENU_SHORTCUT_MASK
public static final java.lang.String GENERATED_ID_PREFIX
public NMAction(@CheckForNull
java.lang.String id,
@CheckForNull
java.lang.String name,
@CheckForNull
javax.swing.KeyStroke stroke,
@CheckForNull
java.lang.String group)
id - the id of the action.name - the name of the action.stroke - the KeyStroke of the action.group - the name of the related commands group.public NMAction(@CheckForNull
java.lang.String id,
@CheckForNull
java.lang.String name,
@CheckForNull
javax.swing.KeyStroke stroke)
id - the id of the action.name - the name of the action.stroke - the KeyStroke of the action.public NMAction(@CheckForNull
java.lang.String id,
@CheckForNull
java.lang.String name,
int mnemonic,
@CheckForNull
java.lang.String group)
id - the id of the action.name - the name of the action.mnemonic - the mnemonic key of the actiongroup - the name of the related commands group.public NMAction(@CheckForNull
java.lang.String id,
@CheckForNull
java.lang.String name,
int mnemonic)
id - the id of the action.name - the name of the action.mnemonic - the mnemonic key of the actionpublic void setName(java.lang.String name)
name - namepublic java.lang.String getID()
@CheckForNull public javax.swing.KeyStroke getCommandKey()
public void addShotcut(@CheckForNull
javax.swing.KeyStroke key)
key - the given shortcut.public void removeShortcut(javax.swing.KeyStroke key)
key - the given shortcut.public void setShortcuts(@CheckForNull
java.util.List<javax.swing.KeyStroke> shortcuts)
shortcuts - the list of all shortcuts.public java.util.List<javax.swing.KeyStroke> getShortcuts()
public java.lang.String getName()
public void setMnemonicKey(int key)
key - the mnemonic key of the action.public int getMnemonicKey()
public void setSmallIcon(@CheckForNull
javax.swing.Icon icon)
icon - the small icon of the action.public javax.swing.Icon getSmallIcon()
public javax.swing.Icon getIcon()
public void setLargeIcon(@CheckForNull
javax.swing.Icon icon)
icon - the large icon of the action.public javax.swing.Icon getLargeIcon()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic abstract void actionPerformed(@CheckForNull
java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenere - event caused execution.public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - the given object to compare to.public java.lang.Object clone()
clone in class javax.swing.AbstractActionpublic java.lang.Object shallowClone()
public void accept(ActionsVisitor visitor)
visitor - visitor to accept.public void setDescription(java.lang.String descrp)
descrp - action description.public java.lang.String getDescription()
protected void setGroup(@CheckForNull
java.lang.String group)
group - group name.public java.lang.String getGroup()
public java.util.List<NMAction> getActions()
public void setActions(java.util.List<? extends NMAction> actions)
actions - the list of the actions.public void addAction(NMAction action)
action - the action to add.public void removeAction(NMAction action)
action - the action to remove.public void updateState()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener to the listener list.
The listener is registered for all properties.
A PropertyChangeEvent will get fired in response to setting
a bound property, e.g. setFont, setBackground,
or setForeground.
Note that if the current component is inheriting its foreground,
background, or font from its container, then no event will be
fired in response to a change in the inherited property.
This method creates advanced SwingPropertyChangeSupport which is safe to use when
removing/adding listeners during firing property change event.
addPropertyChangeListener in interface javax.swing.ActionaddPropertyChangeListener in class javax.swing.AbstractActionlistener - The PropertyChangeListener to be addedAction.addPropertyChangeListener(java.beans.PropertyChangeListener)public void addWeakPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener to the weak listener list.
The listener is registered for all properties.
A PropertyChangeEvent will get fired in response to setting
a bound property, e.g. setFont, setBackground,
or setForeground.
Note that if the current component is inheriting its foreground,
background, or font from its container, then no event will be
fired in response to a change in the inherited property.
This method creates advanced SwingPropertyChangeSupport which is safe to use when
removing/adding listeners during firing property change event.
listener - The PropertyChangeListener to be addedAction.addPropertyChangeListener(java.beans.PropertyChangeListener)protected void firePropertyChange(java.lang.String propertyName,
@CheckForNull
java.lang.Object oldValue,
java.lang.Object newValue)
PropertyChangeEvent to any registered
PropertyChangeListeners.firePropertyChange in class javax.swing.AbstractActionpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener from the listener list.
This removes a PropertyChangeListener that was registered
for all properties.removePropertyChangeListener in interface javax.swing.ActionremovePropertyChangeListener in class javax.swing.AbstractActionlistener - the PropertyChangeListener to be removedAction.removePropertyChangeListener(java.beans.PropertyChangeListener)public void removeWeakPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener from the weak listener list.
This removes a PropertyChangeListener that was registered
for all properties.listener - the PropertyChangeListener to be removedAction.removePropertyChangeListener(java.beans.PropertyChangeListener)public javax.swing.JMenuItem createMenuItem(com.nomagic.actions.MenuComponentFactory factory)
factory - public boolean isIDGenerated()
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListeners added
to this action with addPropertyChangeListener().getPropertyChangeListeners in class javax.swing.AbstractActionPropertyChangeListeners added or an empty
array if no listeners have been added