Search in sources :

Example 6 with ViewportSelectColumnGroupCommand

use of org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method shouldSelectAllCellsInGroupsToLeftWithShift.

@Test
public void shouldSelectAllCellsInGroupsToLeftWithShift() {
    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));
    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));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, true, false));
    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(3));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(4));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    // since the selection with shift is calculated from the anchor
    // position, column 6 is now not selected anymore
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
}
Also used : ViewportSelectColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand) Test(org.junit.Test)

Example 7 with ViewportSelectColumnGroupCommand

use of org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method shouldSelectAllCellsInGroupsToRightWithShift.

@Test
public void shouldSelectAllCellsInGroupsToRightWithShift() {
    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());
    this.layerListener.clearReceivedEvents();
    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));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, true, false));
    assertEquals(1, this.layerListener.getEventsCount());
    assertTrue(this.layerListener.containsInstanceOf(RowSelectionEvent.class));
    event = (RowSelectionEvent) this.layerListener.getReceivedEvent(RowSelectionEvent.class);
    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));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(3));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(4));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
}
Also used : ViewportSelectColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand) RowSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 8 with ViewportSelectColumnGroupCommand

use of org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method shouldSelectAllCellsInGroupsToRightWithShiftInScrolledState.

@Test
public void shouldSelectAllCellsInGroupsToRightWithShiftInScrolledState() {
    assertEquals(0, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
    // scroll down
    this.gridLayer.getBodyLayer().getViewportLayer().moveRowPositionIntoViewport(20);
    assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
    // trigger column group selection
    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));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(3));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(4));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    // no scrolling expected
    assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
    PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(12, selectionAnchor.getRowPosition());
    assertEquals(0, selectionAnchor.getColumnPosition());
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, true, false));
    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(3));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(4));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    // no scrolling expected
    assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
    selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(12, 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 9 with ViewportSelectColumnGroupCommand

use of org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method shouldSelectInScrolledState.

@Test
public void shouldSelectInScrolledState() {
    assertEquals(0, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
    // scroll down
    this.gridLayer.getBodyLayer().getViewportLayer().moveRowPositionIntoViewport(20);
    assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
    // trigger column group selection
    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));
    // no scrolling expected
    assertEquals(12, this.gridLayer.getBodyLayer().getViewportLayer().getRowIndexByPosition(0));
    PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(12, 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)

Aggregations

ViewportSelectColumnGroupCommand (org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand)9 Test (org.junit.Test)9 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)4 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)3 RowSelectionEvent (org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent)3 IRowIdAccessor (org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor)1 NumberValues (org.eclipse.nebula.widgets.nattable.dataset.NumberValues)1