Class RegisteredAction

    • Constructor Detail

      • RegisteredAction

        public RegisteredAction​(String label,
                                KeyStroke acceleratorKey,
                                StateIcon icon,
                                Command command,
                                Collection<Object> context)
        Creates a new RegisteredAction with the given parameters.
        Parameters:
        label - the displayed name (e.g. in a menu item or next to the icon in a button); here it is also used as hover description
        acceleratorKey - the KeyStroke for this action
        icon - the icon which should be displayed
        command - the command which should be executed
        context - the context of this action
      • RegisteredAction

        public RegisteredAction​(String label,
                                String description,
                                KeyStroke acceleratorKey,
                                KeyStroke alternativeAcceleratorKey,
                                StateIcon icon,
                                Command command,
                                Collection<Object> context,
                                boolean closeOnExecution)
        Creates a new RegisteredAction with the given parameters.
        Parameters:
        label - the displayed name (e.g. in a menu item or next to the icon in a button)
        description - the hover description
        acceleratorKey - the KeyStroke for this action
        alternativeAcceleratorKey - an alternative KeyStroke for this action (for example when defining an accelerator with + and an alternative accelerator with numpad +)
        icon - the icon which should be displayed
        command - the command which should be executed
        context - the context of this action
        closeOnExecution - whether the containing menu should be closed after executing the command
      • RegisteredAction

        @Deprecated
        public RegisteredAction​(String label,
                                String description,
                                KeyStroke acceleratorKey,
                                KeyStroke alternativeAcceleratorKey,
                                StateIcon icon,
                                Command command,
                                Collection<Object> context,
                                boolean closeOnExecution,
                                boolean doRegister)
        Deprecated.
        Creates a new RegisteredAction with the given parameters.
        Parameters:
        label - the displayed name (e.g. in a menu item or next to the icon in a button)
        description - the hover description
        acceleratorKey - the KeyStroke for this action
        alternativeAcceleratorKey - an alternative KeyStroke for this action (for example when defining an accelerator with + and an alternative accelerator with numpad +)
        icon - the icon which should be displayed
        command - the command which should be executed
        context - the context of this action
        closeOnExecution - whether the containing menu should be closed after executing the command
        doRegister - whether to call ActionManager.registerAction(RegisteredAction) for this action
    • Method Detail

      • getLabel

        public String getLabel()
        Description copied from interface: Action
        Returns the label of the action which should be displayed in the toolbar or context menu.
        Specified by:
        getLabel in interface Action
        Returns:
        the label
      • getDescription

        public String getDescription()
        Description copied from interface: Action
        Returns the description of the action which should be displayed when hovering over the GUI component containing this action.
        Specified by:
        getDescription in interface Action
        Returns:
        the description
      • getCommand

        public Command getCommand()
        Description copied from interface: Action
        Returns the Command for this action.
        Specified by:
        getCommand in interface Action
        Returns:
        the command
      • getAcceleratorKey

        public KeyStroke getAcceleratorKey()
        Description copied from interface: Action
        Returns the accelerator key stroke (e.g. CTRL + S) for this action.
        Specified by:
        getAcceleratorKey in interface Action
        Returns:
        the accelerator key; null if undefined
      • getAlternativeAcceleratorKey

        public KeyStroke getAlternativeAcceleratorKey()
        Description copied from interface: Action
        Returns a second, alternative accelerator key stroke for this action.
        Specified by:
        getAlternativeAcceleratorKey in interface Action
        Returns:
        the accelerator key; null if undefined
      • setAlternativeAcceleratorKey

        public void setAlternativeAcceleratorKey​(KeyStroke alternativeKeyStroke)
                                          throws RegistrationException
        Description copied from interface: Action
        Sets the given KeyStroke to this action as an alternative KeyStroke. Resetting the KeyStroke is not supported.
        Specified by:
        setAlternativeAcceleratorKey in interface Action
        Parameters:
        alternativeKeyStroke - the alternative KeyStroke
        Throws:
        RegistrationException - when the given KeyStroke is already bound to an action that was previously registered with the ActionManager
      • getCloseOnExecution

        public boolean getCloseOnExecution()
        Description copied from interface: Action
        If this action is contained in an ContextMenu, this value indicates whether the context menu should be closed after executing the command contained in this action.
        Specified by:
        getCloseOnExecution in interface Action
        Returns:
        whether the context menu should be closed or not
      • getContext

        public Collection<Object> getContext()
        Description copied from interface: Action
        The context this action is bound to.
        Specified by:
        getContext in interface Action
        Returns:
        the context objects used to execute the command
      • executeCommand

        public void executeCommand()
        Executes the Command of this action
      • canExecuteCommand

        public boolean canExecuteCommand()
        Checks whether the command can be executed.
        Returns:
        true if the command can be executed otherwise returns false
      • setCommand

        public void setCommand​(Command command)
        Description copied from interface: Action
        Should be only used for sub-menu actions. The Command is set by the button.
        Specified by:
        setCommand in interface Action
        Parameters:
        command - the open sub-menu command