com.vaadin.flow.component.listbox.
Class MultiSelectListBox<T>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.AbstractField<C,T>
-
- com.vaadin.flow.component.AbstractSinglePropertyField<C,VALUE>
-
- com.vaadin.flow.component.listbox.ListBoxBase<MultiSelectListBox<T>,T,Set<T>>
-
- com.vaadin.flow.component.listbox.MultiSelectListBox<T>
-
Type Parameters:
T
- the type of the items contained by this componentAll Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasComponents
,HasElement
,HasEnabled
,HasSize
,HasStyle
,HasValue<AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,Set<T>>,Set<T>>
,HasValueAndElement<AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,Set<T>>,Set<T>>
,HasItemComponents<T>
,HasDataView<T,Void,ListBoxDataView<T>>
,HasListDataView<T,ListBoxListDataView<T>>
,MultiSelect<MultiSelectListBox<T>,T>
,Serializable
public class MultiSelectListBox<T> extends ListBoxBase<MultiSelectListBox<T>,T,Set<T>> implements MultiSelect<MultiSelectListBox<T>,T>
Server-side component for the
vaadin-list-box
element with multi-selection.Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
AbstractField.ComponentValueChangeEvent<C extends Component,V>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.data.binder.HasItemComponents
HasItemComponents.ItemComponent<T>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
-
-
Constructor Summary
Constructors Constructor Description MultiSelectListBox()
Creates a new list box component with multi-selection.
-
Method Summary
All Methods Modifier and Type Method Description Registration
addSelectionListener(MultiSelectionListener<MultiSelectListBox<T>,T> listener)
Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
Set<T>
getSelectedItems()
Returns an immutable set of the currently selected items.
void
setValue(Set<T> value)
Sets the value of this component.
void
updateSelection(Set<T> addedItems, Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
protected boolean
valueEquals(Set<T> value1, Set<T> value2)
Compares two value instances to each other to determine whether they are equal.
-
Methods inherited from class com.vaadin.flow.component.listbox.ListBoxBase
getDataProvider, getGenericDataView, getItemEnabledProvider, getItemId, getItemLabelGenerator, getItemRenderer, getListDataView, onAttach, onDetach, onEnabledStateChanged, setDataProvider, setItemEnabledProvider, setItemLabelGenerator, setItems, setItems, setItems, setItems, setRenderer, setRequiredIndicatorVisible
-
Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
-
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, scrollIntoView, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
Methods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.data.binder.HasItemComponents
addComponents, getItemPosition, prependComponents
-
Methods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItems, setItems
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getOptionalValue, isEmpty
-
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
-
Methods inherited from interface com.vaadin.flow.data.selection.MultiSelect
deselect, deselect, deselectAll, getEmptyValue, getValue, isSelected, select, select
-
-
-
-
Method Detail
-
setValue
public void setValue(Set<T> value)
Sets the value of this component. If the new value is not equal to the previous value, fires a value change event.
The component doesn't accept
null
values. The value of multi select list box without any selected items is an empty set. You can use theHasValue.clear()
method to set the empty value.Specified by:
setValue
in interfaceHasValue<AbstractField.ComponentValueChangeEvent<MultiSelectListBox<T>,Set<T>>,Set<T>>
Specified by:
setValue
in interfaceMultiSelect<MultiSelectListBox<T>,T>
Overrides:
setValue
in classAbstractField<MultiSelectListBox<T>,Set<T>>
Parameters:
value
- the new value to set, notnull
Throws:
NullPointerException
- if value isnull
-
updateSelection
public void updateSelection(Set<T> addedItems, Set<T> removedItems)
Description copied from interface:
MultiSelect
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.
Specified by:
updateSelection
in interfaceMultiSelect<MultiSelectListBox<T>,T>
Parameters:
addedItems
- the items to add, notnull
removedItems
- the items to remove, notnull
-
getSelectedItems
public 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.There are no guarantees of the iteration order of the returned set of items.
Specified by:
getSelectedItems
in interfaceMultiSelect<MultiSelectListBox<T>,T>
Returns:
the items in the current selection, not
null
-
addSelectionListener
public Registration addSelectionListener(MultiSelectionListener<MultiSelectListBox<T>,T> listener)
Description copied from interface:
MultiSelect
Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
Specified by:
addSelectionListener
in interfaceMultiSelect<MultiSelectListBox<T>,T>
Parameters:
listener
- the value change listener, notnull
Returns:
a registration for the listener
-
valueEquals
protected boolean valueEquals(Set<T> value1, Set<T> value2)
Compares two value instances to each other to determine whether they are equal. Equality is used to determine whether to update internal state and fire an event when
AbstractField.setValue(Object)
orAbstractField.setModelValue(Object, boolean)
is called. Subclasses can override this method to define an alternative comparison method instead ofObject.equals(Object)
.Overrides:
valueEquals
in classAbstractField<MultiSelectListBox<T>,Set<T>>
Parameters:
value1
- the first set of instancevalue2
- the second set of instanceReturns:
true
if sets are equal in size and also the items; otherwisefalse
-
-