Class ViewportLayer

    • Constructor Detail

    • Method Detail

      • setHorizontalScroller

        public void setHorizontalScroller​(IScroller<?> scroller)
        Set a different horizontal scroller than the default one.
        Parameters:
        scroller - The scroller that should be used for horizontal scrolling.
      • setVerticalScroller

        public void setVerticalScroller​(IScroller<?> scroller)
        Set a different vertical scroller than the default one.
        Parameters:
        scroller - The scroller that should be used for vertical scrolling.
      • getMaxWidth

        public int getMaxWidth()
      • getMinVerticalStart

        public int getMinVerticalStart()
      • getMaxHeight

        public int getMaxHeight()
      • getMinHorizontalStart

        public int getMinHorizontalStart()
      • getMinimumOrigin

        public PixelCoordinate getMinimumOrigin()
        Returns:
        The minimum origin pixel position.
      • getMinimumOriginColumnPosition

        public int getMinimumOriginColumnPosition()
        Returns:
        The minimum origin column position
      • getMinimumOriginRowPosition

        public int getMinimumOriginRowPosition()
        Returns:
        The minimum origin row position
      • setMinimumOriginX

        public void setMinimumOriginX​(int newMinimumOriginX)
        Set the minimum origin X pixel position.
        Parameters:
        newMinimumOriginX - The new minimum origin x.
      • setMinimumOriginY

        public void setMinimumOriginY​(int newMinimumOriginY)
        Set the minimum origin Y pixel position.
        Parameters:
        newMinimumOriginY - The new minimum origin y.
      • setMinimumOrigin

        public void setMinimumOrigin​(int newMinimumOriginX,
                                     int newMinimumOriginY)
        Set the minimum origin pixel position to the given values.
        Parameters:
        newMinimumOriginX - The new minimum origin x.
        newMinimumOriginY - The new minimum origin y.
      • getOrigin

        public PixelCoordinate getOrigin()
        Returns:
        The origin pixel position
      • setOriginX

        public void setOriginX​(int newOriginX)
        Set the origin X pixel position.
        Parameters:
        newOriginX - The new origin x value.
      • setOriginY

        public void setOriginY​(int newOriginY)
        Set the origin Y pixel position.
        Parameters:
        newOriginY - The new origin y value.
      • resetOrigin

        public void resetOrigin​(int newOriginX,
                                int newOriginY)
        Reset the origin pixel position to the given values.
        Parameters:
        newOriginX - The new origin x value.
        newOriginY - The new origin y value.
      • getMaxColumnPosition

        public int getMaxColumnPosition()
        Returns:
        The maximum column position of a split viewport or -1 in case there are no multiple viewports configured.
      • setMaxColumnPosition

        public void setMaxColumnPosition​(int maxColumnPosition)
        Parameters:
        maxColumnPosition - The right most column position in case split viewports need to be configured.
      • getMinColumnPosition

        public int getMinColumnPosition()
        Returns:
        The minimum column position of a split viewport or -1 in case there are no multiple viewports configured.
      • setMinColumnPosition

        public void setMinColumnPosition​(int minColumnPosition)
        Sets the minimum column position for a split viewport and directly sets the minimum origin x value dependent on the configuration.
        Parameters:
        minColumnPosition - The left most column position in case split viewport need to be configured.
      • getMaxRowPosition

        public int getMaxRowPosition()
        Returns:
        The maximum row position of a split viewport or -1 in case there are no multiple viewports configured.
      • setMaxRowPosition

        public void setMaxRowPosition​(int maxRowPosition)
        Parameters:
        maxRowPosition - The right most row position in case split viewports need to be configured.
      • getMinRowPosition

        public int getMinRowPosition()
        Returns:
        The minimum row position of a split viewport or -1 in case there are no multiple viewports configured.
      • setMinRowPosition

        public void setMinRowPosition​(int minRowPosition)
        Sets the minimum row position for a split viewport and directly sets the minimum origin y value dependent on the configuration.
        Parameters:
        minRowPosition - The left most row position in case split viewport need to be configured.
      • 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
      • localToUnderlyingColumnPosition

        public int localToUnderlyingColumnPosition​(int localColumnPosition)
        Description copied from interface: ILayer
        Convert a column position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.
        Specified by:
        localToUnderlyingColumnPosition in interface ILayer
        Overrides:
        localToUnderlyingColumnPosition in class AbstractLayerTransform
        Parameters:
        localColumnPosition - column position in local (the layer's own) coordinates
        Returns:
        column position in the underlying layer's coordinates
      • underlyingToLocalColumnPosition

        public int underlyingToLocalColumnPosition​(ILayer sourceUnderlyingLayer,
                                                   int underlyingColumnPosition)
        Description copied from interface: ILayer
        Transforms the column position relative to the given underlying layer to this layer coordinates.
        Specified by:
        underlyingToLocalColumnPosition in interface ILayer
        Overrides:
        underlyingToLocalColumnPosition in class AbstractLayerTransform
        Parameters:
        sourceUnderlyingLayer - The underlying layer to which the given column position matches.
        underlyingColumnPosition - The column position in the given underlying layer that should be converted to a local column position.
        Returns:
        The given column position transformed to be local to this layer.
      • getWidth

        public int getWidth()
        Description copied from interface: ILayer
        Returns the total width in pixels of this layer.
        Specified by:
        getWidth in interface ILayer
        Overrides:
        getWidth in class AbstractLayerTransform
        Returns:
        the width of the total number of visible columns
      • isColumnPositionResizable

        public boolean isColumnPositionResizable​(int columnPosition)
        Description copied from interface: ILayer
        Check if the column at the given position is resizable.
        Specified by:
        isColumnPositionResizable in interface ILayer
        Overrides:
        isColumnPositionResizable in class AbstractLayerTransform
        Parameters:
        columnPosition - The column position to check.
        Returns:
        true if the column is resizable, false if not.
      • getColumnPositionByX

        public int getColumnPositionByX​(int x)
        Description copied from interface: ILayer
        Returns the column position that contains the given x coordinate.
        Specified by:
        getColumnPositionByX in interface ILayer
        Overrides:
        getColumnPositionByX in class AbstractLayerTransform
        Parameters:
        x - A horizontal pixel location relative to the pixel boundary of this layer.
        Returns:
        A column position relative to the associated coordinate system, or -1 if there is no column that contains x.
      • getStartXOfColumnPosition

        public int getStartXOfColumnPosition​(int columnPosition)
        Description copied from interface: ILayer
        Returns the x offset in pixels of the given column.
        Specified by:
        getStartXOfColumnPosition in interface ILayer
        Overrides:
        getStartXOfColumnPosition in class AbstractLayerTransform
        Parameters:
        columnPosition - The column position in this layer.
        Returns:
        The x offset of the column, or -1.
      • localToUnderlyingRowPosition

        public int localToUnderlyingRowPosition​(int localRowPosition)
        Description copied from interface: ILayer
        Convert a row position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.
        Specified by:
        localToUnderlyingRowPosition in interface ILayer
        Overrides:
        localToUnderlyingRowPosition in class AbstractLayerTransform
        Parameters:
        localRowPosition - row position in local (the layer's own) coordinates
        Returns:
        row position in the underlying layer's coordinates
      • underlyingToLocalRowPosition

        public int underlyingToLocalRowPosition​(ILayer sourceUnderlyingLayer,
                                                int underlyingRowPosition)
        Description copied from interface: ILayer
        Transforms the row position relative to the given underlying layer to this layer coordinates.
        Specified by:
        underlyingToLocalRowPosition in interface ILayer
        Overrides:
        underlyingToLocalRowPosition in class AbstractLayerTransform
        Parameters:
        sourceUnderlyingLayer - The underlying layer to which the given row position matches.
        underlyingRowPosition - The row position in the given underlying layer that should be converted to a local row position.
        Returns:
        The given row position transformed to be local to this layer.
      • getHeight

        public int getHeight()
        Description copied from interface: ILayer
        Returns the total height in pixels of this layer.
        Specified by:
        getHeight in interface ILayer
        Overrides:
        getHeight in class AbstractLayerTransform
        Returns:
        The total height in pixels of this layer.
      • getRowPositionByY

        public int getRowPositionByY​(int y)
        Description copied from interface: ILayer
        Returns the row position that contains the given y coordinate.
        Specified by:
        getRowPositionByY in interface ILayer
        Overrides:
        getRowPositionByY in class AbstractLayerTransform
        Parameters:
        y - a vertical pixel location relative to the pixel boundary of this layer
        Returns:
        a row position relative to the associated coordinate system, or -1 if there is no row that contains y
      • getStartYOfRowPosition

        public int getStartYOfRowPosition​(int rowPosition)
        Description copied from interface: ILayer
        Returns the y offset in pixels of the given row.
        Specified by:
        getStartYOfRowPosition in interface ILayer
        Overrides:
        getStartYOfRowPosition in class AbstractLayerTransform
        Parameters:
        rowPosition - the row position in this layer
        Returns:
        the y offset of the row, or -1
      • getBoundsByPosition

        public org.eclipse.swt.graphics.Rectangle getBoundsByPosition​(int columnPosition,
                                                                      int rowPosition)
        Description copied from interface: ILayer
        Calculates the bounds in pixel for the given cell position.
        Specified by:
        getBoundsByPosition in interface ILayer
        Overrides:
        getBoundsByPosition in class AbstractLayer
        Parameters:
        columnPosition - the column position of the cell
        rowPosition - the row position of the cell
        Returns:
        the bounds, or null if there are no valid bounds
      • invalidateHorizontalStructure

        public void invalidateHorizontalStructure()
        Clear horizontal caches
      • invalidateVerticalStructure

        public void invalidateVerticalStructure()
        Clear vertical caches
      • recalculateAvailableWidthAndColumnCount

        protected void recalculateAvailableWidthAndColumnCount()
        Recalculate horizontal dimension properties.
      • recalculateAvailableHeightAndRowCount

        protected void recalculateAvailableHeightAndRowCount()
        Recalculate vertical dimension properties.
      • moveCellPositionIntoViewport

        public void moveCellPositionIntoViewport​(int scrollableColumnPosition,
                                                 int scrollableRowPosition)
        Scrolls the table so that the specified cell is visible i.e. in the Viewport
        Parameters:
        scrollableColumnPosition - The column position to scroll to.
        scrollableRowPosition - The row position to scroll to.
      • moveColumnPositionIntoViewport

        public void moveColumnPositionIntoViewport​(int scrollableColumnPosition)
        Scrolls the viewport (if required) so that the specified column is visible.
        Parameters:
        scrollableColumnPosition - column position in terms of the Scrollable Layer
      • moveRowPositionIntoViewport

        public void moveRowPositionIntoViewport​(int scrollableRowPosition)
        Parameters:
        scrollableRowPosition - The row position to scroll to.
        See Also:
        moveColumnPositionIntoViewport(int)
      • fireScrollEvent

        protected void fireScrollEvent()
      • 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 AbstractLayerTransform
        Parameters:
        command - The command to execute.
        Returns:
        true if the command has been handled and was therefore consumed, false otherwise.
      • recalculateScrollBars

        public void recalculateScrollBars()
        Recalculate scrollbar characteristics.
      • handleGridResize

        protected void handleGridResize()
        Recalculate viewport characteristics when the grid has been resized.
      • adjustOriginX

        protected int adjustOriginX​(int originX)
        If the client area size is greater than the content size, move origin to fill as much content as possible.
        Parameters:
        originX - The origin x value to adjust if necessary.
        Returns:
        the adjusted x
      • adjustOriginY

        protected int adjustOriginY​(int originY)
        If the client area size is greater than the content size, move origin to fill as much content as possible.
        Parameters:
        originY - The origin y value to adjust if necessary.
        Returns:
        the adjusted y
      • scrollVerticallyByAPage

        public void scrollVerticallyByAPage​(ScrollSelectionCommand scrollSelectionCommand)
        Scrolls the viewport vertically by a page. This is done by creating a MoveSelectionCommand to move the selection, which will then trigger an update of the viewport.
        Parameters:
        scrollSelectionCommand - The ScrollSelectionCommand that is transfered to a MoveSelectionCommand
      • isLastColumnCompletelyDisplayed

        protected boolean isLastColumnCompletelyDisplayed()
        Returns:
        true if last column is completely displayed, false otherwise
      • isLastRowCompletelyDisplayed

        protected boolean isLastRowCompletelyDisplayed()
        Returns:
        true if last row is completely displayed, false otherwise
      • handleLayerEvent

        public void handleLayerEvent​(ILayerEvent event)
        Description copied from class: AbstractLayer
        Handle layer event notification. Convert it to your context and propagate UP. If you override this method you MUST NOT FORGET to raise the event up the layer stack by calling super.fireLayerEvent(event) - unless you plan to eat the event yourself.
        Specified by:
        handleLayerEvent in interface ILayerListener
        Overrides:
        handleLayerEvent in class AbstractLayer
        Parameters:
        event - the event
      • getClientAreaWidth

        public int getClientAreaWidth()
        Returns:
        The width of the visible client area. Will recalculate horizontal dimension information if the width has changed.
      • getClientAreaHeight

        public int getClientAreaHeight()
        Returns:
        The height of the visible client area. Will recalculate vertical dimension information if the height has changed.
      • getScrollableLayer

        public IUniqueIndexLayer getScrollableLayer()
        Returns:
        The scrollable layer underlying the viewport.
      • drag

        public void drag​(int x,
                         int y)
        Used for edge hover scrolling. Called from the ViewportDragCommandHandler.
        Parameters:
        x - The x coordinate
        y - The y coordinate
      • drag

        public void drag​(SelectionLayer.MoveDirectionEnum horizontal,
                         SelectionLayer.MoveDirectionEnum vertical)
        Used to scroll in the given direction on drag operations outside the visible region. Does not start a background thread for automatic scrolling.
        Parameters:
        horizontal - The horizontal movement for the scroll operation MoveDirectionEnum.LEFT, MoveDirectionEnum.RIGHT, MoveDirectionEnum.NONE
        vertical - The vertical movement for the scroll operation MoveDirectionEnum.UP, MoveDirectionEnum.DOWN, MoveDirectionEnum.NONE
        Since:
        1.3
      • setHorizontalScrollbarEnabled

        public void setHorizontalScrollbarEnabled​(boolean enabled)
        Enable/disable the horizontal scrollbar in this ViewportLayer.

        Note: Setting the value to false will avoid registering a HorizontalScrollBarHandler, which means that there are no actions performed on the horizontal scrollbar in any case. If a horizontal scrollbar is rendered, it will be shown disabled. The rendering of scrollbar is typically configured via style bit in the NatTable control. So if there is a disabled scrollbar rendered check the style bits of the NatTable, and try to remove SWT.H_SCROLL which is set in the default style options.

        Parameters:
        enabled - false to disable the horizontal scrollbar, true to enable it.
      • setVerticalScrollbarEnabled

        public void setVerticalScrollbarEnabled​(boolean enabled)
        Enable/disable the vertical scrollbar in this ViewportLayer.

        Note: Setting the value to false will avoid registering a VerticalScrollBarHandler which means that there are no actions performed on the vertical scrollbar in any case. If a vertical scrollbar is rendered, it will be shown disabled. The rendering of scrollbar is typically configured via style bit in the NatTable control. So if there is a disabled scrollbar rendered check the style bits of the NatTable, and try to remove SWT.V_SCROLL which is set in the default style options.

        Parameters:
        enabled - false to disable the vertical scrollbar, true to enable it.
      • setKeepInViewportRowPosition

        public void setKeepInViewportRowPosition​(int rowPosition)
        Set the row position related to the underlying layer that should be kept visible in the viewport. Mainly used for configurations with dynamic row heights that are calculated on rendering. If a row should become visible via moveCellPositionIntoViewport(int, int) or moveRowPositionIntoViewport(int), but the rows above are resized, the row that should move into the viewport is moved out of it again. Setting the value here leads to keeping the row inside the viewport on recalculateAvailableHeightAndRowCount().

        The value will be reset on ClientAreaResizeCommand handling and via ScrollBarHandlerTemplate if a manual scrolling is triggered.

        Parameters:
        rowPosition - the row position in the underlying layer of the row that should be kept inside the viewport, or -1 to reset the keep row in viewport handling.
        Since:
        1.6