- Type Parameters:
R- the type of rows in the table model
public interface TableSelectionModel<R>
A table selection model
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddBeforeSelectionChangeListener(Runnable listener) To prevent a selection change, add a listener throwing aCancelException.voidaddSelectedIndex(int index) Selects the item atindexvoidaddSelectedIndexes(Collection<Integer> indexes) Adds these indexes to the selectionvoidaddSelectedIndexesListener(Consumer<List<Integer>> listener) voidaddSelectedIndexListener(Consumer<Integer> listener) voidaddSelectedItem(R item) Adds the given item to the selectionvoidaddSelectedItemListener(Consumer<R> listener) voidaddSelectedItems(Collection<R> items) Adds the given items to the selectionvoidaddSelectedItems(Predicate<R> predicate) Adds the items passing the predicate test to the selectionvoidaddSelectedItemsListener(Consumer<List<R>> listener) voidaddSelectionListener(Runnable listener) voidClears 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.StateObservervoidremoveBeforeSelectionChangeListener(Runnable listener) voidremoveSelectedIndex(int index) Removes the item atindexfrom the selectionvoidremoveSelectedIndexes(Collection<Integer> indexes) Removes the given indexes from the selectionvoidremoveSelectedIndexesListener(Consumer<List<Integer>> listener) voidremoveSelectedIndexListener(Consumer<Integer> listener) voidremoveSelectedItem(R item) Remove the given item from the selectionvoidremoveSelectedItemListener(Consumer<R> listener) voidremoveSelectedItems(Collection<R> items) Remove the given items from the selectionvoidremoveSelectedItemsListener(Consumer<List<R>> listener) voidremoveSelectionListener(Runnable listener) voidSelects all visible rowsintis.codion.common.state.StateObserveris.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
-
addBeforeSelectionChangeListener
To prevent a selection change, add a listener throwing aCancelException.- Parameters:
listener- a listener to be notified before the selection changes
-
removeBeforeSelectionChangeListener
- Parameters:
listener- the listener to remove
-
addSelectionListener
- Parameters:
listener- a listener to be notified each time the selection changes
-
removeSelectionListener
- Parameters:
listener- the listener to remove
-
addSelectedIndexListener
- Parameters:
listener- a listener to be notified each time the selected index changes
-
removeSelectedIndexListener
- Parameters:
listener- the listener to remove
-
addSelectedIndexesListener
- Parameters:
listener- a listener to be notified each time the selected indexes change
-
removeSelectedIndexesListener
- Parameters:
listener- the listener to remove
-
addSelectedItemListener
- Parameters:
listener- a listener to be notified each time the selected item changes
-
removeSelectedItemListener
- Parameters:
listener- the listener to remove
-
addSelectedItemsListener
- Parameters:
listener- a listener to be notified each time the selected items change
-
removeSelectedItemsListener
- Parameters:
listener- the listener to remove
-
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
-