Package com.nomagic.actions
Class NMStateAction
java.lang.Object
javax.swing.AbstractAction
com.nomagic.actions.NMAction
com.nomagic.actions.BaseNMStateAction
com.nomagic.actions.NMStateAction
- All Implemented Interfaces:
ActionListener
,Serializable
,Cloneable
,Comparable
,EventListener
,Action
- Direct Known Subclasses:
MDStateAction
,SelectionItem
,SelectionStateItem
The class describes the action with some boolean state.
The action has additional properties: state, grouped.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Property which means that state is not strict.static final String
The state property.Fields inherited from class com.nomagic.actions.BaseNMStateAction
GROUPED
Fields inherited from class com.nomagic.actions.NMAction
ACTION_SHORTCUTS, BELONGS_TO_SEPARATE_GROUP_IN_UI, DO_NO_SHOW_ACTION_NAME_IN_UI, DO_NOT_REGISTER_ACTION_TO_COMPONENTS, GENERATED_ID_PREFIX, GROUP, ID, LARGE_ICON, MENU_SHORTCUT_MASK, TINY_ICON
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
Constructor Summary
ConstructorDescriptionNMStateAction
(String id, String name, int mnemonic) Constructs the action with given id, name, mnemonic key.NMStateAction
(String id, String name, int mnemonic, String group) Constructs the action with given id, name, mnemonic key.NMStateAction
(String id, String name, KeyStroke stroke) Creates action with given id, name, key stroke.NMStateAction
(String id, String name, KeyStroke stroke, String group) Creates action with given id, name, key stroke. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ActionsVisitor visitor) Accepts ActionsVisitor using Visitor design pattern.void
Executes given action.boolean
getState()
Returns boolean state of this action.boolean
Return distinguish property.static boolean
isStateEvent
(PropertyChangeEvent event) void
setDistinguish
(boolean dist) Sets new distinguish property.void
setState
(boolean state) Sets action boolean state.Methods inherited from class com.nomagic.actions.BaseNMStateAction
isGrouped, setGrouped
Methods inherited from class com.nomagic.actions.NMAction
addAction, addPropertyChangeListener, addShortcut, addShotcut, addWeakPropertyChangeListener, clone, compareTo, createMenuItem, equals, firePropertyChange, forEach, forEachIncludingSelf, getActions, getCommandKey, getDescription, getGroup, getIcon, getID, getLargeIcon, getLargeOrSmallIcon, getMenuShortcutMaskAsString, getMnemonicKey, getName, getPropertyChangeListeners, getShortcuts, getSmallIcon, getSmallOrLargeIcon, getTinyIcon, hashCode, hasMenuShortcutMask, isIDGenerated, removeAction, removeIf, removePropertyChangeListener, removeShortcut, removeWeakPropertyChangeListener, setActions, setDescription, setGroup, setIcon, setLargeIcon, setMnemonicKey, setName, setShortcuts, setSmallIcon, setTinyIcon, shallowClone, toString, updateState
Methods inherited from class javax.swing.AbstractAction
getKeys, getValue, isEnabled, putValue, setEnabled
-
Field Details
-
STATE
The state property. Value of this property is Boolean.- See Also:
-
DISTINGUISH
Property which means that state is not strict.- See Also:
-
-
Constructor Details
-
NMStateAction
public NMStateAction(@CheckForNull String id, @CheckForNull String name, @CheckForNull KeyStroke stroke, @CheckForNull String group) Creates action with given id, name, key stroke.- Parameters:
id
- the id of the action.name
- the name of the action.stroke
- the key stroke of the actiongroup
- the name of the related commands group.
-
NMStateAction
public NMStateAction(@CheckForNull String id, @CheckForNull String name, int mnemonic, @CheckForNull String group) Constructs the action with given id, name, mnemonic key.- Parameters:
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.
-
NMStateAction
public NMStateAction(@CheckForNull String id, @CheckForNull String name, @CheckForNull KeyStroke stroke) Creates action with given id, name, key stroke.- Parameters:
id
- the id of the action.name
- the name of the action.stroke
- the key stroke of the action
-
NMStateAction
Constructs the action with given id, name, mnemonic key.- Parameters:
id
- the id of the action.name
- the name of the action.mnemonic
- the mnemonic key of the action
-
-
Method Details
-
setState
public void setState(boolean state) Sets action boolean state.- Parameters:
state
- new state of action.
-
getState
public boolean getState()Returns boolean state of this action.- Returns:
- boolean state of this action.
-
accept
Accepts ActionsVisitor using Visitor design pattern. -
actionPerformed
Executes given action.- Specified by:
actionPerformed
in interfaceActionListener
- Specified by:
actionPerformed
in classNMAction
- Parameters:
e
- event caused execution.
-
isDistinguish
public boolean isDistinguish()Return distinguish property.- Returns:
- true if this action state is not strict.
-
setDistinguish
public void setDistinguish(boolean dist) Sets new distinguish property.- Parameters:
dist
- new value which specifies if state is strict or not.
-
isStateEvent
- Parameters:
event
- instance ofPropertyChangeEvent
- Returns:
true
when passed event property name equals toSTATE
, otherwise -false
-