|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.MapComponentSelectionModel
A simple implementation of a ComponentSelectionModel
. Uses
a map to bind keys to components.
This class also encapsulates a SingleSelectionModel
, which
is useful if the SingleSelectionModel
comes from a List
or
similar class.
Field Summary | |
static String |
versionId
|
Constructor Summary | |
MapComponentSelectionModel(Map components)
Constructs a new MapSingleSelectionModel, using a DefaultSingleSelectionModel selection model and encapsulating the components map. |
|
MapComponentSelectionModel(SingleSelectionModel selModel,
Map components)
Constructs a new MapSingleSelectionModel, using selModel as the inner selection model and encapsulating the components map. |
Method Summary | |
void |
add(Object key,
Component c)
Adds another key-component mapping to the model. |
void |
addChangeListener(ChangeListener l)
Adds a change listener to the model. |
void |
clearSelection(PageState state)
Clears the selection. |
Component |
getComponent(PageState state)
Returns the component that should be used to output the currently selected element. |
Map |
getComponentsMap()
Retrieves the internal Map of components. |
Object |
getSelectedKey(PageState state)
Returns the key that identifies the selected element. |
SingleSelectionModel |
getSingleSelectionModel()
Retrieves the internal SingleSelectionModel. |
ParameterModel |
getStateParameter()
Returns the state parameter that will be used to keep track of the currently selected key. |
boolean |
isLocked()
Return whether an object is locked and thus immutable, or can still be modified. |
boolean |
isSelected(PageState state)
Returns true if there is a selected element. |
void |
lock()
Lock an object. |
void |
removeChangeListener(ChangeListener l)
Removes a change listener from the model. |
void |
setSelectedKey(PageState state,
Object key)
Sets the selected key. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public MapComponentSelectionModel(SingleSelectionModel selModel, Map components)
selModel
- the single selection model to use to determine
the currently selected key/componentcomponents
- the map of components that can be selected. The map
is stored by reference. Therefore, changes to the map will
affect the MapComponentSelectionModel instance.public MapComponentSelectionModel(Map components)
components
- the map of components that can be selected. The map
is stored by reference. Therefore, changes to the map will
affect the MapComponentSelectionModel instance.Method Detail |
public final SingleSelectionModel getSingleSelectionModel()
public final Map getComponentsMap()
public Component getComponent(PageState state)
getComponent
in interface ComponentSelectionModel
state
- the state of the current request
public void add(Object key, Component c)
key
- the key for the mappingc
- the component for the mappingpublic boolean isSelected(PageState state)
true
if there is a selected element.
isSelected
in interface SingleSelectionModel
state
- the state of the current request
true
if there is a selected component
false
otherwise.public Object getSelectedKey(PageState state)
getSelectedKey
in interface SingleSelectionModel
state
- a PageState
value
String
value.public void setSelectedKey(PageState state, Object key)
key
is not in the collection of
objects underlying this model, an
IllegalArgumentException
is thrown.
setSelectedKey
in interface SingleSelectionModel
state
- the state of the current requestkey
- the selected key
IllegalArgumentException
- if the supplied key
cannot
be selected in the context of the current request.public void clearSelection(PageState state)
clearSelection
in interface SingleSelectionModel
state
- the state of the current requestpublic void addChangeListener(ChangeListener l)
stateChanged
is called whenever the selected key changes.
addChangeListener
in interface SingleSelectionModel
l
- a listener to notify when the selected key changespublic void removeChangeListener(ChangeListener l)
removeChangeListener
in interface SingleSelectionModel
l
- the listener to removepublic ParameterModel getStateParameter()
return new StringParameter("foo");
This method may return null if a state parameter is not
appropriate in the context of the implementing class.
getStateParameter
in interface SingleSelectionModel
public final void lock()
Lockable
setXXX
method
should lead to an exception.
Most lockable Bebop classes throw an IllegalStateException
if an attempt is made to modify a
locked instance.
lock
in interface Lockable
public final boolean isLocked()
Lockable
isLocked
in interface Lockable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |