com.mucommander.ui.action
Class ActionManager

java.lang.Object
  extended by com.mucommander.ui.action.ActionManager

public class ActionManager
extends java.lang.Object

ActionManager provides methods to retrieve MuAction instances and invoke them. It keeps track of all the action instances it has created and allows them to be reused whithin a MainFrame.

MuAction subclasses should not be instanciated directly, getActionInstance methods should be used instead. Using ActionManager to retrieve a MuAction ensures that only one instance exists for a given MainFrame. This is particularly important because actions are stateful and can be used in several components of a MainFrame at the same time; if an action's state changes, the change must be reflected everywhere the action is used. It is also important for performance reasons: sharing one action throughout a MainFrame saves some memory and also CPU cycles as some actions listen to particular events to change their state accordingly.

Author:
Maxence Bernard
See Also:
MuAction, ActionDescriptor, ActionKeymap

Constructor Summary
ActionManager()
           
 
Method Summary
static MuAction getActionInstance(ActionDescriptor actionDescriptor, MainFrame mainFrame)
          Returns an instance of the MuAction class denoted by the given ActionDescriptor, for the specified MainFrame.
static MuAction getActionInstance(java.lang.Class actionClass, MainFrame mainFrame)
          Convenience method that returns an instance of the given MuAction class, and associated with the specified MainFrame.
static java.util.Vector getActionInstances(java.lang.Class muActionClass)
          Returns a Vector of all MuAction instances matching the specified Class.
static boolean performAction(ActionDescriptor actionDescriptor, MainFrame mainFrame)
          Convenience method that retrieves an instance of the MuAction denoted by the given ActionDescriptor and associated with the given MainFrame and calls MuAction.performAction() on it.
static boolean performAction(java.lang.Class actionClass, MainFrame mainFrame)
          Convenience method that retrieves an instance of the MuAction denoted by the given Class and associated with the given MainFrame and calls MuAction.performAction() on it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionManager

public ActionManager()
Method Detail

getActionInstance

public static MuAction getActionInstance(java.lang.Class actionClass,
                                         MainFrame mainFrame)
Convenience method that returns an instance of the given MuAction class, and associated with the specified MainFrame. This method creates an ActionDescriptor with no initial property, passes it to getActionInstance(ActionDescriptor, MainFrame) and returns the MuAction instance.

Parameters:
actionClass - the MuAction class to instanciate
mainFrame - the MainFrame instance the action belongs to
Returns:
a MuAction instance matching the given MuAction Class and MainFrame, null if the class could not be found or could not be instanciated.

getActionInstance

public static MuAction getActionInstance(ActionDescriptor actionDescriptor,
                                         MainFrame mainFrame)
Returns an instance of the MuAction class denoted by the given ActionDescriptor, for the specified MainFrame. If an existing instance corresponding to the same ActionDescriptor and MainFrame is found, it is simply returned. If no matching instance could be found, a new instance is created, added to the internal action instances map (for further use) and returned. If the MuAction denoted by the specified ActionDescriptor cannot be found or cannot be instanciated, null is returned.

Parameters:
actionDescriptor - a descriptor of the action class to instanciate with initial properties
mainFrame - the MainFrame instance the action belongs to
Returns:
a MuAction instance matching the given ActionDescriptor and MainFrame, null if the MuAction class denoted by the ActionDescriptor could not be found or could not be instanciated.

getActionInstances

public static java.util.Vector getActionInstances(java.lang.Class muActionClass)
Returns a Vector of all MuAction instances matching the specified Class.

Parameters:
muActionClass - the MuAction class to compare instances against
Returns:
a Vector of all MuAction instances matching the specified Class

performAction

public static boolean performAction(java.lang.Class actionClass,
                                    MainFrame mainFrame)
Convenience method that retrieves an instance of the MuAction denoted by the given Class and associated with the given MainFrame and calls MuAction.performAction() on it. Returns true if an instance of the action could be retrieved and performed, false if the MuAction could not be found or could not be instanciated.

Parameters:
actionClass - the class of the MuAction to perform
mainFrame - the MainFrame the action belongs to
Returns:
true if the action instance could be retrieved and the action performed, false otherwise

performAction

public static boolean performAction(ActionDescriptor actionDescriptor,
                                    MainFrame mainFrame)
Convenience method that retrieves an instance of the MuAction denoted by the given ActionDescriptor and associated with the given MainFrame and calls MuAction.performAction() on it. Returns true if an instance of the action could be retrieved and performed, false if the MuAction could not be found or could not be instanciated.

Parameters:
actionDescriptor - the ActionDescriptor of the action to perform
mainFrame - the MainFrame the action belongs to
Returns:
true if the action instance could be retrieved and the action performed, false otherwise


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard