Class MoveSelectionCommandHandler<T extends MoveSelectionCommand>

java.lang.Object
org.eclipse.nebula.widgets.nattable.selection.MoveSelectionCommandHandler<T>
Type Parameters:
T - The type of the ILayerCommand this ILayerCommandHandler handles. Needs to be a MoveSelectionCommand or subtype.
All Implemented Interfaces:
ILayerCommandHandler<T>
Direct Known Subclasses:
MoveCellSelectionCommandHandler

public abstract class MoveSelectionCommandHandler<T extends MoveSelectionCommand> extends Object implements ILayerCommandHandler<T>
Abstraction of the selection behavior during navigation in the grid. Implementations of this class specify what to select when the selection moves by responding to the MoveSelectionCommand.
See Also:
  • Field Details

    • selectionLayer

      protected final SelectionLayer selectionLayer
      The SelectionLayer instance which is needed to perform selection operations.
    • horizontalTraversalStrategy

      protected final ITraversalStrategy horizontalTraversalStrategy
      The strategy to use on horizontal traversal. Specifies the behavior when the movement reaches a border.
    • verticalTraversalStrategy

      protected final ITraversalStrategy verticalTraversalStrategy
      The strategy to use on vertical traversal. Specifies the behavior when the movement reaches a border.
  • Constructor Details

    • MoveSelectionCommandHandler

      public MoveSelectionCommandHandler(SelectionLayer selectionLayer)
      Create a MoveSelectionCommandHandler for the given SelectionLayer . Uses the ITraversalStrategy.AXIS_TRAVERSAL_STRATEGY as default strategy for selection movement.
      Parameters:
      selectionLayer - The SelectionLayer on which the selection should be performed.
    • MoveSelectionCommandHandler

      public MoveSelectionCommandHandler(SelectionLayer selectionLayer, ITraversalStrategy traversalStrategy)
      Create a MoveSelectionCommandHandler for the given SelectionLayer .
      Parameters:
      selectionLayer - The SelectionLayer on which the selection should be performed.
      traversalStrategy - The strategy that should be used for selection movements. Can not be null.
    • MoveSelectionCommandHandler

      public MoveSelectionCommandHandler(SelectionLayer selectionLayer, ITraversalStrategy horizontalTraversalStrategy, ITraversalStrategy verticalTraversalStrategy)
      Create a MoveSelectionCommandHandler for the given SelectionLayer .
      Parameters:
      selectionLayer - The SelectionLayer on which the selection should be performed.
      horizontalTraversalStrategy - The strategy that should be used for horizontal selection movements. Can not be null.
      verticalTraversalStrategy - The strategy that should be used for vertical selection movements. Can not be null.
  • Method Details

    • doCommand

      public boolean doCommand(ILayer targetLayer, T command)
      Specified by:
      doCommand in interface ILayerCommandHandler<T extends MoveSelectionCommand>
      Parameters:
      targetLayer - the target layer
      command - the command
      Returns:
      true if the command has been handled, false otherwise
    • getTraversalStrategy

      protected ITraversalStrategy getTraversalStrategy(T command)
      Determines the ITraversalStrategy that should be used to move the selection on handling the given command. The strategy is determined in the following way:
      1. Return the ITraversalStrategy carried by the command
      2. If it doesn't contain a ITraversalStrategy but a carries a dedicated step count, create a temporary ITraversalStrategy that is configured with the locally configured ITraversalStrategy but returns the step count carried by the command.
      3. If the command doesn't carry a ITraversalStrategy and no dedicated step count, the ITraversalStrategy registered with this command handler is returned.
      Parameters:
      command - The current handled command.
      Returns:
      The ITraversalStrategy that should be used to move the selection. null for SelectionLayer.MoveDirectionEnum.NONE.
    • moveSelection

      protected void moveSelection(SelectionLayer.MoveDirectionEnum moveDirection, ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
      Moves the selection from the current position into the given move direction.
      Parameters:
      moveDirection - The direction to move to.
      traversalStrategy - the traversal strategy to determine the number of steps to move and the behavior on moving over the border
      withShiftMask - boolean flag to indicate whether the shift key modifier is enabled or not
      withControlMask - boolean flag to indicate whether the control key modifier is enabled or not
    • moveLastSelectedRight

      protected abstract void moveLastSelectedRight(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
      Moves the selection from the current position to the right.
      Parameters:
      traversalStrategy - the traversal strategy to determine the number of steps to move and the behavior on moving over the border
      withShiftMask - boolean flag to indicate whether the shift key modifier is enabled or not
      withControlMask - boolean flag to indicate whether the control key modifier is enabled or not
    • moveLastSelectedLeft

      protected abstract void moveLastSelectedLeft(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
      Moves the selection from the current position to the left.
      Parameters:
      traversalStrategy - the traversal strategy to determine the number of steps to move and the behavior on moving over the border
      withShiftMask - boolean flag to indicate whether the shift key modifier is enabled or not
      withControlMask - boolean flag to indicate whether the control key modifier is enabled or not
    • moveLastSelectedUp

      protected abstract void moveLastSelectedUp(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
      Moves the selection from the current position up.
      Parameters:
      traversalStrategy - the traversal strategy to determine the number of steps to move and the behavior on moving over the border
      withShiftMask - boolean flag to indicate whether the shift key modifier is enabled or not
      withControlMask - boolean flag to indicate whether the control key modifier is enabled or not
    • moveLastSelectedDown

      protected abstract void moveLastSelectedDown(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
      Moves the selection from the current position down.
      Parameters:
      traversalStrategy - the traversal strategy to determine the number of steps to move and the behavior on moving over the border
      withShiftMask - boolean flag to indicate whether the shift key modifier is enabled or not
      withControlMask - boolean flag to indicate whether the control key modifier is enabled or not