- Type Parameters:
R- the type of rows in the table model
public interface TableSelectionModel<R>
A table selection model
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddSelectedIndex(int index) Selects the item atindexvoidaddSelectedIndexes(Collection<Integer> indexes) Adds these indexes to the selectionvoidaddSelectedItem(R item) Adds the given item to the selectionvoidaddSelectedItems(Collection<R> items) Adds the given items to the selectionvoidaddSelectedItems(Predicate<R> predicate) Adds the items passing the predicate test to the selectionvoidClears the selectionintbooleanisSelected(R item) voidMoves all selected indexes down one index, wraps around.voidMoves all selected indexes up one index, wraps around.is.codion.common.state.StateObservervoidremoveSelectedIndex(int index) Removes the item atindexfrom the selectionvoidremoveSelectedIndexes(Collection<Integer> indexes) Removes the given indexes from the selectionvoidremoveSelectedItem(R item) Remove the given item from the selectionvoidremoveSelectedItems(Collection<R> items) Remove the given items from the selectionvoidSelects all visible rowsis.codion.common.event.EventObserver<Integer>is.codion.common.event.EventObserver<R>is.codion.common.event.EventObserver<?>To prevent a selection change, add a listener throwing aCancelException.intis.codion.common.state.StateObserveris.codion.common.event.EventObserver<?>is.codion.common.state.StateObservervoidsetSelectedIndex(int index) Clears the selection and selects the item atindexvoidsetSelectedIndexes(Collection<Integer> indexes) Selects the given indexesvoidsetSelectedItem(R item) Sets the selected itemvoidsetSelectedItems(Collection<R> items) Selects the given itemsvoidsetSelectedItems(Predicate<R> predicate) Sets the items passing the predicate test as the selectionis.codion.common.state.StateObserveris.codion.common.state.State
-
Method Details
-
selectionEmpty
is.codion.common.state.StateObserver selectionEmpty()- Returns:
- a StateObserver indicating whether the selection is empty
-
selectionNotEmpty
is.codion.common.state.StateObserver selectionNotEmpty()- Returns:
- a StateObserver indicating whether one or more items are selected
-
multipleSelection
is.codion.common.state.StateObserver multipleSelection()- Returns:
- a StateObserver indicating whether multiple rows are selected
-
singleSelection
is.codion.common.state.StateObserver singleSelection()- Returns:
- a StateObserver indicating whether a single row is selected
-
singleSelectionMode
is.codion.common.state.State singleSelectionMode()- Returns:
- a State controlling the single selection mode of this selection model
-
selectionChangingEvent
is.codion.common.event.EventObserver<?> selectionChangingEvent()To prevent a selection change, add a listener throwing aCancelException.- Returns:
- an observer notified when the selection is about to change
-
selectionEvent
is.codion.common.event.EventObserver<?> selectionEvent()- Returns:
- an observer notified each time the selection changes
-
selectedIndexEvent
is.codion.common.event.EventObserver<Integer> selectedIndexEvent()- Returns:
- an observer notified each time the selected index changes
-
selectedIndexesEvent
- Returns:
- an observer notified each time the selected indexes change
-
selectedItemEvent
is.codion.common.event.EventObserver<R> selectedItemEvent()- Returns:
- an observer notified each time the selected item changes
-
selectedItemsEvent
- Returns:
- an observer notified each time the selected items change
-
moveSelectionDown
void moveSelectionDown()Moves all selected indexes down one index, wraps around. If the selection is empty the first item in this model is selected.- See Also:
-
moveSelectionUp
void moveSelectionUp()Moves all selected indexes up one index, wraps around. If the selection is empty the last item in this model is selected.- See Also:
-
getSelectedIndex
int getSelectedIndex()- Returns:
- the index of the selected row, -1 if none is selected and the lowest index if more than one row is selected
-
addSelectedIndex
void addSelectedIndex(int index) Selects the item atindex- Parameters:
index- the index
-
removeSelectedIndex
void removeSelectedIndex(int index) Removes the item atindexfrom the selection- Parameters:
index- the index
-
removeSelectedIndexes
Removes the given indexes from the selection- Parameters:
indexes- the indexes
-
setSelectedIndex
void setSelectedIndex(int index) Clears the selection and selects the item atindex- Parameters:
index- the index
-
setSelectedIndexes
Selects the given indexes- Parameters:
indexes- the indexes to select
-
getSelectedIndexes
- Returns:
- the selected indexes, an empty list if selection is empty
-
selectAll
void selectAll()Selects all visible rows- See Also:
-
setSelectedItems
Sets the items passing the predicate test as the selection- Parameters:
predicate- the predicate
-
addSelectedItems
Adds the items passing the predicate test to the selection- Parameters:
predicate- the predicate
-
addSelectedIndexes
Adds these indexes to the selection- Parameters:
indexes- the indexes to add to the selection
-
selectionCount
int selectionCount()- Returns:
- the number of selected indexes in the underlying selection model.
-
setSelectedItems
Selects the given items- Parameters:
items- the items to select
-
getSelectedItems
- Returns:
- a list containing the selected items
-
getSelectedItem
R getSelectedItem()- Returns:
- the item at the lowest selected index, null if none is selected
-
isSelected
- Parameters:
item- the item- Returns:
- true if the item is selected
-
setSelectedItem
Sets the selected item- Parameters:
item- the item to select
-
addSelectedItem
Adds the given item to the selection- Parameters:
item- the item to add to the selection
-
addSelectedItems
Adds the given items to the selection- Parameters:
items- the items to add to the selection
-
removeSelectedItem
Remove the given item from the selection- Parameters:
item- the item to remove from the selection
-
removeSelectedItems
Remove the given items from the selection- Parameters:
items- the items to remove from the selection
-
selectedItem
- Returns:
- the selected item, or an empty Optional in case the selection is empty
-
clearSelection
void clearSelection()Clears the selection
-