use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class SelectionUtils method getBottomRightCellInSelection.
/**
* Returns the bottom right cell of a selected region. Will only return an
* ILayerCell if the selected region is consecutive. Otherwise
* <code>null</code> will be returned.
*
* @param selectionLayer
* The {@link SelectionLayer} needed to determine the selection.
*
* @return The bottom right cell of a selected region or <code>null</code>
* if the selected region is not consecutive.
*
* @since 1.4
*/
public static ILayerCell getBottomRightCellInSelection(SelectionLayer selectionLayer) {
if (hasConsecutiveSelection(selectionLayer)) {
int column = -1;
int row = -1;
for (PositionCoordinate coord : selectionLayer.getSelectedCellPositions()) {
column = Math.max(column, coord.columnPosition);
row = Math.max(row, coord.rowPosition);
}
return selectionLayer.getCellByPosition(column, row);
}
return null;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class CellDisplayValueSearchUtil method findCell.
/**
* Finds the first matching cell in a list of grid cell rectangles.
*
* @param layer
* @param configRegistry
* @param cellRectangles
* @param valueToMatch
* @param comparator
* @param caseSensitive
* @param wholeWord
* @param regex
* @param includeCollapsed
* TODO currently ignored
* @return
* @throws PatternSyntaxException
*/
static PositionCoordinate findCell(final ILayer layer, final IConfigRegistry configRegistry, final List<GridRectangle> cellRectangles, final Object valueToMatch, final Comparator<String> comparator, final boolean caseSensitive, final boolean wholeWord, final boolean regex, final boolean columnFirst, final boolean includeCollapsed) throws PatternSyntaxException {
String stringValue = caseSensitive ? valueToMatch.toString() : valueToMatch.toString().toLowerCase();
Pattern pattern = regex ? Pattern.compile(stringValue) : null;
for (GridRectangle cellRectangle : cellRectangles) {
int direction = cellRectangle.firstDim.size() > 0 || cellRectangle.secondDim.size() > 0 ? 1 : -1;
for (int i = cellRectangle.firstDim.start; Math.abs(cellRectangle.firstDim.end - i) > 0; i += direction) {
PositionCoordinate result = findCell(layer, configRegistry, i, cellRectangle.secondDim.start, cellRectangle.secondDim.end, direction, pattern, stringValue, comparator, caseSensitive, wholeWord, regex, columnFirst, includeCollapsed);
if (result != null) {
return result;
}
}
}
return null;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class CellDisplayValueSearchUtil method findCell.
/**
* Finds the first matching cell in a table slice.
*
* @param layer
* @param configRegistry
* @param firstDimIndex
* @param secondDimStart
* @param secondDimEnd
* @param direction
* @param pattern
* @param stringValue
* @param comparator
* @param caseSensitive
* @param wholeWord
* @param regex
* @param columnFirst
* @param includeCollapsed
* @return
* @throws PatternSyntaxException
*/
private static PositionCoordinate findCell(ILayer layer, IConfigRegistry configRegistry, int firstDimIndex, int secondDimStart, int secondDimEnd, int direction, Pattern pattern, String stringValue, Comparator<String> comparator, boolean caseSensitive, boolean wholeWord, boolean regex, final boolean columnFirst, boolean includeCollapsed) throws PatternSyntaxException {
int columnPosition;
int rowPosition;
if (columnFirst) {
columnPosition = firstDimIndex;
rowPosition = secondDimStart;
} else {
columnPosition = secondDimStart;
rowPosition = firstDimIndex;
}
for (int i = secondDimStart; direction * (secondDimEnd - i) > 0; i += direction) {
ILayerCell cellByPosition = layer.getCellByPosition(columnPosition, rowPosition);
PositionCoordinate searchAnchor = getSearchAnchor(cellByPosition, direction);
// Thus we skip the compare and proceed to the next position.
if (searchAnchor.columnPosition == columnPosition && searchAnchor.rowPosition == rowPosition) {
if (compare(layer, configRegistry, pattern, stringValue, comparator, caseSensitive, wholeWord, regex, columnPosition, rowPosition)) {
return new PositionCoordinate(layer, columnPosition, rowPosition);
}
}
if (columnFirst) {
rowPosition += direction;
} else {
columnPosition += direction;
}
}
return null;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class CellDisplayValueSearchUtil method getCellCoordinates.
static List<PositionCoordinate> getCellCoordinates(ILayer contextLayer, int startingColumnPosition, int startingRowPosition, int width, int height) {
List<PositionCoordinate> coordinates = new ArrayList<PositionCoordinate>(width * height);
for (int columnPosition = 0; columnPosition < width; columnPosition++) {
for (int rowPosition = 0; rowPosition < height; rowPosition++) {
PositionCoordinate coordinate = new PositionCoordinate(contextLayer, startingColumnPosition, startingRowPosition++);
coordinates.add(coordinate);
}
startingColumnPosition++;
}
return coordinates;
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class CellDisplayValueSearchUtil method getDescendingCellCoordinates.
static List<PositionCoordinate> getDescendingCellCoordinates(ILayer contextLayer, int startingColumnPosition, int startingRowPosition, int width, int height) {
List<PositionCoordinate> coordinates = new ArrayList<PositionCoordinate>(width * height);
for (int columnPosition = width; columnPosition >= 0 && startingColumnPosition >= 0; columnPosition--) {
for (int rowPosition = height; rowPosition >= 0 && startingRowPosition >= 0; rowPosition--) {
PositionCoordinate coordinate = new PositionCoordinate(contextLayer, startingColumnPosition, startingRowPosition--);
coordinates.add(coordinate);
}
startingColumnPosition--;
}
return coordinates;
}
Aggregations