Class NMStateAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, java.util.EventListener, javax.swing.Action
    Direct Known Subclasses:
    MDStateAction, SelectionItem, SelectionStateItem

    @OpenApiAll
    public abstract class NMStateAction
    extends NMAction
    The class describes the action with some boolean state. The action has additional properties: state, grouped.
    See Also:
    Serialized Form
    • Field Detail

      • STATE

        public static final java.lang.String STATE
        The state property. Value of this property is Boolean.
        See Also:
        Constant Field Values
      • GROUPED

        public static final java.lang.String GROUPED
        Flag indicates that in group of NMStateActions only one action can have "state" true (its radio buttons actions).
        See Also:
        Constant Field Values
      • DISTINGUISH

        public static final java.lang.String DISTINGUISH
        Property which means that state is not strict.
        See Also:
        Constant Field Values
    • Constructor Detail

      • NMStateAction

        public NMStateAction​(@CheckForNull
                             java.lang.String id,
                             @CheckForNull
                             java.lang.String name,
                             @CheckForNull
                             javax.swing.KeyStroke stroke,
                             @CheckForNull
                             java.lang.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 action
        group - the name of the related commands group.
      • NMStateAction

        public NMStateAction​(@CheckForNull
                             java.lang.String id,
                             @CheckForNull
                             java.lang.String name,
                             int mnemonic,
                             @CheckForNull
                             java.lang.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 action
        group - the name of the related commands group.
      • NMStateAction

        public NMStateAction​(@CheckForNull
                             java.lang.String id,
                             @CheckForNull
                             java.lang.String name,
                             @CheckForNull
                             javax.swing.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

        public NMStateAction​(@CheckForNull
                             java.lang.String id,
                             @CheckForNull
                             java.lang.String name,
                             int mnemonic)
        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 Detail

      • 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.
      • isGrouped

        public boolean isGrouped()
        Return grouped property value.
        Returns:
        true if this action is grouped state action.
      • setGrouped

        public void setGrouped​(boolean grouped)
        Sets new grouped property value.
        Parameters:
        grouped - new value of grouped flag.
      • 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.
      • accept

        public void accept​(ActionsVisitor visitor)
        Accepts ActionsVisitor using Visitor design pattern.
        Overrides:
        accept in class NMAction
        Parameters:
        visitor - visitor to accept.
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Executes given action.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Specified by:
        actionPerformed in class NMAction
        Parameters:
        e - event caused execution.
      • isStateEvent

        public static boolean isStateEvent​(@CheckForNull
                                           java.beans.PropertyChangeEvent event)
        Parameters:
        event - instance of PropertyChangeEvent
        Returns:
        true when passed event property name equals to STATE, otherwise - false