Class AbstractGridMultiSelectionModel<T>

java.lang.Object
io.jmix.groupgridflowui.kit.vaadin.grid.Grid.AbstractGridExtension<T>
io.jmix.groupgridflowui.kit.vaadin.grid.AbstractGridMultiSelectionModel<T>
Type Parameters:
T - the grid type
All Implemented Interfaces:
com.vaadin.flow.data.provider.DataGenerator<T>, com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>, com.vaadin.flow.data.selection.SelectionModel.Multi<Grid<T>,T>, GridMultiSelectionModel<T>, GridSelectionModel<T>, Serializable

public abstract class AbstractGridMultiSelectionModel<T> extends Grid.AbstractGridExtension<T> implements GridMultiSelectionModel<T>
Abstract implementation of a GridMultiSelectionModel.
See Also:
  • Constructor Details

    • AbstractGridMultiSelectionModel

      public AbstractGridMultiSelectionModel(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

    • remove

      protected void remove()
      Description copied from class: Grid.AbstractGridExtension
      Remove this extension from its target.
      Overrides:
      remove in class Grid.AbstractGridExtension<T>
    • 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
    • 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
    • getSelectedItems

      public Set<T> getSelectedItems()
      Specified by:
      getSelectedItems in interface com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>
    • getSelectedItemIds

      protected Set<Object> getSelectedItemIds()
      Returns an unmodifiable view of the selected item ids.

      Exposed to be overridden within subclasses.

      The returned Set may be a direct view of the internal data structures of this class. A defensive copy should be made by callers when iterating over this Set and modifying the selection during iteration to avoid ConcurrentModificationExceptions.

      Returns:
      An unmodifiable view of the selected item ids. Updates in the selection may or may not be directly reflected in the Set.
    • getFirstSelectedItem

      public Optional<T> getFirstSelectedItem()
      Specified by:
      getFirstSelectedItem in interface com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>
      Specified by:
      getFirstSelectedItem in interface com.vaadin.flow.data.selection.SelectionModel.Multi<Grid<T>,T>
    • select

      public void select(T item)
      Specified by:
      select in interface com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>
      Specified by:
      select in interface com.vaadin.flow.data.selection.SelectionModel.Multi<Grid<T>,T>
    • deselect

      public void deselect(T item)
      Specified by:
      deselect in interface com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>
      Specified by:
      deselect in interface com.vaadin.flow.data.selection.SelectionModel.Multi<Grid<T>,T>
    • selectAll

      public void selectAll()
      Specified by:
      selectAll in interface com.vaadin.flow.data.selection.SelectionModel.Multi<Grid<T>,T>
    • deselectAll

      public void deselectAll()
      Specified by:
      deselectAll in interface com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>
    • updateSelection

      public void updateSelection(Set<T> addedItems, Set<T> removedItems)
      Specified by:
      updateSelection in interface com.vaadin.flow.data.selection.SelectionModel.Multi<Grid<T>,T>
    • isSelected

      public boolean isSelected(T item)
      Specified by:
      isSelected in interface com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>
    • asMultiSelect

      public com.vaadin.flow.data.selection.MultiSelect<Grid<T>,T> asMultiSelect()
      Description copied from interface: GridMultiSelectionModel
      Gets a wrapper to use this multiselection model as a multiselect in Binder.
      Specified by:
      asMultiSelect in interface GridMultiSelectionModel<T>
      Returns:
      the multiselect wrapper
    • addSelectionListener

      public com.vaadin.flow.shared.Registration addSelectionListener(com.vaadin.flow.data.selection.SelectionListener<Grid<T>,T> listener)
      Specified by:
      addSelectionListener in interface com.vaadin.flow.data.selection.SelectionModel<Grid<T>,T>
    • addMultiSelectionListener

      public com.vaadin.flow.shared.Registration addMultiSelectionListener(com.vaadin.flow.data.selection.MultiSelectionListener<Grid<T>,T> listener)
      Description copied from interface: GridMultiSelectionModel
      Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
      Specified by:
      addMultiSelectionListener in interface GridMultiSelectionModel<T>
      Parameters:
      listener - the multi selection listener, not null
      Returns:
      a registration for the listener
    • addClientItemToggleListener

      public com.vaadin.flow.shared.Registration addClientItemToggleListener(com.vaadin.flow.component.ComponentEventListener<ClientItemToggleEvent<T>> listener)
      Description copied from interface: GridMultiSelectionModel
      Adds a client item toggle listener that will be called when the user toggles the selection state of an item on the client-side.

      This event follows MultiSelectionEvent and provides details about the item that was toggled, its new selection state, and whether the shift key was pressed during the selection. This can be helpful for implementing features like range selection.

      Specified by:
      addClientItemToggleListener in interface GridMultiSelectionModel<T>
      Parameters:
      listener - the client item toggle listener, not null
      Returns:
      a registration for the listener
    • setSelectAllCheckboxVisibility

      public void setSelectAllCheckboxVisibility(GridMultiSelectionModel.SelectAllCheckboxVisibility selectAllCheckBoxVisibility)
      Description copied from interface: GridMultiSelectionModel
      Sets the select all checkbox visibility mode.

      The default value is GridMultiSelectionModel.SelectAllCheckboxVisibility.DEFAULT, which means that the checkbox is only visible if the grid's data provider is in-memory.

      The select all checkbox will never be shown if the Grid uses lazy loading with unknown item count, i.e. no items count query provided to it, and even setting GridMultiSelectionModel.SelectAllCheckboxVisibility.VISIBLE won't make it visible.

      Specified by:
      setSelectAllCheckboxVisibility in interface GridMultiSelectionModel<T>
      Parameters:
      selectAllCheckBoxVisibility - the visiblity mode to use
      See Also:
    • getSelectAllCheckboxVisibility

      public GridMultiSelectionModel.SelectAllCheckboxVisibility getSelectAllCheckboxVisibility()
      Description copied from interface: GridMultiSelectionModel
      Gets the current mode for the select all checkbox visibility.
      Specified by:
      getSelectAllCheckboxVisibility in interface GridMultiSelectionModel<T>
      Returns:
      the select all checkbox visibility mode
      See Also:
    • isSelectAllCheckboxVisible

      public boolean isSelectAllCheckboxVisible()
      Description copied from interface: GridMultiSelectionModel
      Returns whether the select all checkbox will be visible with the current setting of GridMultiSelectionModel.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility) and the type of data set to the Grid (in-memory or lazy).

      The select all checkbox will never be shown if the Grid uses lazy loading with unknown item count, meaning that no count callback has been provided. It will also not be shown if the grid is configured to use conditional selection via Grid.setItemSelectableProvider(SerializablePredicate)

      Specified by:
      isSelectAllCheckboxVisible in interface GridMultiSelectionModel<T>
      Returns:
      true if the checkbox will be visible with the current settings
      See Also:
    • generateData

      public void generateData(T item, elemental.json.JsonObject jsonObject)
      Specified by:
      generateData in interface com.vaadin.flow.data.provider.DataGenerator<T>
    • setSelectionColumnFrozen

      public void setSelectionColumnFrozen(boolean frozen)
      Description copied from interface: GridMultiSelectionModel
      Sets the selection column's frozen state.
      Specified by:
      setSelectionColumnFrozen in interface GridMultiSelectionModel<T>
      Parameters:
      frozen - whether to freeze or unfreeze the selection column
    • isSelectionColumnFrozen

      public boolean isSelectionColumnFrozen()
      Description copied from interface: GridMultiSelectionModel
      Gets the the selection column's frozen state.
      Specified by:
      isSelectionColumnFrozen in interface GridMultiSelectionModel<T>
      Returns:
      whether the selection column is frozen
    • setDragSelect

      public void setDragSelect(boolean dragSelect)
      Description copied from interface: GridMultiSelectionModel
      If true, grid rows can be selected or deselected by dragging the mouse cursor over grid's selection column.
      Specified by:
      setDragSelect in interface GridMultiSelectionModel<T>
      Parameters:
      dragSelect - true to enable drag select feature, false for disabling it
    • isDragSelect

      public boolean isDragSelect()
      Description copied from interface: GridMultiSelectionModel
      Gets whether grid drag select is enabled or not.
      Specified by:
      isDragSelect in interface GridMultiSelectionModel<T>
      Returns:
      true if drag select feature is enabled, false otherwise
    • fireSelectionEvent

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

      protected void clientSelectAll()
    • getSelectionColumn

      protected GridSelectionColumn getSelectionColumn()
    • clientDeselectAll

      protected void clientDeselectAll()