org.jdesktop.application
Class ActionManager

java.lang.Object
  extended by org.jdesktop.application.AbstractBean
      extended by org.jdesktop.application.ActionManager

public class ActionManager
extends AbstractBean

The application's ActionManager provides read-only cached access to ActionMaps that contain one entry for each method marked with the @Action annotation in a class.

See Also:
ApplicationContext.getActionMap(Object), ApplicationActionMap, ApplicationAction

Constructor Summary
protected ActionManager(ApplicationContext context)
           
 
Method Summary
 ApplicationActionMap getActionMap()
          The ActionMap chain for the entire Application.
 ApplicationActionMap getActionMap(java.lang.Class actionsClass, java.lang.Object actionsObject)
          Returns the ApplicationActionMap chain for the specified actions class and target object.
protected  ApplicationContext getContext()
           
 
Methods inherited from class org.jdesktop.application.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionManager

protected ActionManager(ApplicationContext context)
Method Detail

getContext

protected final ApplicationContext getContext()

getActionMap

public ApplicationActionMap getActionMap()
The ActionMap chain for the entire Application.

Returns an ActionMap with the @Actions defined in the application's Application subclass, i.e. the the value of:

 ApplicationContext.getInstance().getApplicationClass()
 
The remainder of the chain contains one ActionMap for each superclass, up to Application.class. The ActionMap.get() method searches the entire chain, so logically, the ActionMap that this method returns contains all of the application-global actions.

The value returned by this method is cached.

Returns:
the ActionMap chain for the entire Application.
See Also:
getActionMap(Class, Object), ApplicationContext.getActionMap(), ApplicationContext.getActionMap(Class, Object), ApplicationContext.getActionMap(Object)

getActionMap

public ApplicationActionMap getActionMap(java.lang.Class actionsClass,
                                         java.lang.Object actionsObject)
Returns the ApplicationActionMap chain for the specified actions class and target object.

The specified class can contain methods marked with the @Action annotation. Each one will be turned into an ApplicationAction object and all of them will be added to a single ApplicationActionMap. All of the ApplicationActions invoke their actionPerformed method on the specified actionsObject. The parent of the returned ActionMap is the global ActionMap that contains the @Actions defined in this application's Application subclass.

To bind an @Action to a Swing component, one specifies the @Action's name in an expression like this:

 ApplicationContext ctx = Application.getInstance(MyApplication.class).getContext();
 MyActions myActions = new MyActions();
 myComponent.setAction(ac.getActionMap(myActions).get("myAction"));
 

The value returned by this method is cached. The lifetime of the cached entry will be the same as the lifetime of the actionsObject and the ApplicationActionMap and ApplicationActions that refer to it. In other words, if you drop all references to the actionsObject, including its ApplicationActions and their ApplicationActionMaps, then the cached ActionMap entry will be cleared.

Returns:
the ApplicationActionMap for actionsClass and actionsObject
See Also:
getActionMap(), ApplicationContext.getActionMap(), ApplicationContext.getActionMap(Class, Object), ApplicationContext.getActionMap(Object)