Interface SelectionModel<T>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  SelectionModel.Multi<T>
      A selection model in which multiple items can be selected at the same time.
      static interface  SelectionModel.Single<T>
      A selection model in which at most one item can be selected at a time.
    • Method Detail

      • getSelectedItems

        java.util.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.

        Implementation note: the iteration order of the items in the returned set should be well-defined and documented by the implementing class.

        Returns:
        the items in the current selection, not null
      • getFirstSelectedItem

        java.util.Optional<T> getFirstSelectedItem()
        Get first selected data item.

        This is the same as SelectionModel.Single.getSelectedItem() in case of single selection and the first selected item from getSelectedItems() in case of multiselection.

        Returns:
        the first selected item.
      • select

        void select​(T item)
        Selects the given item. Depending on the implementation, may cause other items to be deselected. If the item is already selected, does nothing.
        Parameters:
        item - the item to select, not null
      • deselect

        void deselect​(T item)
        Deselects the given item. If the item is not currently selected, does nothing.
        Parameters:
        item - the item to deselect, not null
      • deselectAll

        void deselectAll()
        Deselects all currently selected items, if any.
      • isSelected

        default boolean isSelected​(T item)
        Returns whether the given item is currently selected.
        Parameters:
        item - the item to check, not null
        Returns:
        true if the item is selected, false otherwise
      • addSelectionListener

        com.vaadin.shared.Registration addSelectionListener​(SelectionListener<T> listener)
        Adds a generic listener to this selection model, accepting both single and multiselection events.
        Parameters:
        listener - the listener to add
        Returns:
        a registration handle for removing the listener