Class SelectionUtils
java.lang.Object
org.eclipse.nebula.widgets.nattable.selection.SelectionUtils
Helper class to operate with selections.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
bothShiftAndControl
(boolean withShiftMask, boolean withControlMask) static ILayerCell
getBottomRightCellInSelection
(SelectionLayer selectionLayer) Returns the bottom right cell of a selected region.static <T> List<T>
getSelectedRowObjects
(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider, boolean fullySelectedRowsOnly) Inspects the current selection on the givenSelectionLayer
and returns a list of the corresponding list item objects.static boolean
hasConsecutiveSelection
(SelectionLayer selectionLayer) Checks whether the selected region tracked by the givenSelectionLayer
is consecutive or not.static boolean
isConsecutive
(int[] pos) Test if the numbers in the given array are consecutive.static boolean
isControlOnly
(boolean withShiftMask, boolean withControlMask) static boolean
isShiftOnly
(boolean withShiftMask, boolean withControlMask) static boolean
noShiftOrControl
(boolean withShiftMask, boolean withControlMask)
-
Method Details
-
noShiftOrControl
public static boolean noShiftOrControl(boolean withShiftMask, boolean withControlMask) - Parameters:
withShiftMask
- flag to indicate whether the shift masked is activewithControlMask
- 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 activewithControlMask
- 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 activewithControlMask
- 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 activewithControlMask
- 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
Checks whether the selected region tracked by the givenSelectionLayer
is consecutive or not.- Parameters:
selectionLayer
- TheSelectionLayer
that tracks the selection.- Returns:
true
if the current selection is consecutive,false
if not.- Since:
- 1.4
-
getBottomRightCellInSelection
Returns the bottom right cell of a selected region. Will only return an ILayerCell if the selected region is consecutive. Otherwisenull
will be returned.- Parameters:
selectionLayer
- TheSelectionLayer
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 givenSelectionLayer
and returns a list of the corresponding list item objects. Uses theIRowDataProvider
to be able to determine the row objects per selected row position.- Parameters:
selectionLayer
- TheSelectionLayer
to retrieve the selected row indexes from.rowDataProvider
- TheIRowDataProvider
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
-