Search in sources :

Example 76 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldUpdateSelectedRegionLeftWithShift.

@Test
public void shouldUpdateSelectedRegionLeftWithShift() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 0, 3, 2, 3, true, false));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(9, cellPositions.length);
    Rectangle region = new Rectangle(0, 3, 3, 3);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(3, this.selectionLayer.getSelectionAnchor().getRowPosition());
}
Also used : SelectRegionCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 77 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldUpdateSelectedRegionUpWithShift.

@Test
public void shouldUpdateSelectedRegionUpWithShift() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 0, 3, 1, true, false));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(12, cellPositions.length);
    Rectangle region = new Rectangle(2, 0, 3, 3);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(3, this.selectionLayer.getSelectionAnchor().getRowPosition());
}
Also used : SelectRegionCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 78 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldExtendSelectedRegionRightWithShift.

@Test
public void shouldExtendSelectedRegionRightWithShift() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 6, 3, 2, 3, true, false));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(18, cellPositions.length);
    Rectangle region = new Rectangle(2, 3, 6, 3);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(3, this.selectionLayer.getSelectionAnchor().getRowPosition());
}
Also used : SelectRegionCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 79 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class RowSearchStrategyTest method shouldSearchAllBodyCellsForRowInSelection.

@Test
public void shouldSearchAllBodyCellsForRowInSelection() {
    RowSearchStrategy rowStrategy = new RowSearchStrategy(new int[] { 2, 0, 4 }, this.configRegistry);
    rowStrategy.setComparator(new CellValueAsStringComparator<>());
    rowStrategy.setContextLayer(this.layer);
    PositionCoordinate cell = rowStrategy.executeSearch("[2,2]");
    assertEquals(2, cell.getColumnPosition());
    assertEquals(2, cell.getRowPosition());
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 80 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class SelectionSearchStrategyTest method shouldAccessWhatIsInSelection.

@Test
public void shouldAccessWhatIsInSelection() {
    // Select range of cells
    int startColumnPosition = 2;
    int startRowPosition = 1;
    final int lastColumn = 7;
    final int lastRow = 5;
    for (int columnPosition = startColumnPosition; columnPosition < lastColumn; columnPosition++) {
        for (int rowPosition = startRowPosition; rowPosition < lastRow; rowPosition++) {
            this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, columnPosition, rowPosition, false, true));
        }
    }
    // We should get 20 Cells from the body
    SelectionSearchStrategy selectionStrategy = new SelectionSearchStrategy(this.configRegistry);
    selectionStrategy.setWrapSearch(true);
    PositionCoordinate[] cellsToSearch = selectionStrategy.getSelectedCells(this.selectionLayer);
    assertEquals(20, cellsToSearch.length);
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) 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