use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class GridSearchStrategyTest method searchShouldWrapAroundColumn.
@Test
public void searchShouldWrapAroundColumn() {
// Select search starting point in composite coordinates
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 3, 4, false, false));
GridSearchStrategy gridStrategy = new GridSearchStrategy(this.configRegistry, false, true);
// If we don't specify to wrap the search, it will not find it.
gridStrategy.setContextLayer(this.selectionLayer);
gridStrategy.setCaseSensitive(true);
gridStrategy.setComparator(new CellValueAsStringComparator<>());
PositionCoordinate searchResult = gridStrategy.executeSearch("body");
assertNull(searchResult);
// Should find it when wrap search is enabled.
gridStrategy.setWrapSearch(true);
searchResult = gridStrategy.executeSearch("body");
assertNotNull(searchResult);
assertEquals(2, searchResult.columnPosition);
assertEquals(2, searchResult.rowPosition);
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class GridSearchStrategyTest method searchShouldMoveBackwardsToFindCell.
@Test
public void searchShouldMoveBackwardsToFindCell() {
// Select search starting point in composite coordinates
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 3, 4, false, false));
GridSearchStrategy gridStrategy = new GridSearchStrategy(this.configRegistry, false, ISearchDirection.SEARCH_BACKWARDS, true);
gridStrategy.setComparator(new CellValueAsStringComparator<>());
gridStrategy.setContextLayer(this.selectionLayer);
PositionCoordinate searchResult = gridStrategy.executeSearch("[1,3]");
assertNotNull(searchResult);
assertEquals(1, searchResult.columnPosition);
assertEquals(3, searchResult.rowPosition);
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class RowSearchStrategyTest method shouldAccessCellInSelectedRow.
@Test
public void shouldAccessCellInSelectedRow() {
// Select three rows for searching
RowSearchStrategy rowStrategy = new RowSearchStrategy(new int[] { 0, 2, 4 }, this.configRegistry);
PositionCoordinate[] cellsToSearch = rowStrategy.getRowCellsToSearch(this.layer);
PositionCoordinate cell = cellsToSearch[0];
assertEquals(0, cell.getRowPosition());
cell = cellsToSearch[10];
assertEquals(2, cell.getRowPosition());
cell = cellsToSearch[20];
assertEquals(4, cell.getRowPosition());
assertEquals(30, cellsToSearch.length);
// the SelectionLayer is not set as context layer, therefore nothing
// should happen
assertEquals(0, this.gridLayer.getBodyLayer().getSelectionLayer().getSelectedCells().size());
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerSelectionTest method shouldSelectAllCellsInGroupsToRightWithShiftInScrolledState.
@Test
public void shouldSelectAllCellsInGroupsToRightWithShiftInScrolledState() {
assertEquals(0, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
// scroll down
this.gridLayer.getBodyLayer().getViewportLayer().moveRowPositionIntoViewport(20);
assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
// trigger column group selection
this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(3));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(4));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
// no scrolling expected
assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
assertEquals(12, selectionAnchor.getRowPosition());
assertEquals(0, selectionAnchor.getColumnPosition());
this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, true, false));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(3));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(4));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
// no scrolling expected
assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
assertEquals(12, selectionAnchor.getRowPosition());
assertEquals(0, selectionAnchor.getColumnPosition());
}
use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerSelectionTest method shouldSelectInScrolledState.
@Test
public void shouldSelectInScrolledState() {
assertEquals(0, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
// scroll down
this.gridLayer.getBodyLayer().getViewportLayer().moveRowPositionIntoViewport(20);
assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
// trigger column group selection
this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
// no scrolling expected
assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
assertEquals(12, selectionAnchor.getRowPosition());
assertEquals(0, selectionAnchor.getColumnPosition());
}
Aggregations