Package io.guise.framework.model
Interface ListSelectModel<V>
- Type Parameters:
V
- The type of values contained in the model.
- All Superinterfaces:
Collection<V>
,Iterable<V>
,List<V>
,ListListenable<V>
,Model
,com.globalmentor.model.MutableValued<V>
,com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,SelectModel<V>
,com.globalmentor.model.Valued<V>
,ValueModel<V>
- All Known Subinterfaces:
CardControl
,ListSelectControl<V>
- All Known Implementing Classes:
AbstractCardPanel
,AbstractListSelectContainerControl
,AbstractListSelectControl
,AbstractListSelectTableModel
,BooleanValueControlSelectControl
,CardPanel
,CardTabControl
,DefaultListSelectModel
,ListControl
,SequenceCardPanel
,TabbedPanel
,TabContainerControl
,TabControl
A model for selecting one or more values from a list. The model must be thread-safe, synchronized on itself. Any iteration over values should include
synchronization on the instance of this interface. When the selection is changed, a
ListSelectionEvent
is fired. When the
state of a value (besides its selection, such as its enabled status) changes, a GenericPropertyChangeEvent
event is fired
referencing the value the state of which has changed.- Author:
- Garret Wilson
-
Field Summary
Fields inherited from interface io.guise.framework.model.ValueModel
VALIDATOR_PROPERTY, VALUE_PROPERTY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.int
Determines the selected index.int[]
Determines the selected indices.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.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.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
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.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
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 io.guise.framework.model.SelectModel
getSelectedValue, getSelectedValues, replace, setSelectedValues
Methods inherited from interface io.guise.framework.model.ValueModel
clearValue, getDefaultValue, getValidator, getValue, getValueClass, isValidValue, resetValue, setValidator, setValue, validateValue
-
Method Details
-
getSelectionPolicy
ListSelectionPolicy<V> getSelectionPolicy()- Returns:
- The selection policy for this model.
-
getSelectedIndex
int getSelectedIndex()Determines the selected index. If more than one index is selected, the lead selected index will be returned.- Returns:
- The index currently selected, or -1 if no index is selected.
- See Also:
-
getSelectedIndexes
int[] getSelectedIndexes()Determines the selected indices.- Returns:
- The indices currently selected.
- See Also:
-
setSelectedIndexes
Sets the selected indices. Invalid and duplicate indices will be ignored. If the value change is vetoed by the installed validator, the validation exception will be accessible viaThrowable.getCause()
.- Parameters:
indexes
- The indices to select.- Throws:
PropertyVetoException
- if the provided value is not valid or the change has otherwise been vetoed.- See Also:
-
addSelectedIndexes
Adds a selection at the given indices. Any invalid indices will be ignored. If the value change is vetoed by the installed validator, the validation exception will be accessible viaThrowable.getCause()
.- Parameters:
indexes
- The indices to add to the selection.- Throws:
PropertyVetoException
- if the provided value is not valid or the change has otherwise been vetoed.- See Also:
-
removeSelectedIndexes
Removes a selection at the given indices. Any invalid indices will be ignored. If the value change is vetoed by the installed validator, the validation exception will be accessible viaThrowable.getCause()
.- Parameters:
indexes
- The indices to remove from the selection.- Throws:
PropertyVetoException
- if the provided value is not valid or the change has otherwise been vetoed.- See Also:
-
isValueDisplayed
Determines the displayed status of the first occurrence of a given value.- Parameters:
value
- The value for which the displayed status is to be determined.- Returns:
true
if the value is displayed, elsefalse
.- Throws:
IndexOutOfBoundsException
- if the given value does not occur in the model.
-
setValueDisplayed
Sets the displayed status of the first occurrence of a given value. This is a bound value state property.- Parameters:
value
- The value to display.newDisplayed
- Whether the value should be displayed.- See Also:
-
isIndexDisplayed
boolean isIndexDisplayed(int index) Determines the displayed status of a given index.- Parameters:
index
- The index of the value for which the displayed status is to be determined.- Returns:
true
if the value at the given index is displayed, elsefalse
.
-
setIndexDisplayed
void setIndexDisplayed(int index, boolean newDisplayed) Sets the displayed status of a given index. This is a bound value state property.- Parameters:
index
- The index of the value to display.newDisplayed
- Whether the value at the given index should be displayed.- Throws:
IndexOutOfBoundsException
- if the given index is not within the range of the list.- See Also:
-
isValueEnabled
Determines the enabled status of the first occurrence of a given value.- Parameters:
value
- The value for which the enabled status is to be determined.- Returns:
true
if the value is enabled, elsefalse
.- Throws:
IndexOutOfBoundsException
- if the given value does not occur in the model.
-
setValueEnabled
Sets the enabled status of the first occurrence of a given value. This is a bound value state property.- Parameters:
value
- The value to enable or disable.newEnabled
- Whether the value should be enabled.- See Also:
-
isIndexEnabled
boolean isIndexEnabled(int index) Determines the enabled status of a given index.- Parameters:
index
- The index of the value for which the enabled status is to be determined.- Returns:
true
if the value at the given index is enabled, elsefalse
.
-
setIndexEnabled
void setIndexEnabled(int index, boolean newEnabled) Sets the enabled status of a given index. This is a bound value state property.- Parameters:
index
- The index of the value to enable or disable.newEnabled
- Whether the value at the given index should be enabled.- Throws:
IndexOutOfBoundsException
- if the given index is not within the range of the list.- See Also:
-
addListListener
Adds a list listener.- Specified by:
addListListener
in interfaceListListenable<V>
- Parameters:
listListener
- The list listener to add.
-
removeListListener
Removes a list listener.- Specified by:
removeListListener
in interfaceListListenable<V>
- Parameters:
listListener
- The list listener to remove.
-
addListSelectionListener
Adds a list selection listener.- Parameters:
selectionListener
- The selection listener to add.
-
removeListSelectionListener
Removes a list selection listener.- Parameters:
selectionListener
- The selection listener to remove.
-