Class SelectionUtils

java.lang.Object
org.eclipse.nebula.widgets.nattable.selection.SelectionUtils

public final class SelectionUtils extends Object
Helper class to operate with selections.
  • Method Details

    • noShiftOrControl

      public static boolean noShiftOrControl(boolean withShiftMask, boolean withControlMask)
      Parameters:
      withShiftMask - flag to indicate whether the shift masked is active
      withControlMask - flag to indicate whether the control masked is active
      Returns:
      true if both, shift and control mask, are not active
    • bothShiftAndControl

      public static boolean bothShiftAndControl(boolean withShiftMask, boolean withControlMask)
      Parameters:
      withShiftMask - flag to indicate whether the shift masked is active
      withControlMask - flag to indicate whether the control masked is active
      Returns:
      true if both, shift and control mask are active
    • isControlOnly

      public static boolean isControlOnly(boolean withShiftMask, boolean withControlMask)
      Parameters:
      withShiftMask - flag to indicate whether the shift masked is active
      withControlMask - flag to indicate whether the control masked is active
      Returns:
      true if only the control mask is active
    • isShiftOnly

      public static boolean isShiftOnly(boolean withShiftMask, boolean withControlMask)
      Parameters:
      withShiftMask - flag to indicate whether the shift masked is active
      withControlMask - flag to indicate whether the control masked is active
      Returns:
      true if only the shift mask is active
    • isConsecutive

      public static boolean isConsecutive(int[] pos)
      Test if the numbers in the given array are consecutive. If there are duplicates or gaps in the array, false will be returned.
      Parameters:
      pos - the array of numbers to check
      Returns:
      true if the numbers are consecutive, false if there are duplicates or gaps.
      Since:
      1.4
    • hasConsecutiveSelection

      public static boolean hasConsecutiveSelection(SelectionLayer selectionLayer)
      Checks whether the selected region tracked by the given SelectionLayer is consecutive or not.
      Parameters:
      selectionLayer - The SelectionLayer that tracks the selection.
      Returns:
      true if the current selection is consecutive, false if not.
      Since:
      1.4
    • getBottomRightCellInSelection

      public static ILayerCell getBottomRightCellInSelection(SelectionLayer selectionLayer)
      Returns the bottom right cell of a selected region. Will only return an ILayerCell if the selected region is consecutive. Otherwise null will be returned.
      Parameters:
      selectionLayer - The SelectionLayer needed to determine the selection.
      Returns:
      The bottom right cell of a selected region or null if the selected region is not consecutive.
      Since:
      1.4
    • getSelectedRowObjects

      public static <T> List<T> getSelectedRowObjects(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider, boolean fullySelectedRowsOnly)
      Inspects the current selection on the given SelectionLayer and returns a list of the corresponding list item objects. Uses the IRowDataProvider to be able to determine the row objects per selected row position.
      Parameters:
      selectionLayer - The SelectionLayer to retrieve the selected row indexes from.
      rowDataProvider - The IRowDataProvider to retrieve the object for the row index.
      fullySelectedRowsOnly - Flag to determine if only fully selected rows should be taken into account.
      Returns:
      The list of all objects that are currently marked as selected. Never null.
      Since:
      1.4