com.vaadin.event.selection.
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 modelAll Implemented Interfaces:
public class MultiSelectionEvent<T> extends HasValue.ValueChangeEvent<Set<T>> implements SelectionEvent<T>
Event fired when the the selection changes in a
SelectionModel.Multi
.Since:
8.0
Author:
Vaadin Ltd
See Also:
-
-
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 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
-true
if this event originates from the client,false
otherwise.
-
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
-true
if this event originates from the client,false
otherwise.
-
-
Method Detail
-
getNewSelection
public Set<T> getNewSelection()
Gets the new selection.
The result is the current selection of the source
AbstractMultiSelect
object. So it's always exactly the same asAbstractMultiSelect.getValue()
Returns:
a set of items selected after the selection was changed
See Also:
-
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:
SelectionEvent
Get 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:
getFirstSelectedItem
in interfaceSelectionEvent<T>
Returns:
the first selected item.
-
getSource
public MultiSelect<T> getSource()
The multiselect on which the Event initially occurred.
Overrides:
getSource
in 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:
getAllSelectedItems
in interfaceSelectionEvent<T>
Returns:
return all the selected items, if any, never
null
-
-