- Type Parameters:
R
- the type of rows in the table model
- All Known Subinterfaces:
FilteredTableSelectionModel<R>
public interface TableSelectionModel<R>
A table selection model
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSelectedIndex
(int index) Selects the item atindex
void
addSelectedIndexes
(Collection<Integer> indexes) Adds these indexes to the selectionvoid
addSelectedItem
(R item) Adds the given item to the selectionvoid
addSelectedItems
(Collection<R> items) Adds the given items to the selectionvoid
addSelectedItems
(Predicate<R> predicate) Adds the items passing the predicate test to the selectionvoid
Clears the selectionint
boolean
isSelected
(R item) void
Moves all selected indexes down one index, wraps around.void
Moves all selected indexes up one index, wraps around.void
removeSelectedIndex
(int index) Removes the item atindex
from the selectionvoid
removeSelectedIndexes
(Collection<Integer> indexes) Removes the given indexes from the selectionvoid
removeSelectedItem
(R item) Remove the given item from the selectionvoid
removeSelectedItems
(Collection<R> items) Remove the given items from the selectionvoid
Selects all visible rowsTo prevent a selection change, add a listener throwing aCancelException
.int
void
setSelectedIndex
(int index) Clears the selection and selects the item atindex
void
setSelectedIndexes
(Collection<Integer> indexes) Selects the given indexesvoid
setSelectedItem
(R item) Sets the selected itemvoid
setSelectedItems
(Collection<R> items) Selects the given itemsvoid
setSelectedItems
(Predicate<R> predicate) Sets the items passing the predicate test as the selection
-
Method Details
-
selectionEmpty
StateObserver selectionEmpty()- Returns:
- a StateObserver indicating whether the selection is empty
-
selectionNotEmpty
StateObserver selectionNotEmpty()- Returns:
- a StateObserver indicating whether one or more items are selected
-
multipleSelection
StateObserver multipleSelection()- Returns:
- a StateObserver indicating whether multiple rows are selected
-
singleSelection
StateObserver singleSelection()- Returns:
- a StateObserver indicating whether a single row is selected
-
singleSelectionMode
State singleSelectionMode()- Returns:
- a State controlling the single selection mode of this selection model
-
selectionChangingEvent
EventObserver<?> selectionChangingEvent()To prevent a selection change, add a listener throwing aCancelException
.- Returns:
- an observer notified when the selection is about to change
-
selectionEvent
EventObserver<?> selectionEvent()- Returns:
- an observer notified each time the selection changes
-
selectedIndexEvent
EventObserver<Integer> selectedIndexEvent()- Returns:
- an observer notified each time the selected index changes
-
selectedIndexesEvent
EventObserver<List<Integer>> selectedIndexesEvent()- Returns:
- an observer notified each time the selected indexes change
-
selectedItemEvent
EventObserver<R> selectedItemEvent()- Returns:
- an observer notified each time the selected item changes
-
selectedItemsEvent
EventObserver<List<R>> 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 atindex
from 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
-