|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.ActionMap
org.jdesktop.swingx.action.ActionManager
public class ActionManager
The ActionManager manages sets of javax.swing.Action
s for an
application. There are convenience methods for getting and setting the state
of the action.
All of these elements have a unique id tag which is used by the ActionManager
to reference the action. This id maps to the Action.ACTION_COMMAND_KEY
on the Action.
The ActionManager may be used to conveniently register callback methods on BoundActions.
A typical use case of the ActionManager is:
ActionManager manager = ActionManager.getInstance(); // load Actions manager.addAction(action); // Change the state of the action: manager.setEnabled("new-action", newState);The ActionManager also supports Actions that can have a selected state associated with them. These Actions are typically represented by a JCheckBox or similar widget. For such actions the registered method is invoked with an additional parameter indicating the selected state of the widget. For example, for the callback handler:
public class Handler { public void stateChanged(boolean newState); }The registration method would look similar:
manager.registerCallback("select-action", new Handler(), "stateChanged");
The stateChanged method would be invoked as the selected state of
the widget changed. Additionally if you need to change the selected
state of the Action use the ActionManager method setSelected
.
The ActionContainerFactory
uses the managed Actions in a
ActionManager to create user interface components. It uses the shared
instance of ActionManager by default. For example, to create a JMenu based on an
action-list id:
ActionContainerFactory factory = new ActionContainerFactory(); JMenu file = factory.createMenu(list);
ActionContainerFactory
,
TargetableAction
,
BoundAction
,
Serialized FormConstructor Summary | |
---|---|
ActionManager()
Creates the action manager. |
Method Summary | |
---|---|
Action |
addAction(Action action)
|
Action |
addAction(Object id,
Action action)
Adds an action to the ActionManager |
Action |
getAction(Object id)
Retrieves the action corresponding to an action id. |
Set<Object> |
getActionIDs()
Returns the ids for all the managed actions. |
BoundAction |
getBoundAction(Object id)
Convenience method for returning the BoundAction |
CompositeAction |
getCompositeAction(Object id)
Convenience method for returning the CompositeAction |
static ActionManager |
getInstance()
Return the instance of the ActionManger. |
ServerAction |
getServerAction(Object id)
Convenience method for returning the ServerAction |
TargetableAction |
getTargetableAction(Object id)
Convenience method for returning the TargetableAction |
boolean |
isBoundAction(Object id)
Test to determine if the action is a BoundAction |
boolean |
isCompositeAction(Object id)
Test to determine if the action is a BoundAction |
boolean |
isEnabled(Object id)
Returns the enabled state of the Action . |
boolean |
isSelected(Object id)
Gets the selected state of a toggle action. |
boolean |
isServerAction(Object id)
Test to determine if the action is a ServerAction |
boolean |
isStateAction(Object id)
Determines if the Action corresponding to the action id is a state changed action (toggle, group type action). |
boolean |
isTargetableAction(Object id)
Test to determine if the action is a TargetableAction |
void |
registerCallback(Object id,
Object handler,
String method)
Convenience method to register a callback method on a BoundAction |
void |
setEnabled(Object id,
boolean enabled)
Enables or disables the state of the Action corresponding to the action id. |
static void |
setInstance(ActionManager manager)
Sets the ActionManager instance. |
void |
setSelected(Object id,
boolean selected)
Sets the selected state of a toggle action. |
Methods inherited from class javax.swing.ActionMap |
---|
allKeys, clear, get, getParent, keys, put, remove, setParent, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ActionManager()
Method Detail |
---|
public static ActionManager getInstance()
setInstance(org.jdesktop.swingx.action.ActionManager)
public static void setInstance(ActionManager manager)
public Set<Object> getActionIDs()
An action id is a unique idenitfier which can be used to retrieve the corrspondng Action from the ActionManager. This identifier can also be used to set the properties of the action through the action manager like setting the state of the enabled or selected flags.
public Action addAction(Action action)
public Action addAction(Object id, Action action)
id
- value of the action id - which is value of the ACTION_COMMAND_KEYaction
- Action to be managed
public Action getAction(Object id)
id
- value of the action id
public TargetableAction getTargetableAction(Object id)
id
- value of the action id
public BoundAction getBoundAction(Object id)
id
- value of the action id
public ServerAction getServerAction(Object id)
id
- value of the action id
public CompositeAction getCompositeAction(Object id)
id
- value of the action id
public void setEnabled(Object id, boolean enabled)
id
- value of the action idenabled
- true if the action is to be enabled; otherwise falsepublic boolean isEnabled(Object id)
Action
. When enabled,
any component associated with this object is active and
able to fire this object's actionPerformed
method.
id
- value of the action id
Action
is enabled; false if the
action doesn't exist or disabled.public void setSelected(Object id, boolean selected)
id
- the value of the action idselected
- true if the action is to be selected; otherwise false.public boolean isSelected(Object id)
id
- the value of the action id
public void registerCallback(Object id, Object handler, String method)
BoundAction
id
- value of the action id - which is the value of the ACTION_COMMAND_KEYhandler
- the object which will be perform the actionmethod
- the name of the method on the handler which will be called.BoundAction.registerCallback(java.lang.Object, java.lang.String)
public boolean isStateAction(Object id)
id
- value of the action id
public boolean isTargetableAction(Object id)
TargetableAction
public boolean isBoundAction(Object id)
BoundAction
public boolean isCompositeAction(Object id)
BoundAction
public boolean isServerAction(Object id)
ServerAction
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |