Class SelectionModel

    • Constructor Detail

      • SelectionModel

        public SelectionModel​(SelectionLayer selectionLayer)
      • SelectionModel

        public SelectionModel​(SelectionLayer selectionLayer,
                              boolean multipleSelectionAllowed)
    • Method Detail

      • 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​(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
      • internalGetSelectedColumnPositions

        protected Set<Range> internalGetSelectedColumnPositions()
        Since:
        1.5
      • 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)
        Are all cells in this column selected? Different selection rectangles might aggregate to cover the entire column. We need to take into account any overlapping selections or any selection rectangles contained within each other. See the related tests for a better understanding.
        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
      • contains

        protected boolean contains​(org.eclipse.swt.graphics.Rectangle containerRectangle,
                                   org.eclipse.swt.graphics.Rectangle rectangle)
      • sortByX

        protected void sortByX​(List<org.eclipse.swt.graphics.Rectangle> selectionRectanglesInRow)
      • sortByY

        protected void sortByY​(List<org.eclipse.swt.graphics.Rectangle> selectionRectanglesInColumn)
      • setClearSelectionOnChange

        public void setClearSelectionOnChange​(boolean clearSelectionOnChange)
        Parameters:
        clearSelectionOnChange - true to simply clear the selection on structural changes, false to keep the valid selection (selection of cells that still exist)