Class MultiSelectionEvent<T>
- java.lang.Object
-
- java.util.EventObject
-
- com.vaadin.data.HasValue.ValueChangeEvent<Set<T>>
-
- com.vaadin.event.selection.MultiSelectionEvent<T>
-
- Type Parameters:
T- the data type of the selection model
- All Implemented Interfaces:
HasUserOriginated,SelectionEvent<T>,Serializable
public class MultiSelectionEvent<T> extends HasValue.ValueChangeEvent<Set<T>> implements SelectionEvent<T>
Event fired when the the selection changes in aSelectionModel.Multi.- Since:
- 8.0
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description MultiSelectionEvent(AbstractMultiSelect<T> source, Set<T> oldSelection, boolean userOriginated)Creates a new event.MultiSelectionEvent(Component component, MultiSelect<T> source, Set<T> oldSelection, boolean userOriginated)Creates a new selection change event in a multiselect component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<T>getAddedSelection()Gets the items that were added to selection.Set<T>getAllSelectedItems()Gets all the currently selected items.Optional<T>getFirstSelectedItem()Get first selected data item.Set<T>getNewSelection()Gets the new selection.Set<T>getOldSelection()Gets the old selection.Set<T>getRemovedSelection()Gets the items that were removed from selection.MultiSelect<T>getSource()The multiselect on which the Event initially occurred.-
Methods inherited from class com.vaadin.data.HasValue.ValueChangeEvent
getComponent, getOldValue, getValue, isUserOriginated
-
Methods inherited from class java.util.EventObject
toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.vaadin.event.HasUserOriginated
isUserOriginated
-
-
-
-
Constructor Detail
-
MultiSelectionEvent
public MultiSelectionEvent(AbstractMultiSelect<T> source, Set<T> oldSelection, boolean userOriginated)
Creates a new event.- Parameters:
source- the listing component in which the selection changedoldSelection- the old set of selected itemsuserOriginated-trueif this event originates from the client,falseotherwise.
-
MultiSelectionEvent
public MultiSelectionEvent(Component component, MultiSelect<T> source, Set<T> oldSelection, boolean userOriginated)
Creates a new selection change event in a multiselect component.- Parameters:
component- the componentsource- the multiselect sourceoldSelection- the old set of selected itemsuserOriginated-trueif this event originates from the client,falseotherwise.
-
-
Method Detail
-
getNewSelection
public Set<T> getNewSelection()
Gets the new selection.The result is the current selection of the source
AbstractMultiSelectobject. So it's always exactly the same asAbstractMultiSelect.getValue()- Returns:
- a set of items selected after the selection was changed
- See Also:
HasValue.ValueChangeEvent.getValue()
-
getOldSelection
public Set<T> getOldSelection()
Gets the old selection.- Returns:
- a set of items selected before the selection was changed
-
getRemovedSelection
public Set<T> getRemovedSelection()
Gets the items that were removed from selection.This is just a convenience method for checking what was previously selected in
getOldSelection()but not selected anymore ingetNewSelection().- Returns:
- the items that were removed from selection
-
getAddedSelection
public Set<T> getAddedSelection()
Gets the items that were added to selection.This is just a convenience method for checking what is new selected in
getNewSelection()and wasn't selected ingetOldSelection().- Returns:
- the items that were removed from selection
-
getFirstSelectedItem
public Optional<T> getFirstSelectedItem()
Description copied from interface:SelectionEventGet first selected data item.This is the same as
SingleSelectionEvent.getSelectedItem()in case of single selection and the first selected item fromgetNewSelection()in case of multi selection.- Specified by:
getFirstSelectedItemin interfaceSelectionEvent<T>- Returns:
- the first selected item.
-
getSource
public MultiSelect<T> getSource()
The multiselect on which the Event initially occurred.- Overrides:
getSourcein classHasValue.ValueChangeEvent<Set<T>>- Returns:
- the multiselect on which the Event initially occurred.
-
getAllSelectedItems
public Set<T> getAllSelectedItems()
Gets all the currently selected items.This method applies more to multiselection - for single select it returns either an empty set or a set containing the only selected item.
This is the same as
HasValue.ValueChangeEvent.getValue().- Specified by:
getAllSelectedItemsin interfaceSelectionEvent<T>- Returns:
- return all the selected items, if any, never
null
-
-