public final class ActionList
extends java.lang.Object
ActionList
encapsulates a collection of action related
objects that can be used to construct menus, tool-bars, pop-ups and
the like. It basically holds a list of identifier Strings
or
null
values that are each associated with a certain EntryType
.
Each ActionList
created by the ActionManager
or other
framework elements is immutable (i.e. it was created using a null
owner). All attempts to modify those lists by client code outside the
framework will cause IllegalArgumentException
being thrown.
If an application wants to create their own ActionList
instance
and modify it at runtime it can use the ActionList(String, Object)
constructor to pass an owner
object to the list that will serve
as a kind of key
to access methods that structurally modify the list
or some of its properties.Modifier and Type | Class and Description |
---|---|
static class |
ActionList.EntryType
Type definitions used for entries in an
ActionList . |
Constructor and Description |
---|
ActionList(java.lang.String id)
Creates an
ActionList that will be immutable
for code outside the framework. |
ActionList(java.lang.String id,
java.lang.Object owner)
Creates an
ActionList that will be immutable
for all code besides the framework and the holder of the owner
object. |
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Object owner,
ActionList.EntryType type,
java.lang.String value)
Adds the
type and value objects to the end
of this list. |
java.lang.String |
getActionId()
Returns the identifier of an
Action that is meant to
be used to activate this list or null if this list
is not associated with any action. |
java.lang.String |
getGroupId(java.lang.String actionId) |
java.lang.String |
getId()
Returns the global identifier assigned to this list
|
ActionList.EntryType |
getTypeAt(int index)
Fetches the
EntryType that describes the actual
'content' of data stored at the given index . |
java.lang.String |
getValueAt(int index)
Fetches the
value this list stores at the given index . |
void |
mapGroup(java.lang.Object owner,
java.lang.String actionId,
java.lang.String groupId) |
void |
set(int index,
java.lang.Object owner,
ActionList.EntryType type,
java.lang.String value)
Replaces the
type and value objects at the specified
index by the given arguments. |
void |
setActionId(java.lang.Object owner,
java.lang.String actionId) |
int |
size()
Returns the number of elements in this list or
0
if it is empty |
public ActionList(java.lang.String id)
ActionList
that will be immutable
for code outside the framework. That means all public methods
that take an owner
argument will throw IllegalArgumentException
on every attempt to call them regardless of the Object
passed
as owner
to the specific call.id
- the global identifier used to address this listpublic ActionList(java.lang.String id, java.lang.Object owner)
ActionList
that will be immutable
for all code besides the framework and the holder of the owner
object. Calls to restricted methods like add(Object, EntryType, String)
will throw IllegalArgumentException
if the given owner
argument does not match the initial value set in this constructor or
the initial owner
is null
. Note that framework members
can still bypass those restriction by using the package private methods!id
- the global identifier used to address this listowner
- "key"
to access restricted methods on this list or
null
if this ActionList
is meant to be immutablepublic java.lang.String getId()
public java.lang.String getValueAt(int index)
value
this list stores at the given index
.
Note that the meaning of this value is depending on the EntryType
defined for that index
and might even be null
.public ActionList.EntryType getTypeAt(int index)
EntryType
that describes the actual
'content' of data stored at the given index
.public int size()
0
if it is emptypublic void set(int index, java.lang.Object owner, ActionList.EntryType type, java.lang.String value)
type
and value
objects at the specified
index
by the given arguments.
Before actual modifications take place the supplied owner
will be checked against the one that was set at constructor time.
If this internal owner
is null
or the given one
differs from it an IllegalArgumentException
will be thrown.
index
- the index the modifications will take placeowner
- key
to access this restricted methodtype
- the new EntryType
or null
if the type
should not be changedvalue
- object to replace the old value
or null
if no changes are intendedpublic void add(java.lang.Object owner, ActionList.EntryType type, java.lang.String value)
type
and value
objects to the end
of this list.
Before actual modifications take place the supplied owner
will be checked against the one that was set at constructor time.
If this internal owner
is null
or the given one
differs from it an IllegalArgumentException
will be thrown.
owner
- key
to access this restricted methodtype
- the EntryType
to be added, must not be null
value
- String
to be added, may be null
public java.lang.String getActionId()
Action
that is meant to
be used to activate
this list or null
if this list
is not associated with any action.public void setActionId(java.lang.Object owner, java.lang.String actionId)
owner
- actionId
- public java.lang.String getGroupId(java.lang.String actionId)
public void mapGroup(java.lang.Object owner, java.lang.String actionId, java.lang.String groupId)