Search in sources :

Example 1 with SelectRegionCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldUpdateAnchorOnDeselectRegion.

@Test
public void shouldUpdateAnchorOnDeselectRegion() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 1, false, false));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(3, this.selectionLayer.getSelectionAnchor().getRowPosition());
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 5, 3, 1, false, true));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(5, this.selectionLayer.getSelectionAnchor().getRowPosition());
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 4, 3, 1, false, true));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(4, this.selectionLayer.getSelectionAnchor().getRowPosition());
    // after de-selection the anchor should move up in the same column
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 4, 3, 1, false, true));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(3, this.selectionLayer.getSelectionAnchor().getRowPosition());
}
Also used : SelectRegionCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand) Test(org.junit.Test)

Example 2 with SelectRegionCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand 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 3 with SelectRegionCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand 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 4 with SelectRegionCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldSelectOtherRegion.

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

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldExtendSelectedRegionDownWithShift.

@Test
public void shouldExtendSelectedRegionDownWithShift() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 7, 3, 2, true, false));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(18, cellPositions.length);
    Rectangle region = new Rectangle(2, 3, 3, 6);
    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)

Aggregations

SelectRegionCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand)10 Rectangle (org.eclipse.swt.graphics.Rectangle)8 Test (org.junit.Test)8 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)7 ColumnPositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate)1 RowPositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.RowPositionCoordinate)1 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)1 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 ConfigureScalingCommand (org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand)1 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)1 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)1 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)1