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
FieldsModifier and TypeFieldDescriptionstatic final StringProperty which means that state is not strict.static final StringThe state property.Fields inherited from class com.nomagic.actions.BaseNMStateAction
GROUPEDFields 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_ICONFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields 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
ConstructorsConstructorDescriptionNMStateAction(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 TypeMethodDescriptionvoidaccept(ActionsVisitor visitor) Accepts ActionsVisitor using Visitor design pattern.voidExecutes given action.booleangetState()Returns boolean state of this action.booleanReturn distinguish property.static booleanisStateEvent(PropertyChangeEvent event) voidsetDistinguish(boolean dist) Sets new distinguish property.voidsetState(boolean state) Sets action boolean state.Methods inherited from class com.nomagic.actions.BaseNMStateAction
isGrouped, setGroupedMethods 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, updateStateMethods 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:
actionPerformedin interfaceActionListener- Specified by:
actionPerformedin 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:
truewhen passed event property name equals toSTATE, otherwise -false
-