com.vaadin.flow.data.selection.

Class MultiSelectionEvent<C extends Component,T>

Type Parameters:

C - the selection component type

T - the type of the selected item

All Implemented Interfaces:

HasValue.ValueChangeEvent<Set<T>>, SelectionEvent<C,T>, Serializable

public class MultiSelectionEvent<C extends Component,T> extends AbstractField.ComponentValueChangeEvent<C,Set<T>> implements SelectionEvent<C,T>

Fired when the selection changes in a listing component that supports multiple item selection.

Since:

1.0.

Author:

Vaadin Ltd

See Also:

  • Constructor Details

    • MultiSelectionEvent

      public MultiSelectionEvent(C listing, HasValue<AbstractField.ComponentValueChangeEvent<C,Set<T>>,Set<T>> source, Set<T> oldSelection, boolean userOriginated)

      Creates a new multi selection change event in a component.

      Parameters:

      listing - the listing component where the event originated

      source - the single select source

      oldSelection - the item that was previously selected

      userOriginated - true if this event originates from the client, false otherwise.

  • Method Details

    • 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.

      Specified by:

      getFirstSelectedItem in interface SelectionEvent<C extends Component,T>

      Returns:

      the first selected item.

    • getAllSelectedItems

      public Set<T> getAllSelectedItems()

      Description copied from interface: SelectionEvent

      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.

      Specified by:

      getAllSelectedItems in interface SelectionEvent<C extends Component,T>

      Returns:

      return all the selected items, if any, never null

    • getValue

      public Set<T> getValue()

      Gets the current selection.

      Specified by:

      getValue in interface HasValue.ValueChangeEvent<C extends Component>

      Overrides:

      getValue in class AbstractField.ComponentValueChangeEvent<C extends Component,Set<T>>

      Returns:

      an unmodifiable set of items selected after the selection was changed

    • getOldSelection

      public Set<T> getOldSelection()

      Gets the old selection.

      Returns:

      an unmodifiable 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 in getValue().

      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 getValue() and wasn't selected in getOldSelection().

      Returns:

      the items that were removed from selection