Top Description Fields Constructors Methods
org.controlsfx.control.action

public Class ActionMap

extends Object
Class Inheritance
Imports
javafx.event.ActionEvent, java.lang.annotation.Annotation, java.lang.reflect.Method, java.util.*

Action Map provides an ability to create an action map of any object. Attempts to convert methods annotated with ActionProxy to Action.

Code Example

Here's a very simple example of how to use ActionMap to register a class (in this class it is the application class itself), and to then retrieve actions out of the ActionMap (via the static ActionMap#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.
See Also
ActionProxy, Action

Field Summary

Modifier and TypeField and Description
private static AnnotatedActionFactory
private static final Map<String, AnnotatedAction>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Action

Returns:

action or null if id was not found
action
(String
action id
id
)

Returns action by its id.

public static Collection<Action>

Returns:

collection of actions
actions
(String...
action ids
ids
)

Returns collection of actions by ids.

private static AnnotatedActionFactory
public static AnnotatedActionFactory
getActionFactory()

Returns the action factory used by ActionMap to construct AnnotatedAction instances.

public static void
register(Object
object to work on
target
)

Attempts to convert target's methods annotated with ActionProxy to Actions.

public static void
setActionFactory(AnnotatedActionFactory factory)

Sets the action factory used by ActionMap to construct AnnotatedAction instances.

public static void
unregister(Object
object to work on
target
)

Removes all the actions associated with target object from the action map.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionFactoryback to summary
private static AnnotatedActionFactory actionFactory
actionsback to summary
private static final Map<String, AnnotatedAction> actions

Constructor Detail

ActionMapback to summary
private ActionMap()

Method Detail

actionback to summary
public static Action action(String id)

Returns action by its id.

Parameters
id:String

action id

Returns:Action

action or null if id was not found

actionsback to summary
public static Collection<Action> actions(String... ids)

Returns collection of actions by ids. Useful to create ActionGroups. Ids starting with "---" are converted to ActionUtils#ACTION_SEPARATOR. Incorrect ids are ignored.

Parameters
ids:String[]

action ids

Returns:Collection<Action>

collection of actions

determineActionFactoryback to summary
private static AnnotatedActionFactory determineActionFactory(ActionProxy annotation)
getActionFactoryback to summary
public static AnnotatedActionFactory getActionFactory()

Returns the action factory used by ActionMap to construct AnnotatedAction instances. By default, this is an instance of DefaultActionFactory.

registerback to summary
public static void register(Object target)

Attempts to convert target's methods annotated with 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.

Parameters
target:Object

object to work on

Exceptions
IllegalStateException:
if a method with unsupported parameters is annotated with ActionProxy.
setActionFactoryback to summary
public static void setActionFactory(AnnotatedActionFactory factory)

Sets the action factory used by ActionMap to construct AnnotatedAction instances. This factory can be overridden on a case-by-case basis by specifying a factory class in ActionProxy#factory()

unregisterback to summary
public static void unregister(Object target)

Removes all the actions associated with target object from the action map.

Parameters
target:Object

object to work on