Class MultiSelectionEvent<C extends com.vaadin.flow.component.Component,T>

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<C>
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,Set<T>>
com.vaadin.flow.data.selection.MultiSelectionEvent<C,T>
Type Parameters:
C - the selection component type
T - the type of the selected item
All Implemented Interfaces:
com.vaadin.flow.component.HasValue.ValueChangeEvent<Set<T>>, SelectionEvent<C,T>, Serializable

public class MultiSelectionEvent<C extends com.vaadin.flow.component.Component,T> extends com.vaadin.flow.component.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:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiSelectionEvent(C listing, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,Set<T>>,Set<T>> source, Set<T> oldSelection, boolean userOriginated)
    Creates a new multi selection change event in a component.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the items that were added to selection.
    Gets all the currently selected items.
    Get first selected data item.
    Gets the old selection.
    Gets the items that were removed from selection.
    Gets the current selection.

    Methods inherited from class com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent

    getHasValue, getOldValue, toString

    Methods inherited from class com.vaadin.flow.component.ComponentEvent

    getSource, isFromClient, unregisterListener

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.HasValue.ValueChangeEvent

    isFromClient

    Methods inherited from interface com.vaadin.flow.data.selection.SelectionEvent

    getSource, isFromClient
  • Constructor Details

    • MultiSelectionEvent

      public MultiSelectionEvent(C listing, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.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 com.vaadin.flow.component.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 com.vaadin.flow.component.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 com.vaadin.flow.component.HasValue.ValueChangeEvent<C extends com.vaadin.flow.component.Component>
      Overrides:
      getValue in class com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.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