Class ColumnReorderLayer

    • Field Detail

      • columnIndexOrder

        protected final org.eclipse.collections.api.list.primitive.MutableIntList columnIndexOrder
        The internal cache of the column index order. Used to track the reordering performed by this layer. Position X in the List contains the index of column at position X.
      • indexPositionMapping

        protected final org.eclipse.collections.api.map.primitive.MutableIntIntMap indexPositionMapping
        The internal mapping of index to position values. Used for performance reasons in getColumnPositionByIndex(int) because List.indexOf(Object) doesn't scale well.
        Since:
        1.5
    • Method Detail

      • 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
      • 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.
      • 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
      • saveState

        public void saveState​(String prefix,
                              Properties properties)
        Description copied from interface: IPersistable
        Saves the state to the given Properties using the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.
        Specified by:
        saveState in interface IPersistable
        Overrides:
        saveState in class AbstractLayerTransform
        Parameters:
        prefix - The prefix to use for the state keys. Is also used as the state configuration name.
        properties - The Properties instance to save the state to.
      • loadState

        public void loadState​(String prefix,
                              Properties properties)
        Description copied from class: AbstractLayerTransform
        Underlying layers must load state first. If this is not done, IStructuralChangeEvent from underlying layers will reset caches after state has been loaded
        Specified by:
        loadState in interface IPersistable
        Overrides:
        loadState in class AbstractLayerTransform
        Parameters:
        prefix - The prefix to use for the state keys. Is also used as the state configuration name.
        properties - The Properties instance to load the state from.
      • isRestoredStateValid

        protected boolean isRestoredStateValid​(int[] newColumnIndexOrder)
        Ensure that columns haven't changed in the underlying data source
        Parameters:
        newColumnIndexOrder - restored from the properties file.
        Since:
        2.0
      • getColumnIndexOrder

        public List<Integer> getColumnIndexOrder()
        Returns:
        the internal kept ordering of column indexes.
      • getColumnIndexOrderArray

        public int[] getColumnIndexOrderArray()
        Returns:
        the internal kept ordering of column indexes.
        Since:
        2.0
      • getColumnIndexByPosition

        public int getColumnIndexByPosition​(int columnPosition)
        Description copied from interface: ILayer
        Gets the underlying non-transformed column index for the given column position on this layer.
        Specified by:
        getColumnIndexByPosition in interface ILayer
        Overrides:
        getColumnIndexByPosition in class AbstractLayerTransform
        Parameters:
        columnPosition - The column position relative to this layer.
        Returns:
        An underlying non-transformed column index, or -1 if the given column position does not exist within this coordinate system.
      • 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.
      • underlyingToLocalColumnPositions

        public Collection<Range> underlyingToLocalColumnPositions​(ILayer sourceUnderlyingLayer,
                                                                  Collection<Range> underlyingColumnPositionRanges)
        Description copied from interface: ILayer
        Transforms the column position ranges relative to the given underlying layer to this layer coordinates.
        Specified by:
        underlyingToLocalColumnPositions in interface ILayer
        Overrides:
        underlyingToLocalColumnPositions in class AbstractLayerTransform
        Parameters:
        sourceUnderlyingLayer - The underlying layer to which the given column positions match.
        underlyingColumnPositionRanges - The column position ranges relative to the given underlying layer that should be converted to local column positions.
        Returns:
        The given column position ranges transformed to this layer.
      • 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 targetColumnPosition)
        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:
        targetColumnPosition - The column position in this layer.
        Returns:
        The x offset of the column, or -1.
      • populateIndexOrder

        protected void populateIndexOrder()
        Initialize the internal column index ordering from a clean state, which means it reflects the ordering from the underlying layer.
        Since:
        1.6
      • refreshIndexPositionMapping

        protected void refreshIndexPositionMapping()
        Initializes the internal index-position-mapping to reflect the internal column-index-order.
        Since:
        1.6
      • reorderColumnPosition

        public void reorderColumnPosition​(int fromColumnPosition,
                                          int toColumnPosition)
        Moves the given from-column to the left edge of the column to move to.
        Parameters:
        fromColumnPosition - column position to move
        toColumnPosition - position to move the column to
      • reorderColumnPosition

        public void reorderColumnPosition​(int fromColumnPosition,
                                          int toColumnPosition,
                                          boolean reorderToLeftEdge)
        Reorders the given from-column to the specified edge of the column to move to and fires a ColumnReorderEvent.
        Parameters:
        fromColumnPosition - column position to move
        toColumnPosition - position to move the column to
        reorderToLeftEdge - true if the column should be moved to the left of the given column to move to, false if it should be positioned to the right
      • reorderMultipleColumnPositions

        public void reorderMultipleColumnPositions​(List<Integer> fromColumnPositions,
                                                   int toColumnPosition)
        Reorders the given from-columns to the left edge of the column to move to.
        Parameters:
        fromColumnPositions - column positions to move
        toColumnPosition - position to move the columns to
      • reorderMultipleColumnPositions

        public void reorderMultipleColumnPositions​(int[] fromColumnPositions,
                                                   int toColumnPosition)
        Reorders the given from-columns to the left edge of the column to move to.
        Parameters:
        fromColumnPositions - column positions to move
        toColumnPosition - position to move the columns to
        Since:
        2.0
      • reorderMultipleColumnPositions

        public void reorderMultipleColumnPositions​(List<Integer> fromColumnPositions,
                                                   int toColumnPosition,
                                                   boolean reorderToLeftEdge)
        Reorders the given from-columns to the specified edge of the column to move to and fires a ColumnReorderEvent.
        Parameters:
        fromColumnPositions - column positions to move
        toColumnPosition - position to move the columns to
        reorderToLeftEdge - true if the columns should be moved to the left of the given column to move to, false if they should be positioned to the right
      • reorderMultipleColumnPositions

        public void reorderMultipleColumnPositions​(int[] fromColumnPositions,
                                                   int toColumnPosition,
                                                   boolean reorderToLeftEdge)
        Reorders the given from-columns to the specified edge of the column to move to and fires a ColumnReorderEvent.
        Parameters:
        fromColumnPositions - column positions to move
        toColumnPosition - position to move the columns to
        reorderToLeftEdge - true if the columns should be moved to the left of the given column to move to, false if they should be positioned to the right
        Since:
        2.0
      • reorderMultipleColumnIndexes

        public void reorderMultipleColumnIndexes​(List<Integer> fromColumnIndexes,
                                                 int toColumnPosition,
                                                 boolean reorderToLeftEdge)
        Reorders the given from-columns identified by index to the specified edge of the column to move to and fires a ColumnReorderEvent. This method can be used to reorder columns that are hidden in a higher level, e.g. to reorder a column group that has hidden columns.
        Parameters:
        fromColumnIndexes - column indexes to move
        toColumnPosition - position to move the columns to
        reorderToLeftEdge - true if the columns should be moved to the left of the given column to move to, false if they should be positioned to the right
        Since:
        1.6
      • reorderMultipleColumnIndexes

        public void reorderMultipleColumnIndexes​(int[] fromColumnIndexes,
                                                 int toColumnPosition,
                                                 boolean reorderToLeftEdge)
        Reorders the given from-columns identified by index to the specified edge of the column to move to and fires a ColumnReorderEvent. This method can be used to reorder columns that are hidden in a higher level, e.g. to reorder a column group that has hidden columns.
        Parameters:
        fromColumnIndexes - column indexes to move
        toColumnPosition - position to move the columns to
        reorderToLeftEdge - true if the columns should be moved to the left of the given column to move to, false if they should be positioned to the right
        Since:
        2.0
      • invalidateCache

        protected void invalidateCache()
        Clear the internal cache.
        Since:
        1.6
      • getReorderFromColumnPosition

        public int getReorderFromColumnPosition()
        Returns the column position from where the reorder process started. Used by the ColumnReorderEndCommandHandler which is triggered by the ColumnReorderDragMode when dragging a column is finished.
        Returns:
        The column position where the reorder started.
      • setReorderFromColumnPosition

        public void setReorderFromColumnPosition​(int fromColumnPosition)
        Sets the column position where a reorder process started. Typically done by calling the ColumnReorderStartCommand which is triggered by the ColumnReorderDragMode.
        Parameters:
        fromColumnPosition - The column position where the reorder started.
      • resetReorder

        public void resetReorder()
        Resets the reordering tracked by this layer.
        Since:
        1.6