Class RowGroupHeaderReorderDragMode

All Implemented Interfaces:
IDragMode

public class RowGroupHeaderReorderDragMode extends RowReorderDragMode
Default IDragMode invoked for 'left click + drag' on the row group header.

It overrides the isValidTargetRowPosition() to calculate if a destination position is valid for the row group to be reordered to.

Example, a row group cannot be reordered to be inside another row group.

Since:
1.6
  • Field Details

    • rowGroupHeaderLayer

      protected final RowGroupHeaderLayer rowGroupHeaderLayer
    • level

      protected int level
    • dragFromGridColumnPosition

      protected int dragFromGridColumnPosition
  • Constructor Details

    • RowGroupHeaderReorderDragMode

      public RowGroupHeaderReorderDragMode(RowGroupHeaderLayer columnGroupHeaderLayer)
      Parameters:
      columnGroupHeaderLayer - The RowGroupHeaderLayer to which this drag mode should be assigned to.
  • Method Details

    • mouseDown

      public void mouseDown(NatTable natTable, org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseDown in interface IDragMode
      Overrides:
      mouseDown in class RowReorderDragMode
    • isValidTargetRowPosition

      protected boolean isValidTargetRowPosition(ILayer natLayer, int fromGridRowPosition, int toGridRowPosition)
      Overrides:
      isValidTargetRowPosition in class RowReorderDragMode
      Parameters:
      natLayer - The layer the positions are related to
      fromGridRowPosition - The row position of the row that is dragged
      toGridRowPosition - The row position where the row is dropped
      Returns:
      true if the drop position is valid, false if not
    • isValidTargetRowPosition

      protected boolean isValidTargetRowPosition(ILayer natLayer, int fromGridRowPosition, int toGridRowPosition, int level, int fromPosition, int toPosition)
      Test if the reorder is valid for the given level.
      Parameters:
      natLayer - The layer on which the drag operation is triggered, typically the NatTable instance.
      fromGridRowPosition - The from position related to the given natLayer.
      toGridRowPosition - The to position related to the given natLayer.
      level - The grouping level for which the check should be performed.
      fromPosition - The from position related to the positionLayer of the RowGroupHeaderLayer.
      toPosition - The to position related to the positionLayer of the RowGroupHeaderLayer.
      Returns:
      true if the reorder would be valid on the specified level, false if not.
    • fireMoveStartCommand

      protected void fireMoveStartCommand(NatTable natTable, int dragFromGridRowPosition)
      Description copied from class: RowReorderDragMode
      Executes the command to indicate row reorder starting.
      Overrides:
      fireMoveStartCommand in class RowReorderDragMode
      Parameters:
      natTable - The NatTable instance on which the command should be executed
      dragFromGridRowPosition - The row position of the row that is dragged
    • fireMoveEndCommand

      protected void fireMoveEndCommand(NatTable natTable, int dragToGridRowPosition)
      Description copied from class: RowReorderDragMode
      Executes the command to indicate row reorder ending.
      Overrides:
      fireMoveEndCommand in class RowReorderDragMode
      Parameters:
      natTable - The NatTable instance on which the command should be executed
      dragToGridRowPosition - The position of the row to which the dragged row should be dropped
    • getMoveDirection

      protected CellEdgeEnum getMoveDirection(int y)
      Overrides:
      getMoveDirection in class RowReorderDragMode
      Parameters:
      y - The y coordinate of the drop location
      Returns:
      The direction whether the drop should be performed before the the cell at drop position or after
    • getRowCell

      protected ILayerCell getRowCell(int y)
      Overrides:
      getRowCell in class RowReorderDragMode
      Parameters:
      y - The y coordinate of the drop location
      Returns:
      The ILayerCell at the drop location
    • calculateLevel

      protected void calculateLevel(int columnPosition, int rowPosition)
      Calculate the group level and based on that the real drag from grid column position that is reordered. Needed in case there is no group at the coordinate level and therefore a spanning indicates a group at a lower level.
      Parameters:
      columnPosition - The column position from which the drag was started. Needs to be related to the columnGroupHeaderLayer.
      rowPosition - The row position from which the drag was started. Needed to check if there is a group at the calculated level. Needs to be related to the columnGroupHeaderLayer.