use of org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerSelectionTest method shouldMoveAnchorOnDeselectWithCtrlWithPreserve.
@Test
public void shouldMoveAnchorOnDeselectWithCtrlWithPreserve() {
this.gridLayer.getBodyLayer().getSelectionLayer().setSelectionModel(new PreserveSelectionModel<>(this.gridLayer.getBodyLayer().getSelectionLayer(), this.dataProvider, new IRowIdAccessor<NumberValues>() {
@Override
public Serializable getRowId(NumberValues rowObject) {
return rowObject.getColumnOneNumber();
}
}));
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.group.command.ViewportSelectColumnGroupCommand 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.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerSelectionTest method shouldSelectAllCellsInGroup.
@Test
public void shouldSelectAllCellsInGroup() {
this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
assertEquals(1, this.layerListener.getEventsCount());
assertTrue(this.layerListener.containsInstanceOf(RowSelectionEvent.class));
RowSelectionEvent event = (RowSelectionEvent) this.layerListener.getReceivedEvent(RowSelectionEvent.class);
Collection<Range> rowPositionRanges = event.getRowPositionRanges();
assertEquals(1, rowPositionRanges.size());
assertEquals(new Range(0, this.gridLayer.getBodyLayer().getSelectionLayer().getRowCount()), rowPositionRanges.iterator().next());
}
use of org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerSelectionTest method shouldDeselectAndSelectAllCellsInGroup.
@Test
public void shouldDeselectAndSelectAllCellsInGroup() {
this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, false));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
}
use of org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerSelectionTest method shouldSelectAllCellsInGroupWithCtrl.
@Test
public void shouldSelectAllCellsInGroupWithCtrl() {
this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
assertEquals(1, this.layerListener.getEventsCount());
assertTrue(this.layerListener.containsInstanceOf(RowSelectionEvent.class));
RowSelectionEvent event = (RowSelectionEvent) this.layerListener.getReceivedEvent(RowSelectionEvent.class);
Collection<Range> rowPositionRanges = event.getRowPositionRanges();
assertEquals(1, rowPositionRanges.size());
assertEquals(new Range(0, this.gridLayer.getBodyLayer().getSelectionLayer().getRowCount()), rowPositionRanges.iterator().next());
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
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(3));
assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(4));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
}
Aggregations