Class MoveSelectionCommandHandler<T extends MoveSelectionCommand>
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.selection.MoveSelectionCommandHandler<T>
-
- Type Parameters:
T
- The type of theILayerCommand
thisILayerCommandHandler
handles. Needs to be aMoveSelectionCommand
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 theMoveSelectionCommand
.
-
-
Field Summary
Fields Modifier and Type Field Description protected ITraversalStrategy
horizontalTraversalStrategy
The strategy to use on horizontal traversal.protected SelectionLayer
selectionLayer
The SelectionLayer instance which is needed to perform selection operations.protected ITraversalStrategy
verticalTraversalStrategy
The strategy to use on vertical traversal.
-
Constructor Summary
Constructors Constructor Description MoveSelectionCommandHandler(SelectionLayer selectionLayer)
Create a MoveSelectionCommandHandler for the givenSelectionLayer
.MoveSelectionCommandHandler(SelectionLayer selectionLayer, ITraversalStrategy traversalStrategy)
Create a MoveSelectionCommandHandler for the givenSelectionLayer
.MoveSelectionCommandHandler(SelectionLayer selectionLayer, ITraversalStrategy horizontalTraversalStrategy, ITraversalStrategy verticalTraversalStrategy)
Create a MoveSelectionCommandHandler for the givenSelectionLayer
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
doCommand(ILayer targetLayer, T command)
protected ITraversalStrategy
getTraversalStrategy(T command)
Determines theITraversalStrategy
that should be used to move the selection on handling the given command.protected abstract void
moveLastSelectedDown(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
Moves the selection from the current position down.protected abstract void
moveLastSelectedLeft(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
Moves the selection from the current position to the left.protected abstract void
moveLastSelectedRight(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
Moves the selection from the current position to the right.protected abstract void
moveLastSelectedUp(ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
Moves the selection from the current position up.protected void
moveSelection(SelectionLayer.MoveDirectionEnum moveDirection, ITraversalStrategy traversalStrategy, boolean withShiftMask, boolean withControlMask)
Moves the selection from the current position into the given move direction.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.nebula.widgets.nattable.command.ILayerCommandHandler
getCommandClass
-
-
-
-
Field Detail
-
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 Detail
-
MoveSelectionCommandHandler
public MoveSelectionCommandHandler(SelectionLayer selectionLayer)
Create a MoveSelectionCommandHandler for the givenSelectionLayer
. Uses theITraversalStrategy.AXIS_TRAVERSAL_STRATEGY
as default strategy for selection movement.- Parameters:
selectionLayer
- TheSelectionLayer
on which the selection should be performed.
-
MoveSelectionCommandHandler
public MoveSelectionCommandHandler(SelectionLayer selectionLayer, ITraversalStrategy traversalStrategy)
Create a MoveSelectionCommandHandler for the givenSelectionLayer
.- Parameters:
selectionLayer
- TheSelectionLayer
on which the selection should be performed.traversalStrategy
- The strategy that should be used for selection movements. Can not benull
.
-
MoveSelectionCommandHandler
public MoveSelectionCommandHandler(SelectionLayer selectionLayer, ITraversalStrategy horizontalTraversalStrategy, ITraversalStrategy verticalTraversalStrategy)
Create a MoveSelectionCommandHandler for the givenSelectionLayer
.- Parameters:
selectionLayer
- TheSelectionLayer
on which the selection should be performed.horizontalTraversalStrategy
- The strategy that should be used for horizontal selection movements. Can not benull
.verticalTraversalStrategy
- The strategy that should be used for vertical selection movements. Can not benull
.
-
-
Method Detail
-
doCommand
public boolean doCommand(ILayer targetLayer, T command)
- Specified by:
doCommand
in interfaceILayerCommandHandler<T extends MoveSelectionCommand>
- Parameters:
targetLayer
- the target layercommand
- the command- Returns:
- true if the command has been handled, false otherwise
-
getTraversalStrategy
protected ITraversalStrategy getTraversalStrategy(T command)
Determines theITraversalStrategy
that should be used to move the selection on handling the given command. The strategy is determined in the following way:- Return the
ITraversalStrategy
carried by the command - If it doesn't contain a
ITraversalStrategy
but a carries a dedicated step count, create a temporaryITraversalStrategy
that is configured with the locally configuredITraversalStrategy
but returns the step count carried by the command. - If the command doesn't carry a
ITraversalStrategy
and no dedicated step count, theITraversalStrategy
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
forSelectionLayer.MoveDirectionEnum.NONE
.
- Return the
-
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 borderwithShiftMask
- boolean flag to indicate whether the shift key modifier is enabled or notwithControlMask
- 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 borderwithShiftMask
- boolean flag to indicate whether the shift key modifier is enabled or notwithControlMask
- 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 borderwithShiftMask
- boolean flag to indicate whether the shift key modifier is enabled or notwithControlMask
- 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 borderwithShiftMask
- boolean flag to indicate whether the shift key modifier is enabled or notwithControlMask
- 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 borderwithShiftMask
- boolean flag to indicate whether the shift key modifier is enabled or notwithControlMask
- boolean flag to indicate whether the control key modifier is enabled or not
-
-