- Type Parameters:
T- the type of items
- All Superinterfaces:
SingleSelection<T>
- All Known Subinterfaces:
FilterListSelection<T>
When multiple items are selected, the inherited SingleSelection
index() and SingleSelection.item() methods represent the minimum selected index
and its corresponding item. If the selection is empty, index() returns null
and SingleSelection.item() returns null.
Examples:
- Selected indexes [2, 5, 8] →
index().get()returns 2,item().get()returns item at index 2 - Selected indexes [7] →
index().get()returns 7,item().get()returns item at index 7 - No selection →
index().get()returns null,item().get()returns null
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceControls whether selection change grouping is enabledstatic interfaceProvides access to indexed itemsstatic interfaceManages the selected indexes.static interfaceThe selected indexes aMultiSelectionis a view over, the one part of a selection that differs per toolkit.static interfaceManages the selected items. -
Method Summary
Modifier and TypeMethodDescriptionObserver<?> Returns an observer notified on every change to the selected indexes, grouped or not, the raw stream of changes ajavax.swing.event.ListSelectionListenerwould see.intcount()grouping()MultiSelection.Groupingcontrols whether the subsequent selection events should be grouped and not triggered individuallyindex()Returns theValuecontrolling the selected index.indexes()Returns theMultiSelection.Indexescontrolling the selected indexes.items()Returns theMultiSelection.Itemscontrolling the selected items.multiple()static <T> MultiSelection<T> multiSelection(MultiSelection.IndexedItems<T> items) static <T> MultiSelection<T> multiSelection(MultiSelection.IndexedItems<T> items, MultiSelection.IndexStore store) voidSelects all itemssingle()Methods inherited from interface is.codion.common.model.selection.SingleSelection
changing, clear, item, present
-
Method Details
-
multiple
ObservableState multiple()- Returns:
- an
ObservableStateindicating whether multiple items are selected
-
single
ObservableState single()- Returns:
- an
ObservableStateindicating whether a single item is selected
-
singleSelection
State singleSelection()- Returns:
- the
Statecontrolling whether single selection mode is enabled
-
index
Returns theValuecontrolling the selected index.In a multi-selection context, this represents the minimum selected index. When multiple items are selected, this value tracks the lowest index among the selected items. The value's
get()method returns null if the selection is empty.- Returns:
- the
Valuecontrolling the minimum selected index, whoseget()method returns null if selection is empty
-
indexes
MultiSelection.Indexes indexes()Returns the
MultiSelection.Indexescontrolling the selected indexes.Notifies only when the selected indexes change.
- Returns:
- the
MultiSelection.Indexescontrolling the selected indexes
-
items
MultiSelection.Items<T> items()Returns the
MultiSelection.Itemscontrolling the selected items.Notifies when the selected items change, and when an instance a selected index refers to is replaced, as happens when the items are refreshed or replaced, the replacement being the same item by
equals()but not the same object.indexes()notifies only when the indexes change.- Returns:
- the
MultiSelection.Itemscontrolling the selected items
-
selectAll
void selectAll()Selects all items- See Also:
-
count
int count()- Returns:
- the number of selected items.
-
grouping
MultiSelection.Grouping grouping()MultiSelection.Groupingcontrols whether the subsequent selection events should be grouped and not triggered individuallyNote that grouping is not reentrant,
grouping().set(false)ends the group whether or not it opened one. Code which may run inside a group of its caller's making saves and restores the state:boolean wasGrouping = selection.grouping().is(); selection.grouping().set(true); try { // mutate the selection } finally { selection.grouping().set(wasGrouping); }- Returns:
- the
MultiSelection.Groupinginstance
-
adjusting
Observer<?> adjusting()Returns an observer notified on every change to the selected indexes, grouped or not, the raw stream of changes a
javax.swing.event.ListSelectionListenerwould see.index(),indexes(),SingleSelection.item()anditems()notify once a group of changes has ended, this observer notifies as the changes happen, so a listener may observe intermediate states, such as the momentarily empty selection while a refresh restores it. Suited to a live status display, not to anything acting on the selection.- Returns:
- an observer notified each time the selected indexes change, grouped or not
- See Also:
-
multiSelection
- Type Parameters:
T- the item type- Parameters:
items- the indexed items- Returns:
- a default
MultiSelectionimplementation
-
multiSelection
static <T> MultiSelection<T> multiSelection(MultiSelection.IndexedItems<T> items, MultiSelection.IndexStore store) - Type Parameters:
T- the item type- Parameters:
items- the indexed itemsstore- the store keeping the selected indexes- Returns:
- a default
MultiSelectionimplementation over the given store - See Also:
-