Search in sources :

Example 66 with PositionCoordinate

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);
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 67 with PositionCoordinate

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);
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 68 with PositionCoordinate

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());
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 69 with PositionCoordinate

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());
}
Also used : ViewportSelectColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 70 with PositionCoordinate

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());
}
Also used : ViewportSelectColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Aggregations

PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)97 Test (org.junit.Test)55 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)15 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 SelectRegionCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand)7 ArrayList (java.util.ArrayList)5 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)5 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)5 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)4 ViewportSelectColumnGroupCommand (org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand)4 SearchEvent (org.eclipse.nebula.widgets.nattable.search.event.SearchEvent)4 SelectAllCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand)4 ILayerListener (org.eclipse.nebula.widgets.nattable.layer.ILayerListener)3 HashSet (java.util.HashSet)2 Pattern (java.util.regex.Pattern)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 ColumnPositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate)2 RowPositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.RowPositionCoordinate)2 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)2