public class NavigatorSelectionModel
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
READ_ONLY_PROPERTY |
static java.lang.String |
SELECTION_PROPERTY |
Constructor and Description |
---|
NavigatorSelectionModel(boolean isMultiSelectable)
Constructs a new instance with no selected elements.
|
NavigatorSelectionModel(java.util.List<?> selectedElements,
boolean isMultiSelectable)
Constructs a new instance with the provided selected elements.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a new property change listener for this selection model.
|
protected void |
fireReadOnlyChanged(boolean oldValue,
boolean newValue)
Fires to all listeners the provide read only change to the state of the
model.
|
java.util.List<?> |
getSelection()
Returns the selection list.
|
boolean |
isMultipleSelectionsAllowed()
Returns whether multiple selections are allowed in this model.
|
boolean |
isReadOnly()
Is this selection read only? A read only selection is presented to the
user for informative purposes only.
|
boolean |
isValid()
Is the current selection valid? This method should be used to inform
the user that the selection they made is invalid.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener from this selection model.
|
boolean |
updateSelection(java.util.List<?> newElements)
Updates the selection to some new selection.
|
public static final java.lang.String SELECTION_PROPERTY
public static final java.lang.String READ_ONLY_PROPERTY
public NavigatorSelectionModel(java.util.List<?> selectedElements, boolean isMultiSelectable)
selectedElements
- the list of initial elements in the selectionisMultiSelectable
- whether the selection can include multiple elements
or not. The model will not allow the selection to be updated
to include multiple selections if this flag is set to false.public NavigatorSelectionModel(boolean isMultiSelectable)
isMultiSelectable
- whether the selection can include multiple elements
or not. The model will not allow the selection to be updated
to include multiple selections if this flag is set to false.public final boolean updateSelection(java.util.List<?> newElements)
newElements
- The list of elements in a selectionpublic final java.util.List<?> getSelection()
public final void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- A new listener that will receive events for changes to
this model.public final void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- An existing listener that should not receive events from
this model any more.public boolean isValid()
Is the current selection valid? This method should be used to inform the user that the selection they made is invalid.
Note that invalid selections are allowed to be updated in this model and events will be fired. It is up to clients to call this method in order to check that the user made a valid or invalid selection.
public boolean isReadOnly()
Is this selection read only? A read only selection is presented to the user for informative purposes only. Any changes to the selection will not take effect.
Note: If this method is overriden in a way that makes the read only state
dynamic then listeners will be informed through the fireReadOnlyChanged(boolean, boolean)
mechanism about all read only state changes.
protected final void fireReadOnlyChanged(boolean oldValue, boolean newValue)
oldValue
- The old read only value.newValue
- The new read only value.public final boolean isMultipleSelectionsAllowed()