Class FGrid.AbstractSelectionModel

java.lang.Object
com.vaadin.featurepack.ui.FGrid.AbstractSelectionModel
All Implemented Interfaces:
FGrid.SelectionModel, Serializable
Direct Known Subclasses:
FGrid.MultiSelectionModel, FGrid.NoSelectionModel, FGrid.SingleSelectionModel
Enclosing class:
FGrid

public abstract static class FGrid.AbstractSelectionModel extends Object implements FGrid.SelectionModel
A base class for SelectionModels that contains some of the logic that is reusable.
See Also:
  • Field Details

  • Constructor Details

    • AbstractSelectionModel

      public AbstractSelectionModel()
  • Method Details

    • isSelected

      public boolean isSelected(Object itemId)
      Description copied from interface: FGrid.SelectionModel
      Checks whether an item is selected or not.
      Specified by:
      isSelected in interface FGrid.SelectionModel
      Parameters:
      itemId - the item id to check for
      Returns:
      true iff the item is selected
    • getSelectedRows

      public Collection<Object> getSelectedRows()
      Description copied from interface: FGrid.SelectionModel
      Returns a collection of all the currently selected itemIds.
      Specified by:
      getSelectedRows in interface FGrid.SelectionModel
      Returns:
      a collection of all the currently selected itemIds
    • setGrid

      public void setGrid(FGrid grid)
      Description copied from interface: FGrid.SelectionModel
      Injects the current Grid instance into the SelectionModel.

      Note: This method should not be called manually.

      Specified by:
      setGrid in interface FGrid.SelectionModel
      Parameters:
      grid - the Grid in which the SelectionModel currently is, or null when a selection model is being detached from a Grid.
    • getParentGrid

      protected FGrid getParentGrid()
    • checkItemIdExists

      protected void checkItemIdExists(Object itemId) throws IllegalArgumentException
      Sanity check for existence of item id.
      Parameters:
      itemId - item id to be selected / deselected
      Throws:
      IllegalArgumentException - if item Id doesn't exist in the container of Grid
    • checkItemIdsExist

      protected void checkItemIdsExist(Collection<?> itemIds) throws IllegalArgumentException
      Sanity check for existence of item ids in given collection.
      Parameters:
      itemIds - item id collection to be selected / deselected
      Throws:
      IllegalArgumentException - if at least one item id doesn't exist in the container of Grid
    • fireSelectionEvent

      protected void fireSelectionEvent(Collection<Object> oldSelection, Collection<Object> newSelection)
      Fires a SelectionEvent to all the SelectionListeners currently added to the Grid in which this SelectionModel is.

      Note that this is only a helper method, and routes the call all the way to Grid. A FGrid.SelectionModel is not a SelectionEvent.SelectionNotifier

      Parameters:
      oldSelection - the complete Collection of the itemIds that were selected before this event happened
      newSelection - the complete Collection of the itemIds that are selected after this event happened