Class RowReorderDragMode

java.lang.Object
org.eclipse.nebula.widgets.nattable.viewport.action.AutoScrollDragMode
org.eclipse.nebula.widgets.nattable.reorder.action.RowReorderDragMode
All Implemented Interfaces:
IDragMode
Direct Known Subclasses:
RowGroupHeaderReorderDragMode, RowHeaderReorderDragMode

public class RowReorderDragMode extends AutoScrollDragMode
Default IDragMode invoked for 'left click + drag' on the row header. It does the following when invoked:
  1. Fires a row reorder command, to move columns
  2. Overlays a black line indicating the new row position
  • Field Details

    • natTable

      protected NatTable natTable
    • initialEvent

      protected org.eclipse.swt.events.MouseEvent initialEvent
    • currentEvent

      protected org.eclipse.swt.events.MouseEvent currentEvent
    • dragFromGridRowPosition

      protected int dragFromGridRowPosition
    • targetOverlayPainter

      protected IOverlayPainter targetOverlayPainter
  • Constructor Details

    • RowReorderDragMode

      public RowReorderDragMode()
  • Method Details

    • mouseDown

      public void mouseDown(NatTable natTable, org.eclipse.swt.events.MouseEvent event)
    • mouseMove

      public void mouseMove(NatTable natTable, org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseMove in interface IDragMode
      Overrides:
      mouseMove in class AutoScrollDragMode
    • mouseUp

      public void mouseUp(NatTable natTable, org.eclipse.swt.events.MouseEvent event)
      Specified by:
      mouseUp in interface IDragMode
      Overrides:
      mouseUp in class AutoScrollDragMode
    • getDragFromGridRowPosition

      protected int getDragFromGridRowPosition()
      Returns:
      The row position of the row that is dragged
    • getDragToGridRowPosition

      protected int getDragToGridRowPosition(CellEdgeEnum moveDirection, int gridRowPosition)
      Parameters:
      moveDirection - The direction to indicate whether the drop was before or after the given row position
      gridRowPosition - The row position at which the drop was performed
      Returns:
      The row position where the dragged row should be dropped
    • getMoveDirection

      protected CellEdgeEnum getMoveDirection(int y)
      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)
      Parameters:
      y - The y coordinate of the drop location
      Returns:
      The ILayerCell at the drop location
      Since:
      1.6
    • isValidTargetRowPosition

      protected boolean isValidTargetRowPosition(ILayer natLayer, int dragFromGridRowPosition, int dragToGridRowPosition)
      Parameters:
      natLayer - The layer the positions are related to
      dragFromGridRowPosition - The row position of the row that is dragged
      dragToGridRowPosition - The row position where the row is dropped
      Returns:
      true if the drop position is valid, false if not
    • fireMoveStartCommand

      protected void fireMoveStartCommand(NatTable natTable, int dragFromGridRowPosition)
      Executes the command to indicate row reorder starting.
      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)
      Executes the command to indicate row reorder ending.
      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