Class AbstractGridSingleSelectionModel<T>

java.lang.Object
com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>
com.vaadin.flow.component.grid.AbstractGridSingleSelectionModel<T>
Type Parameters:
T - the grid type
All Implemented Interfaces:
GridSelectionModel<T>, GridSingleSelectionModel<T>, DataGenerator<T>, SelectionModel<Grid<T>,T>, SelectionModel.Single<Grid<T>,T>, Serializable

public abstract class AbstractGridSingleSelectionModel<T> extends Grid.AbstractGridExtension<T> implements GridSingleSelectionModel<T>
Abstract implementation of a GridSingleSelectionModel.
Author:
Vaadin Ltd.
See Also:
  • Constructor Details

    • AbstractGridSingleSelectionModel

      public AbstractGridSingleSelectionModel(Grid<T> grid)
      Constructor for passing a reference of the grid to this implementation.
      Parameters:
      grid - reference to the grid for which this selection model is created
  • Method Details

    • selectFromClient

      public void selectFromClient(T item)
      Description copied from interface: GridSelectionModel
      Handles the selection of an item that originates from the client.
      Specified by:
      selectFromClient in interface GridSelectionModel<T>
      Parameters:
      item - the item being selected
    • select

      public void select(T item)
      Description copied from interface: SelectionModel
      Selects the given item. Depending on the implementation, may cause other items to be deselected. If the item is already selected, does nothing.
      Specified by:
      select in interface SelectionModel<Grid<T>,T>
      Specified by:
      select in interface SelectionModel.Single<Grid<T>,T>
      Parameters:
      item - the item to select, not null
    • deselectFromClient

      public void deselectFromClient(T item)
      Description copied from interface: GridSelectionModel
      Handles the deselection of an item that originates from the client.
      Specified by:
      deselectFromClient in interface GridSelectionModel<T>
      Parameters:
      item - the item being deselected
    • deselect

      public void deselect(T item)
      Description copied from interface: SelectionModel
      Deselects the given item. If the item is not currently selected, does nothing.
      Specified by:
      deselect in interface SelectionModel<Grid<T>,T>
      Parameters:
      item - the item to deselect, not null
    • isSelected

      public boolean isSelected(T item)
      Description copied from interface: SelectionModel
      Returns whether the given item is currently selected.
      Specified by:
      isSelected in interface SelectionModel<Grid<T>,T>
      Parameters:
      item - the item to check, not null
      Returns:
      true if the item is selected, false otherwise
    • getSelectedItem

      public Optional<T> getSelectedItem()
      Description copied from interface: SelectionModel.Single
      Returns the currently selected item, or an empty optional if no item is selected.
      Specified by:
      getSelectedItem in interface SelectionModel.Single<Grid<T>,T>
      Returns:
      an optional of the selected item if any, an empty optional otherwise
    • setDeselectAllowed

      public void setDeselectAllowed(boolean deselectAllowed)
      Description copied from interface: SelectionModel.Single
      Sets whether it's allowed to deselect the selected row through the UI. Deselection is allowed by default.
      Specified by:
      setDeselectAllowed in interface SelectionModel.Single<Grid<T>,T>
      Parameters:
      deselectAllowed - true if the selected row can be deselected without selecting another row instead; otherwise false.
    • isDeselectAllowed

      public boolean isDeselectAllowed()
      Description copied from interface: SelectionModel.Single
      Gets whether it's allowed to deselect the selected row through the UI.
      Specified by:
      isDeselectAllowed in interface SelectionModel.Single<Grid<T>,T>
      Returns:
      true if deselection is allowed; otherwise false
    • asSingleSelect

      public SingleSelect<Grid<T>,T> asSingleSelect()
      Description copied from interface: GridSingleSelectionModel
      Gets a wrapper to use this single selection model as a single select in Binder.
      Specified by:
      asSingleSelect in interface GridSingleSelectionModel<T>
      Returns:
      the single select wrapper
    • addSelectionListener

      public Registration addSelectionListener(SelectionListener<Grid<T>,T> listener)
      Description copied from interface: SelectionModel
      Adds a generic listener to this selection model, accepting both single and multiselection events.
      Specified by:
      addSelectionListener in interface SelectionModel<Grid<T>,T>
      Parameters:
      listener - the listener to add, not null
      Returns:
      a registration handle for removing the listener
    • addSingleSelectionListener

      public Registration addSingleSelectionListener(SingleSelectionListener<Grid<T>,T> listener)
      Description copied from interface: GridSingleSelectionModel
      Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
      Specified by:
      addSingleSelectionListener in interface GridSingleSelectionModel<T>
      Parameters:
      listener - the single selection listener, not null
      Returns:
      a registration for the listener
    • generateData

      public void generateData(T item, elemental.json.JsonObject jsonObject)
      Description copied from interface: DataGenerator
      Adds custom data for the given item to its serialized JsonObject representation. This JSON object will be sent to client-side DataProvider.
      Specified by:
      generateData in interface DataGenerator<T>
      Parameters:
      item - the data item being serialized
      jsonObject - the JSON object being sent to the client
    • remove

      protected void remove()
      Description copied from class: Grid.AbstractGridExtension
      Remove this extension from its target.
      Overrides:
      remove in class Grid.AbstractGridExtension<T>
    • fireSelectionEvent

      protected abstract void fireSelectionEvent(SelectionEvent<Grid<T>,T> event)
      Method for handling the firing of selection events.
      Parameters:
      event - the selection event to fire