Class SelectionLayer

    • Field Detail

      • lastSelectedRegion

        protected org.eclipse.swt.graphics.Rectangle lastSelectedRegion
      • fillHandleRegion

        protected org.eclipse.swt.graphics.Rectangle fillHandleRegion
        The region selected via fill handle to extend the current selection for triggering a fill action. Can be null.
        Since:
        1.4
      • bottomRightInSelection

        protected PositionCoordinate bottomRightInSelection
        The bottom right cell in a contiguous selection or null if there is no selection or the selection is not contiguous. Needed to identify the cell on which the fill handle should be rendered.
        Since:
        1.4
    • Constructor Detail

      • SelectionLayer

        public SelectionLayer​(IUniqueIndexLayer underlyingLayer,
                              boolean useDefaultConfiguration)
    • Method Detail

      • setSelectionModel

        public void setSelectionModel​(ISelectionModel selectionModel)
      • addSelection

        public void addSelection​(org.eclipse.swt.graphics.Rectangle selection)
      • clear

        public void clear()
      • clear

        public void clear​(boolean fireSelectionEvent)
      • clearSelection

        public void clearSelection​(int columnPosition,
                                   int rowPosition)
      • clearSelection

        public void clearSelection​(org.eclipse.swt.graphics.Rectangle selection)
      • selectAll

        public void selectAll()
      • isCellPositionSelected

        public boolean isCellPositionSelected​(int columnPosition,
                                              int rowPosition)
      • setSelectedCell

        public void setSelectedCell​(int columnPosition,
                                    int rowPosition)
      • getCellPositionToMoveFrom

        protected PositionCoordinate getCellPositionToMoveFrom​(boolean withShiftMask,
                                                               boolean withControlMask)
        When extending a selected area via modifier keys, we need to move from the last selected cell. If we are not extending a selection we need to move from the selection anchor.
        Parameters:
        withShiftMask - true if the shift mask is active, false if not.
        withControlMask - true if the shift mask is active, false if not.
        Returns:
        The cell position coordinate related to this SelectionLayer, from where to move from.
      • getSelectedCells

        public Collection<ILayerCell> getSelectedCells()
        Retrieves the ILayerCells out of the SelectionLayer that are currently marked as selected in the SelectionModel. Takes spanning into account.
        Returns:
        The selected ILayerCells
      • selectCell

        public void selectCell​(int columnPosition,
                               int rowPosition,
                               boolean withShiftMask,
                               boolean withControlMask)
        Calculates the selected cells - taking into account Shift and Ctrl key presses.
      • selectRegion

        public void selectRegion​(int startColumnPosition,
                                 int startRowPosition,
                                 int regionWidth,
                                 int regionHeight)
      • setLastSelectedRegion

        protected void setLastSelectedRegion​(org.eclipse.swt.graphics.Rectangle region)
      • setLastSelectedRegion

        protected void setLastSelectedRegion​(int startColumnPosition,
                                             int startRowPosition,
                                             int regionWidth,
                                             int regionHeight)
      • moveSelectionAnchor

        public void moveSelectionAnchor​(int startColumnPositionInRegion,
                                        int startRowPosition)
      • allCellsSelectedInRegion

        public boolean allCellsSelectedInRegion​(org.eclipse.swt.graphics.Rectangle region)
        Test if all cells in a given region are selected.
        Parameters:
        region - The region that should be checked.
        Returns:
        true if all cells in a region are selected, false if at least one cell in the region is not selected.
        Since:
        1.6
      • setLastSelectedCell

        public void setLastSelectedCell​(int columnPosition,
                                        int rowPosition)
      • getLastSelectedRegion

        public org.eclipse.swt.graphics.Rectangle getLastSelectedRegion()
      • hasColumnSelection

        public boolean hasColumnSelection()
      • getSelectedColumnPositions

        public int[] getSelectedColumnPositions()
      • isColumnPositionSelected

        public boolean isColumnPositionSelected​(int columnPosition)
      • getFullySelectedColumnPositions

        public int[] getFullySelectedColumnPositions()
      • isColumnPositionFullySelected

        public boolean isColumnPositionFullySelected​(int columnPosition)
      • selectColumn

        public void selectColumn​(int columnPosition,
                                 int rowPosition,
                                 boolean withShiftMask,
                                 boolean withControlMask)
      • hasRowSelection

        public boolean hasRowSelection()
      • getSelectedRowCount

        public int getSelectedRowCount()
      • getSelectedRowPositions

        public Set<Range> getSelectedRowPositions()
      • isRowPositionSelected

        public boolean isRowPositionSelected​(int rowPosition)
      • getFullySelectedRowPositions

        public int[] getFullySelectedRowPositions()
      • isRowPositionFullySelected

        public boolean isRowPositionFullySelected​(int rowPosition)
      • selectRow

        public void selectRow​(int columnPosition,
                              int rowPosition,
                              boolean withShiftMask,
                              boolean withControlMask)
      • getConfigLabelsByPosition

        public LabelStack getConfigLabelsByPosition​(int columnPosition,
                                                    int rowPosition)
        Description copied from interface: ILayer
        Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry.
        Specified by:
        getConfigLabelsByPosition in interface ILayer
        Overrides:
        getConfigLabelsByPosition in class AbstractIndexLayerTransform
        Parameters:
        columnPosition - The column position of the cell.
        rowPosition - The row position of the cell.
        Returns:
        The LabelStack with the config labels for the cell at the given coordinates.
      • registerCommandHandlers

        protected void registerCommandHandlers()
        Description copied from class: AbstractLayer
        Layers should use this method to register their command handlers and call it from their constructor. This allows easy overriding if required of command handlers
        Overrides:
        registerCommandHandlers in class AbstractLayer
      • doCommand

        public boolean doCommand​(ILayerCommand command)
        Description copied from interface: ILayer
        Opportunity to respond to a command as it flows down the stack. If the layer is not interested in the command it should allow the command to keep traveling down the stack.

        Note: Before the layer can process a command it must convert the command to its local coordinates using ILayerCommand.convertToTargetLayer(ILayer)

        Specified by:
        doCommand in interface ILayer
        Overrides:
        doCommand in class AbstractIndexLayerTransform
        Parameters:
        command - The command to execute.
        Returns:
        true if the command has been handled and was therefore consumed, false otherwise.
      • fireCellSelectionEvent

        public void fireCellSelectionEvent​(int columnPosition,
                                           int rowPosition,
                                           boolean forcingEntireCellIntoViewport,
                                           boolean withShiftMask,
                                           boolean withControlMask)
      • handleColumnHideCommand

        protected boolean handleColumnHideCommand​(ColumnHideCommand command)
        Will check if there are fully selected column positions. If there is at least one fully selected column position, the ColumnHideCommand will be consumed and a MultiColumnHideCommand will be created and executed further down the layer stack, that contains all fully selected column positions. Otherwise the given command will be executed further.
        This is necessary because neither the ColumnHideShowLayer nor the action that caused the execution of the ColumnHideCommand is aware of the presence of the SelectionLayer. Without this transformation, only the column on which the action was called will be hidden instead of all selected ones.
        Parameters:
        command - The ColumnHideCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • handleMultiColumnHideCommand

        protected boolean handleMultiColumnHideCommand​(MultiColumnHideCommand command)
        Previous to processing the given MultiColumnHideCommand down the layer stack, the fully selected column positions selection state will be cleared. This is necessary so the selection also disappears for the selected columns. Otherwise after hiding the selection will be showed for different columns.
        Parameters:
        command - The MultiColumnHideCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • handleRowHideCommand

        protected boolean handleRowHideCommand​(RowHideCommand command)
        Will check if there are fully selected row positions. If there is at least one fully selected row position, the RowHideCommand will be consumed and a MultiRowHideCommand will be created and executed further down the layer stack, that contains all fully selected row positions. Otherwise the given command will be executed further.
        This is necessary because neither the RowHideShowLayer nor the action that caused the execution of the RowHideCommand is aware of the presence of the SelectionLayer. Without this transformation, only the row on which the action was called will be hidden instead of all selected ones.
        Parameters:
        command - The RowHideCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • handleMultiRowHideCommand

        protected boolean handleMultiRowHideCommand​(MultiRowHideCommand command)
        Previous to processing the given MultiRowHideCommand down the layer stack, the fully selected row positions selection state will be cleared. This is necessary so the selection also disappears for the selected rows. Otherwise after hiding the selection will be showed for different rows.
        Parameters:
        command - The MultiRowHideCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • handleRowPositionHideCommand

        protected boolean handleRowPositionHideCommand​(RowPositionHideCommand command)
        First inspects the cell at the position contained in the RowPositionHideCommand and calculates all rows for that cell, taking the spanning into account. If the cell itself is selected, than also all other selected cells in the column position will be handled for hiding.
        Parameters:
        command - The RowPositionHideCommand to process.
        Returns:
        true if the command has been handled, false otherwise
        Since:
        1.6
      • handleColumnResizeCommand

        protected boolean handleColumnResizeCommand​(ColumnResizeCommand command)
        Will check if there are fully selected column positions. If there is at least one fully selected column position, the ColumnResizeCommand will be consumed and a MultiColumnResizeCommand will be created and executed further down the layer stack, that contains all fully selected column positions. Otherwise the given command will be executed further.
        This is necessary because neither the underlying layers are not aware of the presence of the SelectionLayer. Without this transformation, only the column on which the action was called will be resized instead of all selected ones.
        Parameters:
        command - The ColumnResizeCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • handleRowResizeCommand

        protected boolean handleRowResizeCommand​(RowResizeCommand command)
        Will check if there are fully selected row positions. If there is at least one fully selected row position, the RowResizeCommand will be consumed and a MultiRowResizeCommand will be created and executed further down the layer stack, that contains all fully selected row positions. Otherwise the given command will be executed further.
        This is necessary because neither the underlying layers are not aware of the presence of the SelectionLayer. Without this transformation, only the row on which the action was called will be resized instead of all selected ones.
        Parameters:
        command - The RowResizeCommand to process
        Returns:
        true if the command has been handled, false otherwise
      • setFillHandleRegion

        public void setFillHandleRegion​(org.eclipse.swt.graphics.Rectangle region)
        Set the region that is currently selected via fill handle to extend the current active selection for triggering a fill action.
        Parameters:
        region - The region selected via fill handle.
        Since:
        1.4
        See Also:
        FillHandleDragMode, FillHandleLayerPainter
      • getFillHandleRegion

        public org.eclipse.swt.graphics.Rectangle getFillHandleRegion()
        Returns the region that is currently selected via fill handle to extend the current active selection. Used to perform actions on drag & drop of the fill handle.
        Returns:
        The region selected via fill handle or null.
        Since:
        1.4
      • markFillHandleCell

        public void markFillHandleCell()
        Marks the bottom right cell in a contiguous selection within the SelectionLayer. Also removes the markup in case there is no selection or the selection is not contiguous.
        Since:
        1.4