Class RowGroupUtils
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.group.RowGroupUtils
-
public final class RowGroupUtils extends Object
The utility methods in this class bridge the divide between the world of row indexes and positions and row objects used the model.- Author:
- Stefan Bolton, Matt Biggs
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> IRowGroup<T>
getOwnRowGroupForRowIndex(IRowGroupModel<T> model, int rowIndex)
static <T> IRowGroup<T>
getRowGroupForRowIndex(IRowGroupModel<T> model, int rowIndex)
static <T> String
getRowGroupNameForIndex(IRowGroupModel<T> model, int bodyRowIndex)
static <T> List<Integer>
getRowIndexesInGroup(IRowGroupModel<T> model, int rowIndex)
static <T> List<Integer>
getRowIndexesInGroup(IRowGroupModel<T> model, IRowGroup<T> group, boolean includeStatic)
Return the row indexes of the rows that belong to a group.static <T> int[]
getRowIndexesInGroupAsArray(IRowGroupModel<T> model, int rowIndex)
static <T> int[]
getRowIndexesInGroupAsArray(IRowGroupModel<T> model, IRowGroup<T> group, boolean includeStatic)
Return the row indexes of the rows that belong to a group.static int[]
getRowPositionsInGroup(IUniqueIndexLayer layer, int... bodyRowIndexes)
Helper method to get the row positions for a specified layer If a row is currently invisible (-1) it will not be returned within the collectionstatic List<Integer>
getRowPositionsInGroup(IUniqueIndexLayer layer, Collection<Integer> bodyRowIndexes)
Helper method to get the row positions for a specified layer If a row is currently invisible (-1) it will not be returned within the collectionstatic <T> IRowGroup<T>
getTopMostParentGroup(IRowGroup<T> rowGroup)
static <T> boolean
isAnyParentCollapsed(IRowGroup<T> group)
static boolean
isBetweenTwoGroups(RowGroupHeaderLayer rowGroupHeaderLayer, int toPosition, boolean reorderToTopEdge, SelectionLayer.MoveDirectionEnum moveDirection)
Checks if the edge of a row position is the top-most or the bottom most row on any level of a row group.static boolean
isBetweenTwoGroups(RowGroupHeaderLayer rowGroupHeaderLayer, int level, int toPosition, boolean reorderToTopEdge, SelectionLayer.MoveDirectionEnum moveDirection)
Checks if the edge of a row position for a specific grouping level is the top-most or the bottom most row of a row group.static boolean
isBetweenTwoGroups(ILayer natLayer, int startY, int endY, RowGroupHeaderLayer layer, int level)
Checks if the row positions at the given y coordinates belong to the same group or not.static <T> boolean
isCollapsed(IRowGroupModel<T> model, IRowGroup<T> group)
static boolean
isGroupReordered(GroupModel.Group fromGroup, int[] fromPositions)
Check if a complete group is reordered.static <T> boolean
isInTheSameGroup(int fromRowIndex, int toRowIndex, IRowGroupModel<T> model)
static boolean
isInTheSameGroup(RowGroupHeaderLayer layer, int level, int fromPosition, int toPosition)
Checks if the two given row positions on the given layer belong to the same group at the given level on the givenRowGroupHeaderLayer
.static <T> boolean
isPartOfAGroup(IRowGroupModel<T> model, int rowIndex)
static boolean
isReorderValid(RowGroupHeaderLayer rowGroupHeaderLayer, int fromPosition, int toPosition, boolean reorderToTopEdge)
Checks if a reorder operation is valid by checking the unbreakable states of the groups below the from and the to position.static boolean
isReorderValid(RowGroupHeaderLayer rowGroupHeaderLayer, int level, int fromPosition, int toPosition, boolean reorderToTopEdge)
Checks if a reorder operation is valid by checking the unbreakable states of the groups below the from and the to position.static boolean
isRowIndexHiddenInUnderLyingLayer(int rowIndex, ILayer layer, IUniqueIndexLayer underlyingLayer)
static <T> boolean
isStaticRow(IRowGroupModel<T> model, int bodyRowIndex)
static <T> int
sizeOfGroup(IRowGroupModel<T> model, int bodyRowIndex)
-
-
-
Method Detail
-
getRowGroupForRowIndex
public static <T> IRowGroup<T> getRowGroupForRowIndex(IRowGroupModel<T> model, int rowIndex)
-
getOwnRowGroupForRowIndex
public static <T> IRowGroup<T> getOwnRowGroupForRowIndex(IRowGroupModel<T> model, int rowIndex)
-
isPartOfAGroup
public static <T> boolean isPartOfAGroup(IRowGroupModel<T> model, int rowIndex)
-
isInTheSameGroup
public static <T> boolean isInTheSameGroup(int fromRowIndex, int toRowIndex, IRowGroupModel<T> model)
-
isCollapsed
public static <T> boolean isCollapsed(IRowGroupModel<T> model, IRowGroup<T> group)
- Parameters:
model
- TheIRowGroupModel
the givenIRowGroup
belongs to.group
- TheIRowGroup
to check.- Returns:
true
if the given row group or one of its parent groups is collapsed.
-
isAnyParentCollapsed
public static <T> boolean isAnyParentCollapsed(IRowGroup<T> group)
- Parameters:
group
- TheIRowGroup
to check.- Returns:
true
if any of the groups parent groups is collapsed.
-
sizeOfGroup
public static <T> int sizeOfGroup(IRowGroupModel<T> model, int bodyRowIndex)
- Parameters:
model
- TheIRowGroupModel
to check.bodyRowIndex
- The index of a row whose row group should be inspected.- Returns:
- The number of rows in the row group to which the given bodyRowIndex belongs to.
-
getTopMostParentGroup
public static <T> IRowGroup<T> getTopMostParentGroup(IRowGroup<T> rowGroup)
- Parameters:
rowGroup
- TheIRowGroup
to check.- Returns:
- the top-most parent group of the given group or the group specified if it has no parents.
-
isStaticRow
public static <T> boolean isStaticRow(IRowGroupModel<T> model, int bodyRowIndex)
- Parameters:
model
- TheIRowGroupModel
to check.bodyRowIndex
- The index of a row whose row group should be inspected.- Returns:
true
ifbodyRowIndex
is contained in the list of static rows of the row group this index belongs to
-
isRowIndexHiddenInUnderLyingLayer
public static boolean isRowIndexHiddenInUnderLyingLayer(int rowIndex, ILayer layer, IUniqueIndexLayer underlyingLayer)
-
getRowPositionsInGroup
public static List<Integer> getRowPositionsInGroup(IUniqueIndexLayer layer, Collection<Integer> bodyRowIndexes)
Helper method to get the row positions for a specified layer If a row is currently invisible (-1) it will not be returned within the collection- Parameters:
layer
- The layer for which the position transformation should be performed.bodyRowIndexes
- The row indexes for which the positions are requested.- Returns:
- Unmodifiable list of the row positions for the given layer
-
getRowIndexesInGroup
public static <T> List<Integer> getRowIndexesInGroup(IRowGroupModel<T> model, int rowIndex)
- Parameters:
model
- TheIRowGroupModel
to check.rowIndex
- The index of a row whose row group should be inspected.- Returns:
- Unmodifiable list of row indexes and static row indexes in the same group as this index
-
getRowIndexesInGroup
public static <T> List<Integer> getRowIndexesInGroup(IRowGroupModel<T> model, IRowGroup<T> group, boolean includeStatic)
Return the row indexes of the rows that belong to a group.- Type Parameters:
T
- The type of the objects in the backing data.- Parameters:
model
- TheIRowGroupModel
to check.group
- TheIRowGroup
to check.includeStatic
-true
if static rows should be included,false
if not.- Returns:
- The row indexes of the rows that belong to the given group.
-
getRowPositionsInGroup
public static int[] getRowPositionsInGroup(IUniqueIndexLayer layer, int... bodyRowIndexes)
Helper method to get the row positions for a specified layer If a row is currently invisible (-1) it will not be returned within the collection- Parameters:
layer
- The layer for which the position transformation should be performed.bodyRowIndexes
- The row indexes for which the positions are requested.- Returns:
- The row positions for the given layer.
- Since:
- 2.0
-
getRowIndexesInGroupAsArray
public static <T> int[] getRowIndexesInGroupAsArray(IRowGroupModel<T> model, int rowIndex)
- Parameters:
model
- TheIRowGroupModel
to check.rowIndex
- The index of a row whose row group should be inspected.- Returns:
- The row indexes and static row indexes in the same group as this index.
- Since:
- 2.0
-
getRowIndexesInGroupAsArray
public static <T> int[] getRowIndexesInGroupAsArray(IRowGroupModel<T> model, IRowGroup<T> group, boolean includeStatic)
Return the row indexes of the rows that belong to a group.- Type Parameters:
T
- The type of the objects in the backing data.- Parameters:
model
- TheIRowGroupModel
to check.group
- TheIRowGroup
to check.includeStatic
-true
if static rows should be included,false
if not.- Returns:
- The row indexes of the rows that belong to the given group.
- Since:
- 2.0
-
getRowGroupNameForIndex
public static <T> String getRowGroupNameForIndex(IRowGroupModel<T> model, int bodyRowIndex)
-
isInTheSameGroup
public static boolean isInTheSameGroup(RowGroupHeaderLayer layer, int level, int fromPosition, int toPosition)
Checks if the two given row positions on the given layer belong to the same group at the given level on the givenRowGroupHeaderLayer
.- Parameters:
layer
- TheRowGroupHeaderLayer
which is needed to perform the check against.level
- The grouping level to check.fromPosition
- The row position to check based on the position layer of the givenRowGroupHeaderLayer
.toPosition
- The row position to check based on the position layer of the givenRowGroupHeaderLayer
.- Returns:
true
if both given positions belong to the same group,false
if not.- Since:
- 1.6
-
isBetweenTwoGroups
public static boolean isBetweenTwoGroups(ILayer natLayer, int startY, int endY, RowGroupHeaderLayer layer, int level)
Checks if the row positions at the given y coordinates belong to the same group or not.- Parameters:
natLayer
- The layer to which the given positions match. Typically the NatTable itself.startY
- The y coordinate of the row that should be checked. Typically the drag start y coordinate.endY
- The y coordinate of the row that should be checked. Typically the drag end y coordinate.layer
- TheRowGroupHeaderLayer
which is needed to perform the check against.level
- The grouping level to check.- Returns:
true
if there is a row group boundary between startY and endY,false
if both positions are in the same group.- Since:
- 1.6
-
isBetweenTwoGroups
public static boolean isBetweenTwoGroups(RowGroupHeaderLayer rowGroupHeaderLayer, int toPosition, boolean reorderToTopEdge, SelectionLayer.MoveDirectionEnum moveDirection)
Checks if the edge of a row position is the top-most or the bottom most row on any level of a row group.- Parameters:
rowGroupHeaderLayer
- TheRowGroupHeaderLayer
to handle the checks.toPosition
- The position to check. Needs to be related to the positionLayer.reorderToTopEdge
-true
if the check should be performed to the top edge or the bottom edge of the toPosition.moveDirection
- The direction in which the reordering is performed.- Returns:
true
if the destination would be between two groups,false
if the destination would be inside a group.- Since:
- 1.6
-
isBetweenTwoGroups
public static boolean isBetweenTwoGroups(RowGroupHeaderLayer rowGroupHeaderLayer, int level, int toPosition, boolean reorderToTopEdge, SelectionLayer.MoveDirectionEnum moveDirection)
Checks if the edge of a row position for a specific grouping level is the top-most or the bottom most row of a row group.- Parameters:
rowGroupHeaderLayer
- TheRowGroupHeaderLayer
to handle the checks.level
- The grouping level on which the check should be performed.toPosition
- The position to check. Needs to be related to the positionLayer.reorderToTopEdge
-true
if the check should be performed to the top edge or the bottom edge of the toPosition.moveDirection
- The direction in which the reordering is performed.- Returns:
true
if the destination would be between two groups,false
if the destination would be inside a group.- Since:
- 1.6
-
isReorderValid
public static boolean isReorderValid(RowGroupHeaderLayer rowGroupHeaderLayer, int fromPosition, int toPosition, boolean reorderToTopEdge)
Checks if a reorder operation is valid by checking the unbreakable states of the groups below the from and the to position.- Parameters:
rowGroupHeaderLayer
- TheRowGroupHeaderLayer
to get the groups to check.fromPosition
- The position from which a row should be reordered.toPosition
- The position to which a row should be reordered.reorderToTopEdge
-true
if the reorder should be performed to the top edge of the toPosition.- Returns:
true
if the reorder operation would be valid,false
if the either the source or the target belongs to an unbreakable group.- Since:
- 1.6
-
isReorderValid
public static boolean isReorderValid(RowGroupHeaderLayer rowGroupHeaderLayer, int level, int fromPosition, int toPosition, boolean reorderToTopEdge)
Checks if a reorder operation is valid by checking the unbreakable states of the groups below the from and the to position.- Parameters:
rowGroupHeaderLayer
- TheRowGroupHeaderLayer
to get the groups to check.level
- The grouping level that should be checked.fromPosition
- The position from which a row should be reordered.toPosition
- The position to which a row should be reordered.reorderToTopEdge
-true
if the reorder should be performed to the top edge of the toPosition.- Returns:
true
if the reorder operation would be valid,false
if the either the source or the target belongs to an unbreakable group.- Since:
- 1.6
-
isGroupReordered
public static boolean isGroupReordered(GroupModel.Group fromGroup, int[] fromPositions)
Check if a complete group is reordered.- Parameters:
fromGroup
- The group to check.fromPositions
- The positions to check.- Returns:
true
if the fromPositions are all part of the given group.- Since:
- 1.6
-
-