com.vaadin.flow.data.selection.
Interface SelectionModel<C extends Component,T>
Type Parameters:
T
- the type of the items to select
C
- the component type
All Superinterfaces:
All Known Subinterfaces:
GridMultiSelectionModel<T>
, GridSelectionModel<T>
, GridSingleSelectionModel<T>
, SelectionModel.Multi<C,
, SelectionModel.Single<C,
All Known Implementing Classes:
AbstractGridMultiSelectionModel
, AbstractGridSingleSelectionModel
, GridNoneSelectionModel
Models the selection logic of a Listing
component. Determines how
items can be selected and deselected.
Since:
1.0.
Author:
Vaadin Ltd
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
SelectionModel.Multi<C extends Component,
T> A selection model in which multiple items can be selected at the same time.
static interface
SelectionModel.Single<C extends Component,
T> A selection model in which at most one item can be selected at a time.
-
Method Summary
Modifier and TypeMethodDescriptionaddSelectionListener
(SelectionListener<C, T> listener) Adds a generic listener to this selection model, accepting both single and multiselection events.
void
Deselects the given item.
void
Deselects all currently selected items, if any.
Get first selected data item.
Returns an immutable set of the currently selected items.
default boolean
isSelected
(T item) Returns whether the given item is currently selected.
void
Selects the given item.
-
Method Details
-
getSelectedItems
Returns an immutable set of the currently selected items. It is safe to invoke other
SelectionModel
methods while iterating over the set.Implementation note: the iteration order of the items in the returned set should be well-defined and documented by the implementing class.
Returns:
the items in the current selection, not null
-
getFirstSelectedItem
Get first selected data item.
This is the same as
SelectionModel.Single.getSelectedItem()
in case of single selection and the first selected item fromgetSelectedItems()
in case of multiselection.Returns:
the first selected item.
-
select
Selects the given item. Depending on the implementation, may cause other items to be deselected. If the item is already selected, does nothing.
Parameters:
item
- the item to select, not null -
deselect
Deselects the given item. If the item is not currently selected, does nothing.
Parameters:
item
- the item to deselect, not null -
deselectAll
void deselectAll()Deselects all currently selected items, if any.
-
isSelected
Returns whether the given item is currently selected.
Parameters:
item
- the item to check, not nullReturns:
true
if the item is selected,false
otherwise -
addSelectionListener
Adds a generic listener to this selection model, accepting both single and multiselection events.
Parameters:
listener
- the listener to add, notnull
Returns:
a registration handle for removing the listener
-