Class RegisteredAction
java.lang.Object
com.levigo.jadice.web.client.util.action.RegisteredAction
- All Implemented Interfaces:
Action
- Direct Known Subclasses:
DynamicRegisteredAction
,StopAreaSelectionAction
A RegisteredAction provides the content and
KeyStroke
of all kind of buttons or menu
items. The registered action is automatically registered in an ActionRegistry
.-
Constructor Summary
ConstructorsConstructorDescriptionRegisteredAction
(String label, KeyStroke acceleratorKey, StateIcon icon, Command command, Collection<Object> context) Creates a newRegisteredAction
with the given parameters.RegisteredAction
(String label, String description, KeyStroke acceleratorKey, KeyStroke alternativeAcceleratorKey, StateIcon icon, Command command, Collection<Object> context, boolean closeOnExecution) Creates a newRegisteredAction
with the given parameters.RegisteredAction
(String label, String description, KeyStroke acceleratorKey, KeyStroke alternativeAcceleratorKey, StateIcon icon, Command command, Collection<Object> context, boolean closeOnExecution, boolean doRegister) Creates a newRegisteredAction
with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether the command can be executed.void
Executes the Command of this actionReturns 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 alternativeKeyStroke) Sets the givenKeyStroke
to this action as an alternative KeyStroke.void
setCommand
(Command command) Should be only used for sub-menu actions.
-
Constructor Details
-
RegisteredAction
public RegisteredAction(String label, KeyStroke acceleratorKey, StateIcon icon, Command command, Collection<Object> context) Creates a newRegisteredAction
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 descriptionacceleratorKey
- theKeyStroke
for this actionicon
- the icon which should be displayedcommand
- the command which should be executedcontext
- 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 newRegisteredAction
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 descriptionacceleratorKey
- theKeyStroke
for this actionalternativeAcceleratorKey
- an alternativeKeyStroke
for this action (for example when defining an accelerator with + and an alternative accelerator with numpad +)icon
- the icon which should be displayedcommand
- the command which should be executedcontext
- the context of this actioncloseOnExecution
- whether the containing menu should be closed after executing the command
-
RegisteredAction
public RegisteredAction(String label, String description, KeyStroke acceleratorKey, KeyStroke alternativeAcceleratorKey, StateIcon icon, Command command, Collection<Object> context, boolean closeOnExecution, boolean doRegister) Creates a newRegisteredAction
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 descriptionacceleratorKey
- theKeyStroke
for this actionalternativeAcceleratorKey
- an alternativeKeyStroke
for this action (for example when defining an accelerator with + and an alternative accelerator with numpad +)icon
- the icon which should be displayedcommand
- the command which should be executedcontext
- the context of this actioncloseOnExecution
- whether the containing menu should be closed after executing the commanddoRegister
- whether to callActionManager.registerAction(RegisteredAction)
for this action
-
-
Method Details
-
getLabel
Description copied from interface:Action
Returns the label of the action which should be displayed in the toolbar or context menu. -
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 interfaceAction
- Returns:
- the description
-
getIcon
Description copied from interface:Action
Returns theStateIcon
for this action. -
getCommand
Description copied from interface:Action
Returns theCommand
for this action.- Specified by:
getCommand
in interfaceAction
- Returns:
- the command
-
getAcceleratorKey
Description copied from interface:Action
Returns the accelerator key stroke (e.g. CTRL + S) for this action.- Specified by:
getAcceleratorKey
in interfaceAction
- Returns:
- the accelerator key; null if undefined
-
getAlternativeAcceleratorKey
Description copied from interface:Action
Returns a second, alternative accelerator key stroke for this action.- Specified by:
getAlternativeAcceleratorKey
in interfaceAction
- Returns:
- the accelerator key; null if undefined
-
setAlternativeAcceleratorKey
public void setAlternativeAcceleratorKey(KeyStroke alternativeKeyStroke) throws RegistrationException Description copied from interface:Action
Sets the givenKeyStroke
to this action as an alternative KeyStroke. Resetting the KeyStroke is not supported.- Specified by:
setAlternativeAcceleratorKey
in interfaceAction
- 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 anContextMenu
, this value indicates whether the context menu should be closed after executing the command contained in this action.- Specified by:
getCloseOnExecution
in interfaceAction
- Returns:
- whether the context menu should be closed or not
-
getContext
Description copied from interface:Action
The context this action is bound to.- Specified by:
getContext
in interfaceAction
- 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 returnsfalse
-
setCommand
Description copied from interface:Action
Should be only used for sub-menu actions. TheCommand
is set by the button.- Specified by:
setCommand
in interfaceAction
- Parameters:
command
- the open sub-menu command
-