Class PreserveSelectionModel<T>

java.lang.Object
org.eclipse.nebula.widgets.nattable.selection.preserve.PreserveSelectionModel<T>
Type Parameters:
T - the type of object underlying each row
All Implemented Interfaces:
ILayerEventHandler<IStructuralChangeEvent>, IMarkerSelectionModel, ISelectionModel
Direct Known Subclasses:
SummaryRowPreserveSelectionModel

public class PreserveSelectionModel<T> extends Object implements IMarkerSelectionModel
Individual cell selection model that copes with the reordering of rows.
  • Field Details

    • selectionLayer

      protected final IUniqueIndexLayer selectionLayer
      Provider of cell information.
      Since:
      1.6
  • Constructor Details

    • PreserveSelectionModel

      public PreserveSelectionModel(IUniqueIndexLayer selectionLayer, IRowDataProvider<T> rowDataProvider, IRowIdAccessor<T> rowIdAccessor)
      Creates a row sortable selection model
      Parameters:
      selectionLayer - provider of cell information
      rowDataProvider - provider of underlying row objects
      rowIdAccessor - provider of unique IDs for the rows
  • Method Details

    • isMultipleSelectionAllowed

      public boolean isMultipleSelectionAllowed()
      Description copied from interface: ISelectionModel
      Determines whether multiple cells can be selected simultaneously
      Specified by:
      isMultipleSelectionAllowed in interface ISelectionModel
      Returns:
      whether multiple cells can be selected simultaneously
    • setMultipleSelectionAllowed

      public void setMultipleSelectionAllowed(boolean multipleSelectionAllowed)
      Description copied from interface: ISelectionModel
      Sets whether multiple cells can be selected simultaneously
      Specified by:
      setMultipleSelectionAllowed in interface ISelectionModel
      Parameters:
      multipleSelectionAllowed - whether multiple cells can be selected simultaneously
    • addSelection

      public void addSelection(int columnPosition, int rowPosition)
      Description copied from interface: ISelectionModel
      Selects a specified cell
      Specified by:
      addSelection in interface ISelectionModel
      Parameters:
      columnPosition - column position of the cell to select
      rowPosition - row position of the cell to select
    • addSelection

      public void addSelection(org.eclipse.swt.graphics.Rectangle range)
      Description copied from interface: ISelectionModel
      Selects the cells of a specified area
      Specified by:
      addSelection in interface ISelectionModel
      Parameters:
      range - the position based area to select
    • clearSelection

      public void clearSelection()
      Description copied from interface: ISelectionModel
      Removes all cell selections
      Specified by:
      clearSelection in interface ISelectionModel
    • clearSelection

      public void clearSelection(int columnPosition, int rowPosition)
      Description copied from interface: ISelectionModel
      Deselects a specified cell
      Specified by:
      clearSelection in interface ISelectionModel
      Parameters:
      columnPosition - column position of the cell to deselect
      rowPosition - row position of the cell to deselect
    • clearSelection

      public void clearSelection(org.eclipse.swt.graphics.Rectangle removedSelection)
      Description copied from interface: ISelectionModel
      Removes the selection of specified cells
      Specified by:
      clearSelection in interface ISelectionModel
      Parameters:
      removedSelection - the position based area to deselect
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ISelectionModel
      Determines whether there are any selected cells
      Specified by:
      isEmpty in interface ISelectionModel
      Returns:
      whether there are any selected cells
    • getSelections

      public List<org.eclipse.swt.graphics.Rectangle> getSelections()
      Description copied from interface: ISelectionModel
      Retrieves the cells that are selected
      Specified by:
      getSelections in interface ISelectionModel
      Returns:
      the cells that are selected, expressed in position coordinates
    • isCellPositionSelected

      public boolean isCellPositionSelected(int columnPosition, int rowPosition)
      Description copied from interface: ISelectionModel
      Determines whether a specified cell is selected
      Specified by:
      isCellPositionSelected in interface ISelectionModel
      Parameters:
      columnPosition - column position of the cell to inspect
      rowPosition - row position of the cell to inspect
      Returns:
      whether the specified cell is selected
    • getSelectedColumnPositions

      public int[] getSelectedColumnPositions()
      Description copied from interface: ISelectionModel
      Retrieves the columns that have any selected cells
      Specified by:
      getSelectedColumnPositions in interface ISelectionModel
      Returns:
      the column positions that have any selected cells
    • isColumnPositionSelected

      public boolean isColumnPositionSelected(int columnPosition)
      Description copied from interface: ISelectionModel
      Determines whether a specified column contains any selected cell
      Specified by:
      isColumnPositionSelected in interface ISelectionModel
      Parameters:
      columnPosition - column position to inspect
      Returns:
      whether the specified column contains any selected cell
    • getFullySelectedColumnPositions

      public int[] getFullySelectedColumnPositions(int columnHeight)
      Specified by:
      getFullySelectedColumnPositions in interface ISelectionModel
      Parameters:
      columnHeight - the number of rows in a fully selected column
    • isColumnPositionFullySelected

      public boolean isColumnPositionFullySelected(int columnPosition, int columnHeight)
      Specified by:
      isColumnPositionFullySelected in interface ISelectionModel
      columnHeight - the number of rows in a fully selected column
    • getSelectedRowCount

      public int getSelectedRowCount()
      Description copied from interface: ISelectionModel
      Retrieves the number of rows that have any selected cell
      Specified by:
      getSelectedRowCount in interface ISelectionModel
      Returns:
      the number of rows that have any selected cell
    • getSelectedRowPositions

      public Set<Range> getSelectedRowPositions()
      Description copied from interface: ISelectionModel
      Retrieves the rows with a valid row position that have any selected cells
      Specified by:
      getSelectedRowPositions in interface ISelectionModel
      Returns:
      the row positions with a valid row position that have any selected cells
    • isRowPositionSelected

      public boolean isRowPositionSelected(int rowPosition)
      Description copied from interface: ISelectionModel
      Determines whether a specified row contains any selected cell
      Specified by:
      isRowPositionSelected in interface ISelectionModel
      Parameters:
      rowPosition - row position to inspect
      Returns:
      whether the specified row contains any selected cell
    • getFullySelectedRowPositions

      public int[] getFullySelectedRowPositions(int rowWidth)
      Specified by:
      getFullySelectedRowPositions in interface ISelectionModel
      Parameters:
      rowWidth - the number of columns in a fully selected row
    • isRowPositionFullySelected

      public boolean isRowPositionFullySelected(int rowPosition, int rowWidth)
      Description copied from interface: ISelectionModel
      Check if all cells in a row are selected, which means the row is fully selected.
      Specified by:
      isRowPositionFullySelected in interface ISelectionModel
      Parameters:
      rowPosition - The row position that should be checked.
      rowWidth - The number of columns in the row which is needed to determine if the all cells in a row are selected.
      Returns:
      true if all cells in a row are selected, false if not
    • getRowIdByPosition

      protected Serializable getRowIdByPosition(int rowPosition)
      Retrieves the row ID for a row position
      Parameters:
      rowPosition - row position for retrieving row ID
      Returns:
      row ID for rowPosition, or null if undefined
      Since:
      1.6
    • getRowPositionByRowObject

      protected int getRowPositionByRowObject(T rowObject)
      Retrieves the row position for a row object
      Parameters:
      rowObject - row object for retrieving row position
      Returns:
      row position for rowObject, or -1 if undefined
      Since:
      1.6
    • getSelectionAnchor

      public org.eclipse.swt.graphics.Point getSelectionAnchor()
      Specified by:
      getSelectionAnchor in interface IMarkerSelectionModel
      Returns:
      point of the anchor expressed in position coordinates
    • getLastSelectedCell

      public org.eclipse.swt.graphics.Point getLastSelectedCell()
      Specified by:
      getLastSelectedCell in interface IMarkerSelectionModel
      Returns:
      point of the last selected cell expressed in position coordinates
    • getLastSelectedRegion

      public org.eclipse.swt.graphics.Rectangle getLastSelectedRegion()
      Specified by:
      getLastSelectedRegion in interface IMarkerSelectionModel
      Returns:
      rectangle of the last selected region expressed in position coordinates
    • setSelectionAnchor

      public void setSelectionAnchor(org.eclipse.swt.graphics.Point coordinate)
      Specified by:
      setSelectionAnchor in interface IMarkerSelectionModel
      Parameters:
      coordinate - coordinate of the anchor
    • setLastSelectedCell

      public void setLastSelectedCell(org.eclipse.swt.graphics.Point coordinate)
      Specified by:
      setLastSelectedCell in interface IMarkerSelectionModel
      Parameters:
      coordinate - coordinate of the last selected
    • setLastSelectedRegion

      public void setLastSelectedRegion(org.eclipse.swt.graphics.Rectangle region)
      Description copied from interface: IMarkerSelectionModel
      Will set the Rectangle object of the last selected region to be the same as the parameter object region.
      Specified by:
      setLastSelectedRegion in interface IMarkerSelectionModel
      Parameters:
      region - the last selection position region
    • setLastSelectedRegion

      public void setLastSelectedRegion(int x, int y, int width, int height)
      Description copied from interface: IMarkerSelectionModel
      Will copy the information of the parameters to the already existing Rectangle object of last selected region.
      Specified by:
      setLastSelectedRegion in interface IMarkerSelectionModel
      Parameters:
      x - origin of the last selection position region
      y - origin of the last selection position region
      width - of the last selection position region
      height - of the last selection position region
    • handleLayerEvent

      public void handleLayerEvent(IStructuralChangeEvent event)
      Specified by:
      handleLayerEvent in interface ILayerEventHandler<T>
    • ignoreVerticalChange

      protected boolean ignoreVerticalChange(org.eclipse.nebula.widgets.nattable.selection.preserve.Selections.Row<T> row)
      Check if the default handling for vertical structure changes should be performed for the given Selections.Row, or if it should be skipped. Skipping for example would make sense for selections that are stored for rows that have no row data in the backing data structure, e.g. a summary row selection.
      Parameters:
      row - The internal selected row representation.
      Returns:
      false if the default handling for vertical changes should be performed, true if the default handling should be skipped.
      Since:
      1.6
    • getLayerEventClass

      public Class<IStructuralChangeEvent> getLayerEventClass()
      Specified by:
      getLayerEventClass in interface ILayerEventHandler<T>