public class ActionMap
extends java.lang.Object
ActionProxy to Action.
action(String) method:
public class ActionMapDemo extends Application {
public ActionMapDemo() {
ActionMap.register(this);
Action action11 = ActionMap.action("action11");
Button actionButton = ActionUtils.createButton(action11);
}
@ActionProxy(text="Action 1.1", graphic="start.png", accelerator="ctrl+shift+T")
private void action11() {
System.out.println( "Action 1.1 is executed");
}
}
If you require more control over the creation of the Action objects, you can either set the
global ActionFactory by calling ActionMap.setActionFactory() and/or you can use the factory
property on individual @ActionProxy declarations to set the factory on a case-by-case basis.ActionProxy,
Action| Modifier and Type | Method and Description |
|---|---|
static Action |
action(java.lang.String id)
Returns action by its id.
|
static java.util.Collection<Action> |
actions(java.lang.String... ids)
Returns collection of actions by ids.
|
static AnnotatedActionFactory |
getActionFactory()
Returns the action factory used by ActionMap to construct AnnotatedAction instances.
|
static void |
register(java.lang.Object target)
Attempts to convert target's methods annotated with
ActionProxy to Actions. |
static void |
setActionFactory(AnnotatedActionFactory factory)
Sets the action factory used by ActionMap to construct AnnotatedAction instances.
|
static void |
unregister(java.lang.Object target)
Removes all the actions associated with target object from the action map.
|
public static AnnotatedActionFactory getActionFactory()
DefaultActionFactory.public static void setActionFactory(AnnotatedActionFactory factory)
ActionProxy.factory()public static void register(java.lang.Object target)
ActionProxy to Actions.
Three types of methods are currently converted: parameter-less methods,
methods with one parameter of type ActionEvent, and methods with two parameters
(ActionEvent, Action).
Note that this method supports safe re-registration of a given instance or of another instance of the
same class that has already been registered. If another instance of the same class is registered, then
those actions will now be associated with the new instance. The first instance is implicitly unregistered.
Actions are registered with their id or method name if id is not defined.target - object to work onjava.lang.IllegalStateException - if a method with unsupported parameters is annotated with ActionProxy.public static void unregister(java.lang.Object target)
target - object to work onpublic static Action action(java.lang.String id)
id - action idpublic static java.util.Collection<Action> actions(java.lang.String... ids)
ActionGroups.
Ids starting with "---" are converted to ActionUtils.ACTION_SEPARATOR.
Incorrect ids are ignored.ids - action ids