Interface ITraversalStrategy

  • All Known Implementing Classes:
    EditTraversalStrategy, HierarchicalTraversalStrategy

    public interface ITraversalStrategy
    This interface is used to configure the traversal behavior when moving the selection in a NatTable via key actions, e.g. tab or the arrow keys. You can specify the scope, if the traversal should cycle and specify logic to determine the step count if necessary. It is also possible to add logic that determines whether a target is a valid selection movement target. This allows traversal of editable cells while non-editable cells would be skipped.
    • Field Detail

      • AXIS_TRAVERSAL_STRATEGY

        static final ITraversalStrategy AXIS_TRAVERSAL_STRATEGY
        ITraversalStrategy that specifies the following:
        • traversal scope = axis
        • cycle = false
        • step count = 1
        • valid = true
        This means for example, on moving a selection to the right, the selection will move one cell at a time and stop at the right border.

        This is the default traversal strategy.

      • AXIS_CYCLE_TRAVERSAL_STRATEGY

        static final ITraversalStrategy AXIS_CYCLE_TRAVERSAL_STRATEGY
        ITraversalStrategy that specifies the following:
        • traversal scope = axis
        • cycle = true
        • step count = 1
        • valid = true
        This means for example, on moving a selection to the right, the selection will move one cell at a time and jump to the first column when moving over the right border.
      • TABLE_TRAVERSAL_STRATEGY

        static final ITraversalStrategy TABLE_TRAVERSAL_STRATEGY
        ITraversalStrategy that specifies the following:
        • traversal scope = table
        • cycle = false
        • step count = 1
        • valid = true
        This means for example, on moving a selection to the right, the selection will move one cell at a time and jump to the first column and move one row down when moving over the right border. At the end of the table the selection will stop and doesn't move to the beginning.
      • TABLE_CYCLE_TRAVERSAL_STRATEGY

        static final ITraversalStrategy TABLE_CYCLE_TRAVERSAL_STRATEGY
        ITraversalStrategy that specifies the following:
        • traversal scope = table
        • cycle = true
        • step count = 1
        • valid = true
        This means for example, on moving a selection to the right, the selection will move one cell at a time and jump to the first column and move one row down when moving over the right border. At the end of the table the selection will cycle to the beginning of the table.
    • Method Detail

      • isCycle

        boolean isCycle()
        Returns:
        true if on traversal the selection should cycle, false if the selection should stay at the last/first position without cycling.
      • getStepCount

        int getStepCount()
        Returns:
        The number of steps to jump on traversal.
      • isValidTarget

        boolean isValidTarget​(ILayerCell from,
                              ILayerCell to)
        Checks whether the ILayerCell that would be selected after the selection movement is valid or not. In case the target is invalid, the responsible command handler is able to react accordingly, e.g. move the next valid cell.

        This is for example useful for editing traversal. If the selection movement is triggered on committing a value in an editor, the next editable cell should be selected and the editor opened immediately.

        Parameters:
        from - The ILayerCell from which the selection movement is started.
        to - The ILayerCell to which the selection movement should be performed.
        Returns:
        true if the target is a valid target for selection movement, false if not