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 newRegisteredActionwith the given parameters.RegisteredAction(String label, String description, KeyStroke acceleratorKey, KeyStroke alternativeAcceleratorKey, StateIcon icon, Command command, Collection<Object> context, boolean closeOnExecution) Creates a newRegisteredActionwith 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 newRegisteredActionwith the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether the command can be executed.voidExecutes the Command of this actionReturns the accelerator key stroke (e.g.Returns a second, alternative accelerator key stroke for this action.booleanIf 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 theCommandfor 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 theStateIconfor this action.getLabel()Returns the label of the action which should be displayed in the toolbar or context menu.voidsetAlternativeAcceleratorKey(KeyStroke alternativeKeyStroke) Sets the givenKeyStroketo this action as an alternative KeyStroke.voidsetCommand(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 newRegisteredActionwith 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- theKeyStrokefor 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 newRegisteredActionwith 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- theKeyStrokefor this actionalternativeAcceleratorKey- an alternativeKeyStrokefor 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 newRegisteredActionwith 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- theKeyStrokefor this actionalternativeAcceleratorKey- an alternativeKeyStrokefor 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:ActionReturns the label of the action which should be displayed in the toolbar or context menu. -
getDescription
Description copied from interface:ActionReturns the description of the action which should be displayed when hovering over the GUI component containing this action.- Specified by:
getDescriptionin interfaceAction- Returns:
- the description
-
getIcon
Description copied from interface:ActionReturns theStateIconfor this action. -
getCommand
Description copied from interface:ActionReturns theCommandfor this action.- Specified by:
getCommandin interfaceAction- Returns:
- the command
-
getAcceleratorKey
Description copied from interface:ActionReturns the accelerator key stroke (e.g. CTRL + S) for this action.- Specified by:
getAcceleratorKeyin interfaceAction- Returns:
- the accelerator key; null if undefined
-
getAlternativeAcceleratorKey
Description copied from interface:ActionReturns a second, alternative accelerator key stroke for this action.- Specified by:
getAlternativeAcceleratorKeyin interfaceAction- Returns:
- the accelerator key; null if undefined
-
setAlternativeAcceleratorKey
public void setAlternativeAcceleratorKey(KeyStroke alternativeKeyStroke) throws RegistrationException Description copied from interface:ActionSets the givenKeyStroketo this action as an alternative KeyStroke. Resetting the KeyStroke is not supported.- Specified by:
setAlternativeAcceleratorKeyin 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:ActionIf 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:
getCloseOnExecutionin interfaceAction- Returns:
- whether the context menu should be closed or not
-
getContext
Description copied from interface:ActionThe context this action is bound to.- Specified by:
getContextin 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:
trueif the command can be executed otherwise returnsfalse
-
setCommand
Description copied from interface:ActionShould be only used for sub-menu actions. TheCommandis set by the button.- Specified by:
setCommandin interfaceAction- Parameters:
command- the open sub-menu command
-