Interface Action
- All Known Subinterfaces:
DynamicAction
- All Known Implementing Classes:
BasicAction
,DynamicRegisteredAction
,RegisteredAction
,StopAreaSelectionAction
public interface Action
The Action provides the content of all kind of buttons or menu items.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the accelerator key stroke (e.g.Returns a second, alternative accelerator key stroke for this action.boolean
If this action is contained in anContextMenu
, this value indicates whether the context menu should be closed after executing the command contained in this action.Returns theCommand
for this action.The context this action is bound to.Returns the description of the action which should be displayed when hovering over the GUI component containing this action.getIcon()
Returns theStateIcon
for this action.getLabel()
Returns the label of the action which should be displayed in the toolbar or context menu.void
setAlternativeAcceleratorKey
(KeyStroke alternativeAcceleratorKey) Sets the givenKeyStroke
to this action as an alternative KeyStroke.void
setCommand
(Command command) Should be only used for sub-menu actions.
-
Method Details
-
getLabel
String getLabel()Returns the label of the action which should be displayed in the toolbar or context menu.- Returns:
- the label
-
getDescription
String getDescription()Returns the description of the action which should be displayed when hovering over the GUI component containing this action.- Returns:
- the description
-
getIcon
StateIcon getIcon()Returns theStateIcon
for this action.- Returns:
- the icon
-
getCommand
Command getCommand()Returns theCommand
for this action.- Returns:
- the command
-
getAcceleratorKey
KeyStroke getAcceleratorKey()Returns the accelerator key stroke (e.g. CTRL + S) for this action.- Returns:
- the accelerator key; null if undefined
-
getAlternativeAcceleratorKey
KeyStroke getAlternativeAcceleratorKey()Returns a second, alternative accelerator key stroke for this action.- Returns:
- the accelerator key; null if undefined
-
setAlternativeAcceleratorKey
Sets the givenKeyStroke
to this action as an alternative KeyStroke. Resetting the KeyStroke is not supported.- Parameters:
alternativeAcceleratorKey
- the alternative KeyStroke- Throws:
UnsupportedOperationException
- if this action already has an alternativeKeyStroke
or the action doesn't support KeyStrokes.RegistrationException
- when the given KeyStroke is already bound to an action that was previously registered with the ActionManager
-
getCloseOnExecution
boolean getCloseOnExecution()If this action is contained in anContextMenu
, this value indicates whether the context menu should be closed after executing the command contained in this action.- Returns:
- whether the context menu should be closed or not
-
getContext
Collection<Object> getContext()The context this action is bound to.- Returns:
- the context objects used to execute the command
-
setCommand
Should be only used for sub-menu actions. TheCommand
is set by the button.- Parameters:
command
- the open sub-menu command
-