com.vaadin.flow.data.selection.
Interface MultiSelect<C extends Component,T>
-
Type Parameters:
C
- the selection component typeT
- the type of the items to selectAll Superinterfaces:
HasElement, HasEnabled, HasValue<AbstractField.ComponentValueChangeEvent<C,Set<T>>,Set<T>>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<C,Set<T>>,Set<T>>, Serializable
All Known Implementing Classes:
public interface MultiSelect<C extends Component,T> extends HasValueAndElement<AbstractField.ComponentValueChangeEvent<C,Set<T>>,Set<T>>
Multi selection component which allows to select and deselect multiple items.
Since:
1.0
Author:
Vaadin Ltd
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
-
-
Method Summary
All Methods Modifier and Type Method and Description Registration
addSelectionListener(MultiSelectionListener<C,T> listener)
Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
default void
deselect(Iterable<T> items)
Removes the given items from the set of currently selected items.
default void
deselect(T... items)
Removes the given items from the set of currently selected items.
default void
deselectAll()
Deselects all currently selected items.
default Set<T>
getEmptyValue()
MultiSelect empty value should always be an empty set by default and not
null
.Set<T>
getSelectedItems()
Returns an immutable set of the currently selected items.
default Set<T>
getValue()
Returns the current value of this object.
default boolean
isSelected(T item)
Returns whether the given item is currently selected.
default void
select(Iterable<T> items)
Adds the given items to the set of currently selected items.
default void
select(T... items)
Adds the given items to the set of currently selected items.
default void
setValue(Set<T> value)
Sets the value of this object.
void
updateSelection(Set<T> addedItems, Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
-
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
-
Methods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getOptionalValue, isEmpty
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
-
-
-
Method Detail
-
select
default void select(T... items)
Adds the given items to the set of currently selected items.
By default this does not clear any previous selection. To do that, use
deselectAll()
.If the all the items were already selected, this is a NO-OP.
This is a short-hand for
updateSelection(Set, Set)
with nothing to deselect.Parameters:
items
- to add to selection, notnull
-
deselect
default void deselect(T... items)
Removes the given items from the set of currently selected items.
If the none of the items were selected, this is a NO-OP.
This is a short-hand for
updateSelection(Set, Set)
with nothing to select.Parameters:
items
- to remove from selection, notnull
-
select
default void select(Iterable<T> items)
Adds the given items to the set of currently selected items.
By default this does not clear any previous selection. To do that, use
deselectAll()
.If the all the items were already selected, this is a NO-OP.
This is a short-hand for
updateSelection(Set, Set)
with nothing to deselect.Parameters:
items
- to add to selection, notnull
-
deselect
default void deselect(Iterable<T> items)
Removes the given items from the set of currently selected items.
If the none of the items were selected, this is a NO-OP.
This is a short-hand for
updateSelection(Set, Set)
with nothing to select.Parameters:
items
- to remove from selection, notnull
-
updateSelection
void updateSelection(Set<T> addedItems, Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
If all the added items were already selected and the removed items were not selected, this is a NO-OP.
Duplicate items (in both add and remove sets) are ignored.
Parameters:
addedItems
- the items to add, notnull
removedItems
- the items to remove, notnull
-
getSelectedItems
Set<T> 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
-
deselectAll
default void deselectAll()
Deselects all currently selected items.
-
isSelected
default boolean isSelected(T item)
Returns whether the given item is currently selected.
Parameters:
item
- the item to check, notnull
Returns:
true
if the item is selected,false
otherwise
-
addSelectionListener
Registration addSelectionListener(MultiSelectionListener<C,T> listener)
Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
Parameters:
listener
- the value change listener, notnull
Returns:
a registration for the listener
-
getEmptyValue
default Set<T> getEmptyValue()
MultiSelect empty value should always be an empty set by default and not
null
.Specified by:
getEmptyValue
in interfaceHasValue<AbstractField.ComponentValueChangeEvent<C extends Component,Set<T>>,Set<T>>
Returns:
An empty set, not
null
-
getValue
default Set<T> getValue()
Description copied from interface:
HasValue
Returns the current value of this object.
Implementation note: the implementing class should document whether null values may be returned or not, and override
HasValue.getEmptyValue()
if the empty value is notnull
.
-
setValue
default void setValue(Set<T> value)
Description copied from interface:
HasValue
Sets the value of this object. If the new value is not equal to
getValue()
, fires a value change event. May throwIllegalArgumentException
if the value is not acceptable.Implementation note: the implementing class should document whether null values are accepted or not, and override
HasValue.getEmptyValue()
if the empty value is notnull
.
-
-