|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.globalmentor.beans.BoundPropertyObject
com.guiseframework.model.AbstractModel
com.guiseframework.model.AbstractValueModel<V>
com.guiseframework.model.DefaultListSelectModel<V>
V - The type of values contained in the model.public class DefaultListSelectModel<V>
The default implementation of a model for selecting one or more values from a list.
The model is thread-safe, synchronized on itself. Any iteration over values should include synchronization on the instance of this class.
This implementation has a default value of null.
| Nested Class Summary | |
|---|---|
protected class |
DefaultListSelectModel.ValueState
An encapsulation of the state of a value in the model. |
| Field Summary |
|---|
| Fields inherited from class com.globalmentor.beans.BoundPropertyObject |
|---|
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS |
| Fields inherited from interface com.guiseframework.model.ValueModel |
|---|
VALIDATOR_PROPERTY, VALUE_PROPERTY |
| Fields inherited from interface com.guiseframework.model.Model |
|---|
PLAIN_TEXT_CONTENT_TYPE, XHTML_CONTENT_TYPE, XHTML_FRAGMENT_CONTENT_TYPE |
| Constructor Summary | |
|---|---|
DefaultListSelectModel(java.lang.Class<V> valueClass)
Constructs a list select model indicating the type of values it can hold, using a default multiple selection strategy. |
|
DefaultListSelectModel(java.lang.Class<V> valueClass,
ListSelectionPolicy<V> listSelectionStrategy)
Constructs a list select model indicating the type of values it can hold. |
|
| Method Summary | ||
|---|---|---|
void |
add(int index,
V value)
Inserts the specified value at the specified position in this model. |
|
boolean |
add(V value)
Appends the specified value to the end of this model. |
|
boolean |
addAll(java.util.Collection<? extends V> collection)
Appends all of the values in the specified collection to the end of this model, in the order that they are returned by the specified collection's iterator. |
|
boolean |
addAll(int index,
java.util.Collection<? extends V> collection)
Inserts all of the values in the specified collection into this model at the specified position. |
|
void |
addListListener(ListListener<V> listListener)
Adds a list listener. |
|
void |
addListSelectionListener(ListSelectionListener<V> selectionListener)
Adds a list selection listener. |
|
void |
addSelectedIndexes(int... indexes)
Adds a selection at the given indices. |
|
void |
clear()
Removes all of the values from this model. |
|
void |
clearValue()
Clears the value by setting the value to null, which may be invalid according to any installed validators. |
|
boolean |
contains(java.lang.Object value)
Determines whether this model contains the specified value. |
|
boolean |
containsAll(java.util.Collection<?> collection)
Determines if this model contains all of the values of the specified collection. |
|
protected void |
fireListModified(int index,
V addedElement,
V removedElement)
Fires an event to all registered list listeners indicating the list was modified. |
|
protected void |
fireSelectionChanged(java.lang.Integer addedIndex,
java.lang.Integer removedIndex)
Fires an event to all registered selection listeners indicating the selection changed. |
|
V |
get(int index)
Returns the value at the specified position in this model. |
|
V |
getDefaultValue()
|
|
int |
getSelectedIndex()
Determines the selected index. |
|
int[] |
getSelectedIndexes()
Determines the selected indices. |
|
V |
getSelectedValue()
Determines the selected value. |
|
V[] |
getSelectedValues()
Determines the selected values. |
|
ListSelectionPolicy<V> |
getSelectionPolicy()
|
|
V |
getValue()
|
|
int |
indexOf(java.lang.Object value)
Returns the index in this model of the first occurrence of the specified value, or -1 if this model does not contain this value. |
|
boolean |
isEmpty()
|
|
boolean |
isIndexDisplayed(int index)
Determines the displayed status of a given index. |
|
boolean |
isIndexEnabled(int index)
Determines the enabled status of a given index. |
|
boolean |
isValueDisplayed(V value)
Determines the displayed status of the first occurrence of a given value. |
|
boolean |
isValueEnabled(V value)
Determines the enabled status of the first occurrence of a given value. |
|
java.util.Iterator<V> |
iterator()
|
|
int |
lastIndexOf(java.lang.Object value)
Returns the index in this model of the last occurrence of the specified value, or -1 if this model does not contain this value. |
|
java.util.ListIterator<V> |
listIterator()
|
|
java.util.ListIterator<V> |
listIterator(int index)
Returns a list iterator of the values in this model (in proper sequence), starting at the specified position in this model. |
|
protected void |
listModified(int index,
V addedElement,
V removedElement)
Called when the list is modified. |
|
V |
remove(int index)
Removes the value at the specified position in this model. |
|
boolean |
remove(java.lang.Object value)
Removes the first occurrence in this model of the specified value. |
|
boolean |
removeAll(java.util.Collection<?> collection)
Removes from this model all the values that are contained in the specified collection. |
|
void |
removeListListener(ListListener<V> listListener)
Removes a list listener. |
|
void |
removeListSelectionListener(ListSelectionListener<V> selectionListener)
Removes a list selection listener. |
|
void |
removeSelectedIndexes(int... indexes)
Removes a selection at the given indices. |
|
boolean |
replace(V oldValue,
V newValue)
Replaces the first occurrence of the given value with its replacement. |
|
void |
resetValue()
Resets the value to a default value, which may be invalid according to any installed validators. |
|
boolean |
retainAll(java.util.Collection<?> collection)
Retains only the values in this model that are contained in the specified collection. |
|
V |
set(int index,
V value)
Replaces the value at the specified position in this model with the specified value. |
|
void |
setIndexDisplayed(int index,
boolean newDisplayed)
Sets the displayed status of a given index. |
|
void |
setIndexEnabled(int index,
boolean newEnabled)
Sets the enabled status of a given index. |
|
void |
setSelectedIndexes(int... indexes)
Sets the selected indices. |
|
void |
setSelectedValues(V... values)
Sets the selected values. |
|
void |
setValue(V newValue)
Sets the input value. |
|
void |
setValueDisplayed(V value,
boolean newDisplayed)
Sets the displayed status of the first occurrence of a given value. |
|
void |
setValueEnabled(V value,
boolean newEnabled)
Sets the enabled status of the first occurrence of a given value. |
|
int |
size()
|
|
java.util.List<V> |
subList(int fromIndex,
int toIndex)
Returns a read-only view of the portion of this model between the specified fromIndex, inclusive, and toIndex, exclusive. |
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] array)
Returns an array containing all of the values in this model. |
|
| Methods inherited from class com.guiseframework.model.AbstractValueModel |
|---|
createPropertyVetoException, getValidator, getValueClass, isValidValue, setValidator, validateValue |
| Methods inherited from class com.guiseframework.model.AbstractModel |
|---|
getEventListenerManager, getPlainText |
| Methods inherited from class com.globalmentor.beans.BoundPropertyObject |
|---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.guiseframework.model.ValueModel |
|---|
getValidator, getValueClass, isValidValue, setValidator, validateValue |
| Methods inherited from interface com.globalmentor.beans.PropertyBindable |
|---|
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener |
| Methods inherited from interface com.globalmentor.beans.PropertyConstrainable |
|---|
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener |
| Methods inherited from interface java.util.List |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public DefaultListSelectModel(java.lang.Class<V> valueClass)
valueClass - The class indicating the type of values held in the model.
java.lang.NullPointerException - if the given value class is null.
public DefaultListSelectModel(java.lang.Class<V> valueClass,
ListSelectionPolicy<V> listSelectionStrategy)
valueClass - The class indicating the type of values held in the model.listSelectionStrategy - The strategy for selecting values in the model.
java.lang.NullPointerException - if the given value class and/or selection strategy is null.| Method Detail |
|---|
public V getDefaultValue()
getDefaultValue in interface ValueModel<V>public V getValue()
getValue in interface Valued<V>getValue in interface ValueModel<V>null if there is no selected value.
public void setValue(V newValue)
throws java.beans.PropertyVetoException
equals() method.
If a validator is installed, the value will first be validated before the current value is changed.
Validation always occurs if a validator is installed, even if the value is not changing.
If the value change is vetoed by the installed validator, the validation exception will be accessible via Throwable.getCause().
setValue in interface Valued<V>setValue in interface ValueModel<V>newValue - The input value of the model.
java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.AbstractValueModel.getValidator(),
ValueModel.VALUE_PROPERTYpublic void clearValue()
null, which may be invalid according to any installed validators.
No validation occurs.
clearValue in interface ValueModel<V>ValueModel.VALUE_PROPERTYpublic void resetValue()
clearValue().
resetValue in interface ValueModel<V>ValueModel.VALUE_PROPERTY,
clearValue()public int size()
size in interface java.util.Collection<V>size in interface java.util.List<V>public boolean isEmpty()
isEmpty in interface java.util.Collection<V>isEmpty in interface java.util.List<V>public boolean contains(java.lang.Object value)
contains in interface java.util.Collection<V>contains in interface java.util.List<V>value - The value the presence of which to test.
true if this model contains the specified value.public java.util.Iterator<V> iterator()
iterator in interface java.lang.Iterable<V>iterator in interface java.util.Collection<V>iterator in interface java.util.List<V>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<V>toArray in interface java.util.List<V>public <T> T[] toArray(T[] array)
toArray in interface java.util.Collection<V>toArray in interface java.util.List<V>array - The array into which the value of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
java.lang.ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every value in this model.
java.lang.NullPointerException - if the specified array is null.public boolean add(V value)
add(int, Object).
add in interface java.util.Collection<V>add in interface java.util.List<V>value - The value to be appended to this model.
true, indicating that the model changed as a result of the operation.public boolean remove(java.lang.Object value)
remove(int).
remove in interface java.util.Collection<V>remove in interface java.util.List<V>value - The value to be removed from this model, if present.
true if this model contained the specified value.public boolean containsAll(java.util.Collection<?> collection)
containsAll in interface java.util.Collection<V>containsAll in interface java.util.List<V>collection - The collection to be checked for containment in this model.
true if this model contains all of the values of the specified collection.
java.lang.NullPointerException - if the specified collection is null.contains(Object)public boolean addAll(java.util.Collection<? extends V> collection)
addAll in interface java.util.Collection<V>addAll in interface java.util.List<V>collection - The collection the values of which are to be added to this model.
true if this model changed as a result of the call.
java.lang.NullPointerException - if the specified collection is null.add(Object)
public boolean addAll(int index,
java.util.Collection<? extends V> collection)
addAll in interface java.util.List<V>index - The index at which to insert first value from the specified collection.collection - The values to be inserted into this model.
true if this model changed as a result of the call.
java.lang.NullPointerException - if the specified collection is null.
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).public boolean removeAll(java.util.Collection<?> collection)
removeAll in interface java.util.Collection<V>removeAll in interface java.util.List<V>collection - The collection that defines which values will be removed from this model.
true if this model changed as a result of the call.
java.lang.NullPointerException - if the specified collection is null.remove(Object),
contains(Object)public boolean retainAll(java.util.Collection<?> collection)
retainAll in interface java.util.Collection<V>retainAll in interface java.util.List<V>collection - The collection that defines which values this model will retain.
true if this model changed as a result of the call.
java.lang.NullPointerException - if the specified collection is null.remove(Object),
contains(Object)public void clear()
clear in interface java.util.Collection<V>clear in interface java.util.List<V>public V get(int index)
get in interface java.util.List<V>index - The index of the value to return.
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
public V set(int index,
V value)
set in interface java.util.List<V>index - The index of the value to replace.value - The value to be stored at the specified position.
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
public void add(int index,
V value)
add in interface java.util.List<V>index - The index at which the specified value is to be inserted.value - The value to be inserted.
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).public V remove(int index)
remove in interface java.util.List<V>index - The index of the value to removed.
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).public int indexOf(java.lang.Object value)
indexOf in interface java.util.List<V>value - The value for which to search.
public int lastIndexOf(java.lang.Object value)
lastIndexOf in interface java.util.List<V>value - The value for which to search.
public java.util.ListIterator<V> listIterator()
listIterator in interface java.util.List<V>public java.util.ListIterator<V> listIterator(int index)
listIterator in interface java.util.List<V>index - The index of first value to be returned from the list iterator (by a call to the next() method).
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).
public java.util.List<V> subList(int fromIndex,
int toIndex)
subList in interface java.util.List<V>fromIndex - The low endpoint (inclusive) of the sub-list.toIndex - The high endpoint (exclusive) of the sub-list.
java.lang.IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size() || fromIndex > toIndex).
public boolean replace(V oldValue,
V newValue)
replace in interface SelectModel<V>oldValue - The value for which to search.newValue - The replacement value.
public ListSelectionPolicy<V> getSelectionPolicy()
getSelectionPolicy in interface ListSelectModel<V>public int getSelectedIndex()
getSelectedIndex in interface ListSelectModel<V>getSelectedValue()public int[] getSelectedIndexes()
getSelectedIndexes in interface ListSelectModel<V>getSelectedValues()
public void setSelectedIndexes(int... indexes)
throws java.beans.PropertyVetoException
Throwable.getCause().
setSelectedIndexes in interface ListSelectModel<V>indexes - The indices to select.
java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.ListSelectionPolicy.getSetSelectedIndices(ListSelectModel, int[]),
#setSelectedValues(V[]),
addSelectedIndexes(int...)
public void addSelectedIndexes(int... indexes)
throws java.beans.PropertyVetoException
Throwable.getCause().
addSelectedIndexes in interface ListSelectModel<V>indexes - The indices to add to the selection.
java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.ListSelectionPolicy.getAddSelectedIndices(ListSelectModel, int[]),
setSelectedIndexes(int[])
public void removeSelectedIndexes(int... indexes)
throws java.beans.PropertyVetoException
Throwable.getCause().
removeSelectedIndexes in interface ListSelectModel<V>indexes - The indices to remove from the selection.
java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.ListSelectionPolicy.getRemoveSelectedIndices(ListSelectModel, int[]),
setSelectedIndexes(int[])public V getSelectedValue()
getSelectedValue in interface SelectModel<V>null if no value is currently selected.getSelectedIndex()public V[] getSelectedValues()
getSelectedValues in interface SelectModel<V>getSelectedIndexes()
public void setSelectedValues(V... values)
throws java.beans.PropertyVetoException
Throwable.getCause().
setSelectedValues in interface SelectModel<V>values - The values to select.
java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.setSelectedIndexes(int[])public boolean isValueDisplayed(V value)
isValueDisplayed in interface ListSelectModel<V>value - The value for which the displayed status is to be determined.
true if the value is displayed, else false.
java.lang.IndexOutOfBoundsException - if the given value does not occur in the model.
public void setValueDisplayed(V value,
boolean newDisplayed)
setValueDisplayed in interface ListSelectModel<V>value - The value to display.newDisplayed - Whether the value should be displayed.#DISPLAYED_PROPERTYpublic boolean isIndexDisplayed(int index)
isIndexDisplayed in interface ListSelectModel<V>index - The index of the value for which the displayed status is to be determined.
true if the value at the given index is displayed, else false.
public void setIndexDisplayed(int index,
boolean newDisplayed)
setIndexDisplayed in interface ListSelectModel<V>index - The index of the value to display.newDisplayed - Whether the value at the given index should be displayed.
java.lang.IndexOutOfBoundsException - if the given index is not within the range of the list.#DISPLAYED_PROPERTYpublic boolean isValueEnabled(V value)
isValueEnabled in interface ListSelectModel<V>value - The value for which the enabled status is to be determined.
true if the value is enabled, else false.
java.lang.IndexOutOfBoundsException - if the given value does not occur in the model.
public void setValueEnabled(V value,
boolean newEnabled)
setValueEnabled in interface ListSelectModel<V>value - The value to enable or disable.newEnabled - Whether the value should be enabled.#ENABLED_PROPERTYpublic boolean isIndexEnabled(int index)
isIndexEnabled in interface ListSelectModel<V>index - The index of the value for which the enabled status is to be determined.
true if the value at the given index is enabled, else false.
public void setIndexEnabled(int index,
boolean newEnabled)
setIndexEnabled in interface ListSelectModel<V>index - The index of the value to enable or disable.newEnabled - Whether the value at the given index should be enabled.
java.lang.IndexOutOfBoundsException - if the given index is not within the range of the list.#ENABLED_PROPERTYpublic void addListListener(ListListener<V> listListener)
addListListener in interface ListListenable<V>addListListener in interface ListSelectModel<V>listListener - The list listener to add.public void removeListListener(ListListener<V> listListener)
removeListListener in interface ListListenable<V>removeListListener in interface ListSelectModel<V>listListener - The list listener to remove.public void addListSelectionListener(ListSelectionListener<V> selectionListener)
addListSelectionListener in interface ListSelectModel<V>selectionListener - The selection listener to add.public void removeListSelectionListener(ListSelectionListener<V> selectionListener)
removeListSelectionListener in interface ListSelectModel<V>selectionListener - The selection listener to remove.
protected void listModified(int index,
V addedElement,
V removedElement)
index - The index at which an element was added and/or removed, or -1 if the index is unknown.addedElement - The element that was added to the list, or null if no element was added or it is unknown whether or which elements were added.removedElement - The element that was removed from the list, or null if no element was removed or it is unknown whether or which elements were removed.fireListModified(int, Object, Object)
protected void fireListModified(int index,
V addedElement,
V removedElement)
index - The index at which an element was added and/or removed, or -1 if the index is unknown.addedElement - The element that was added to the list, or null if no element was added or it is unknown whether or which elements were added.removedElement - The element that was removed from the list, or null if no element was removed or it is unknown whether or which elements were removed.ListListener,
ListEvent
protected void fireSelectionChanged(java.lang.Integer addedIndex,
java.lang.Integer removedIndex)
addedIndex - The index that was added to the selection, or null if no index was added or it is unknown whether or which indices were added.removedIndex - The index that was removed from the list, or null if no index was removed or it is unknown whether or which indices were removed.ListSelectionListener,
ListSelectionEvent
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||