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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations