Search in sources :

Example 6 with PositionCoordinate

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

the class ColumnGroupHeaderLayerSelectionTest method shouldMoveAnchorOnDeselectWithCtrl.

@Test
public void shouldMoveAnchorOnDeselectWithCtrl() {
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    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(5));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, selectionAnchor.getRowPosition());
    assertEquals(5, selectionAnchor.getColumnPosition());
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    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(5));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, 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 7 with PositionCoordinate

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

the class SelectionLayerTest method testGetLastSelectedCellPosition.

@Test
public void testGetLastSelectedCellPosition() {
    this.selectionLayer.selectAll();
    PositionCoordinate existingSelectedCell = this.selectionLayer.getLastSelectedCell();
    assertSame(existingSelectedCell, this.selectionLayer.getLastSelectedCellPosition());
    assertNotNull(existingSelectedCell);
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 8 with PositionCoordinate

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

the class RegionSelectionTest method shouldAppendSelectedRegionWithCtrl.

@Test
public void shouldAppendSelectedRegionWithCtrl() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 7, 3, 1, false, true));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(12, cellPositions.length);
    Rectangle region = new Rectangle(2, 3, 3, 3);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    region = new Rectangle(2, 7, 3, 1);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    region = new Rectangle(2, 3, 3, 5);
    assertFalse("all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(7, 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 9 with PositionCoordinate

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

the class RegionSelectionTest method shouldSelectRegion.

@Test
public void shouldSelectRegion() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(9, cellPositions.length);
    Rectangle region = new Rectangle(2, 3, 3, 3);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    region = new Rectangle(1, 1, 2, 2);
    assertFalse("all cells 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 10 with PositionCoordinate

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

the class RowSelectionTest method onlyOneCellSelectedAtAnyTime.

@Test
public void onlyOneCellSelectedAtAnyTime() {
    this.selectionLayer.getSelectionModel().setMultipleSelectionAllowed(false);
    this.selectionLayer.clear();
    this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 1, 0, false, true));
    Collection<PositionCoordinate> cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
    assertEquals(1, cells.size());
    assertEquals(1, this.selectionLayer.getSelectedRowPositions().size());
    assertEquals(1, this.selectionLayer.getSelectedRowCount());
    // select another row with control mask
    this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 1, 2, false, true));
    cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
    assertEquals(1, cells.size());
    assertEquals(1, this.selectionLayer.getSelectedRowPositions().size());
    assertEquals(1, this.selectionLayer.getSelectedRowCount());
    // select additional rows with shift mask
    this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 1, 5, true, false));
    cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
    assertEquals(1, cells.size());
    assertEquals(1, this.selectionLayer.getSelectedRowPositions().size());
    assertEquals(1, this.selectionLayer.getSelectedRowCount());
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) 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