use of org.eclipse.nebula.widgets.nattable.coordinate.Range 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));
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range 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));
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class RowReorderLayerStructuralChangeEventTest method testHandleMultipleRowDeleteEvent.
@Test
public void testHandleMultipleRowDeleteEvent() {
// test start order: 0 1 2 3
assertEquals(0, this.rowReorderLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowReorderLayer.getRowIndexByPosition(1));
assertEquals(2, this.rowReorderLayer.getRowIndexByPosition(2));
assertEquals(3, this.rowReorderLayer.getRowIndexByPosition(3));
assertEquals("one", this.rowReorderLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowReorderLayer.getDataValueByPosition(0, 1));
assertEquals("three", this.rowReorderLayer.getDataValueByPosition(0, 2));
assertEquals("four", this.rowReorderLayer.getDataValueByPosition(0, 3));
// reorder to inverse order: 3 2 1 0
this.rowReorderLayer.reorderRowPosition(3, 0);
this.rowReorderLayer.reorderRowPosition(3, 1);
this.rowReorderLayer.reorderRowPosition(3, 2);
assertEquals(3, this.rowReorderLayer.getRowIndexByPosition(0));
assertEquals(2, this.rowReorderLayer.getRowIndexByPosition(1));
assertEquals(1, this.rowReorderLayer.getRowIndexByPosition(2));
assertEquals(0, this.rowReorderLayer.getRowIndexByPosition(3));
assertEquals("four", this.rowReorderLayer.getDataValueByPosition(0, 0));
assertEquals("three", this.rowReorderLayer.getDataValueByPosition(0, 1));
assertEquals("two", this.rowReorderLayer.getDataValueByPosition(0, 2));
assertEquals("one", this.rowReorderLayer.getDataValueByPosition(0, 3));
// delete rows in the middle
this.contents.remove(1);
this.contents.remove(1);
this.underlyingLayer.fireLayerEvent(new RowDeleteEvent(this.underlyingLayer, new Range(1, 3)));
assertEquals(2, this.rowReorderLayer.getRowCount());
assertEquals(1, this.rowReorderLayer.getRowIndexByPosition(0));
assertEquals(0, this.rowReorderLayer.getRowIndexByPosition(1));
assertEquals(-1, this.rowReorderLayer.getRowIndexByPosition(2));
assertEquals("four", this.rowReorderLayer.getDataValueByPosition(0, 0));
assertEquals("one", this.rowReorderLayer.getDataValueByPosition(0, 1));
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class MultiColumnReorderEventDiffTest method testReorderLeftConvertToLocal.
/**
* + - - - before: 0 1 2 3 4 5 6 7 8 9 10 after: 0 1 7 8 9 2 3 4 5 6 10 + +
* + -
*/
@Test
public void testReorderLeftConvertToLocal() {
this.event = new ColumnReorderEvent(this.dataLayer, Arrays.asList(new Integer[] { 7, 8, 9 }), 2, true);
this.event.convertToLocal(this.viewportLayer);
Collection<StructuralDiff> columnDiffs = this.event.getColumnDiffs();
Assert.assertNotNull(columnDiffs);
Assert.assertEquals(2, columnDiffs.size());
Iterator<StructuralDiff> iterator = columnDiffs.iterator();
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.DELETE, new Range(5, 8), new Range(8, 8)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(0, 0), new Range(0, 3)), iterator.next());
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class MultiColumnReorderEventDiffTest method testReorderRightConvertToLocal.
/**
* - - - + before: 0 1 2 3 4 5 6 7 8 after: 0 1 5 6 2 3 4 7 8 - + + +
*/
@Test
public void testReorderRightConvertToLocal() {
this.event = new ColumnReorderEvent(this.dataLayer, Arrays.asList(new Integer[] { 2, 3, 4 }), 7, true);
this.event.convertToLocal(this.viewportLayer);
Collection<StructuralDiff> columnDiffs = this.event.getColumnDiffs();
Assert.assertNotNull(columnDiffs);
Assert.assertEquals(2, columnDiffs.size());
Iterator<StructuralDiff> iterator = columnDiffs.iterator();
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.DELETE, new Range(0, 3), new Range(0, 0)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(5, 5), new Range(2, 5)), iterator.next());
}
Aggregations