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