public class ActionStore extends Object
A class for maintaining action objects.
This class provides access to the actions available in an application or for a certain component. Actions can be queried by their name, or lists of all existing actions can be requested. It is also possible to organize actions in groups. Then for example all actions that belong to a group can be disabled at once.
An ActionStore
object also holds a reference to a parent
store. If defined, all actions in the parent store can be accessed by this
store, too. This provides for a hierarchical action architecture. E.g. there
may be a central ActionStore
holding the global actions of the
application. Sub components of the application (e.g. internal frames or
dialogs) can define their own ActionStore
with their specific
set of actions, but through the parent reference have also access to the
global actions.
Note: The operations of this class are thread-safe.
Constructor and Description |
---|
ActionStore()
Creates a new empty instance of
ActionStore . |
ActionStore(ActionStore parent)
Creates a new instance of
ActionStore and initializes the
parent reference. |
Modifier and Type | Method and Description |
---|---|
void |
addAction(FormAction action)
Adds the specified action to this store.
|
void |
addActionToGroup(String actionName,
String groupName)
Adds the specified action to the given group.
|
void |
enableGroup(String groupName,
boolean enabled)
Sets the enabled flag for all actions in the specified group.
|
FormAction |
getAction(String name)
Returns the action with the given name.
|
Set<String> |
getActionNames()
Returns a collection with the names of the actions stored in this
ActionStore . |
Set<String> |
getActionNamesForGroup(String groupName)
Returns a set with the names of all actions that belong to the given
group.
|
Collection<FormAction> |
getActions(Collection<String> names)
Returns all action objects whose names are specified in the given
collection.
|
Set<String> |
getAllActionNames()
Returns a collection with the names of all actions stored in this
ActionStore or in one of its parents. |
Set<String> |
getGroupNames()
Returns the names of all defined groups.
|
ActionStore |
getParent()
Returns the parent store.
|
boolean |
hasAction(String name)
Returns a flag whether the specified action is contained in this store or
in the parent store.
|
boolean |
isActionInGroup(String actionName,
String groupName)
Checks if the specified action belongs to the given group.
|
FormAction |
removeAction(String name)
Removes the action with the specified name from this store.
|
boolean |
removeActionFromGroup(String actionName,
String groupName)
Removes the specified action from the given group.
|
boolean |
removeGroup(String groupName)
Removes the group with the specified name.
|
void |
setParent(ActionStore parent)
Sets the parent store.
|
public ActionStore()
ActionStore
.public ActionStore(ActionStore parent)
ActionStore
and initializes the
parent reference.parent
- this action store's parentpublic void addAction(FormAction action)
action
- the action to add (must not be null)public FormAction removeAction(String name)
name
- the name of the action to removepublic FormAction getAction(String name)
name
- the name of the desired actionNoSuchElementException
- if no such action existspublic boolean hasAction(String name)
name
- the action's namepublic Set<String> getActionNames()
ActionStore
. The returned collection will not contain the
names of the actions that are stored in the parent
ActionStore
.ActionStore
public Set<String> getAllActionNames()
ActionStore
or in one of its parents. With this method
really all names can be found out that can be passed to the
getAction(String)
method. Note: the set returned
by this method is a snapshot reflecting the state of this action time at
the time it was created. It is not connected to this action store, so
later updates are not visible.public Collection<FormAction> getActions(Collection<String> names)
NoSuchElementException
exception will be thrown. If an
action cannot be found in this store, the parent store (if it is
defined), is also searched.names
- a collection with the names of the desired actionsNoSuchElementException
- if one of the actions cannot be resolvedpublic void addActionToGroup(String actionName, String groupName)
NoSuchElementException
exception will
be thrown.actionName
- the name of the actiongroupName
- the name of the group (must not be null)public boolean removeActionFromGroup(String actionName, String groupName)
actionName
- the action's namegroupName
- the group's namepublic boolean isActionInGroup(String actionName, String groupName)
actionName
- the action's namegroupName
- the group's namepublic boolean removeGroup(String groupName)
groupName
- the name of the group to removepublic Set<String> getActionNamesForGroup(String groupName)
groupName
- the name of the grouppublic Set<String> getGroupNames()
ActionStore
are completely independent on the parent's
groups, i.e. this method won't return any groups defined in the parent
store.public void enableGroup(String groupName, boolean enabled)
groupName
- the name of the groupenabled
- the value of the enabled flagpublic ActionStore getParent()
public void setParent(ActionStore parent)
parent
- the parent storeCopyright © 2016 The JGUIraffe Team. All rights reserved.