use of org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff in project nebula.widgets.nattable by eclipse.
the class ShowColumnPositionsEventDiffTest method testColumnDiffs.
/**
* + + + before: 0 1 3 5 6 8 9 10 11 12 after: 0 1 2 3 4 5 6 7 8 9 + + + + +
*/
@Test
public void testColumnDiffs() {
Collection<StructuralDiff> columnDiffs = this.event.getColumnDiffs();
Assert.assertNotNull(columnDiffs);
Assert.assertEquals(3, columnDiffs.size());
Iterator<StructuralDiff> iterator = columnDiffs.iterator();
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(2, 2), new Range(2, 3)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(3, 3), new Range(4, 5)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(5, 5), new Range(7, 10)), iterator.next());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff in project nebula.widgets.nattable by eclipse.
the class ShowRowPositionsEventDiffTest method testConvertToLocal.
/**
* + + + before: 0 1 3 5 6 8 9 10 11 12 after: 0 1 2 3 4 5 6 7 8 9 + + + + +
*/
@Test
public void testConvertToLocal() {
this.event.convertToLocal(this.hideShowLayer);
Collection<StructuralDiff> rowDiffs = this.event.getRowDiffs();
Assert.assertNotNull(rowDiffs);
Assert.assertEquals(3, rowDiffs.size());
Iterator<StructuralDiff> iterator = rowDiffs.iterator();
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(2, 2), new Range(2, 3)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(3, 3), new Range(4, 5)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(5, 5), new Range(7, 10)), iterator.next());
this.event.convertToLocal(this.viewportLayer);
rowDiffs = this.event.getRowDiffs();
Assert.assertNotNull(rowDiffs);
Assert.assertEquals(3, rowDiffs.size());
iterator = rowDiffs.iterator();
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(0, 0), new Range(0, 1)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(1, 1), new Range(2, 3)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(3, 3), new Range(5, 8)), iterator.next());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff in project nebula.widgets.nattable by eclipse.
the class ShowRowPositionsEventDiffTest method testColumnDiffs.
/**
* + + + before: 0 1 3 5 6 8 9 10 11 12 after: 0 1 2 3 4 5 6 7 8 9 + + + + +
*/
@Test
public void testColumnDiffs() {
Collection<StructuralDiff> rowDiffs = this.event.getRowDiffs();
Assert.assertNotNull(rowDiffs);
Assert.assertEquals(3, rowDiffs.size());
Iterator<StructuralDiff> iterator = rowDiffs.iterator();
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(2, 2), new Range(2, 3)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(3, 3), new Range(4, 5)), iterator.next());
Assert.assertEquals(new StructuralDiff(DiffTypeEnum.ADD, new Range(5, 5), new Range(7, 10)), iterator.next());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerTest2 method shouldFireTheCorrectEventOnColumnHide.
@Test
public void shouldFireTheCorrectEventOnColumnHide() throws Exception {
NatTable natTable = new NatTableFixture();
LayerListenerFixture listener = new LayerListenerFixture();
natTable.addLayerListener(listener);
// Grid coordinates
natTable.doCommand(new ColumnHideCommand(natTable, 5));
assertEquals(1, listener.getReceivedEvents().size());
HideColumnPositionsEvent hideEvent = (HideColumnPositionsEvent) listener.getReceivedEvents().get(0);
Range range = hideEvent.getColumnPositionRanges().iterator().next();
assertEquals(5, range.start);
assertEquals(6, range.end);
// The range Before hide: 5 -> 6
// The range After hide: 5 -> 5 (column is not there anymore)
StructuralDiff columnDiff = hideEvent.getColumnDiffs().iterator().next();
assertEquals(5, columnDiff.getBeforePositionRange().start);
assertEquals(6, columnDiff.getBeforePositionRange().end);
assertEquals(5, columnDiff.getAfterPositionRange().start);
assertEquals(5, columnDiff.getAfterPositionRange().end);
}
use of org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayerTest2 method shouldFireTheCorrectEventOnRowHide.
@Test
public void shouldFireTheCorrectEventOnRowHide() throws Exception {
NatTable natTable = new NatTableFixture(new Shell(), new DummyGridLayerStack() {
@Override
protected void init(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer) {
RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(bodyDataLayer);
super.init(rowHideShowLayer, columnHeaderDataLayer, rowHeaderDataLayer, cornerDataLayer);
}
});
LayerListenerFixture listener = new LayerListenerFixture();
natTable.addLayerListener(listener);
// Grid coordinates
natTable.doCommand(new RowHideCommand(natTable, 5));
assertEquals(1, listener.getReceivedEvents().size());
HideRowPositionsEvent hideEvent = (HideRowPositionsEvent) listener.getReceivedEvents().get(0);
Range range = hideEvent.getRowPositionRanges().iterator().next();
assertEquals(5, range.start);
assertEquals(6, range.end);
// The range Before hide: 5 -> 6
// The range After hide: 5 -> 5 (row is not there anymore)
StructuralDiff rowDiff = hideEvent.getRowDiffs().iterator().next();
assertEquals(5, rowDiff.getBeforePositionRange().start);
assertEquals(6, rowDiff.getBeforePositionRange().end);
assertEquals(5, rowDiff.getAfterPositionRange().start);
assertEquals(5, rowDiff.getAfterPositionRange().end);
}
Aggregations