use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testUnderlyingToLocalColumnPositions.
@Test
public void testUnderlyingToLocalColumnPositions() {
ArrayList<Range> positionRanges = new ArrayList<>();
positionRanges.add(new Range(0, 2));
positionRanges.add(new Range(2, 4));
positionRanges.add(new Range(4, 6));
Collection<Range> underlying = this.treeLayer.underlyingToLocalColumnPositions(this.selectionLayer, positionRanges);
ArrayList<Range> list = new ArrayList<>(underlying);
assertEquals(new Range(1, 3), list.get(0));
assertEquals(new Range(4, 6), list.get(1));
assertEquals(new Range(7, 9), list.get(2));
this.treeLayer.setShowTreeLevelHeader(false);
underlying = this.treeLayer.underlyingToLocalColumnPositions(this.selectionLayer, positionRanges);
list = new ArrayList<>(underlying);
assertEquals(new Range(0, 2), list.get(0));
assertEquals(new Range(2, 4), list.get(1));
assertEquals(new Range(4, 6), list.get(2));
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerHideShowTest method testFreezeDeleteRows.
@Test
public void testFreezeDeleteRows() {
this.compositeFreezeLayer.doCommand(new FreezeRowCommand(this.compositeFreezeLayer, 3));
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(4, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(1, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(4, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(80, this.viewportLayer.getMinimumOrigin().getY());
// fake a multi row delete with no details on which rows are deleted
// technically the same as collapsing or filtering a GlazedLists
this.rowCount = 2;
this.dataLayer.fireLayerEvent(new RowDeleteEvent(this.dataLayer, new ArrayList<Range>()));
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(2, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(0, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(-1, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(40, this.viewportLayer.getMinimumOrigin().getY());
// since the RowHideShowLayer is involved in the current composition
// the number of rows is cached and we need to update this before reset
this.rowCount = 5;
this.dataLayer.fireLayerEvent(new RowInsertEvent(this.dataLayer, new Range(0, 2)));
reset();
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range 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.coordinate.Range 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.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayerTest method testHideShowDefaultSizedColumns.
// test hide with default only set columns
@Test
public void testHideShowDefaultSizedColumns() {
assertEquals(500, this.hideShowLayer.getWidth());
assertTrue(this.bodyDataLayer.isColumnPositionResizable(1));
assertTrue(this.bodyDataLayer.isColumnPositionResizable(4));
this.hideShowLayer.hideColumnPositions(1, 4);
assertEquals(2, this.listener.getReceivedEvents().size());
assertEquals(new Range(1, 2), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(0)).getColumnDiffs().iterator().next().getAfterPositionRange());
assertEquals(new Range(4, 5), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(1)).getColumnDiffs().iterator().next().getAfterPositionRange());
assertEquals(300, this.hideShowLayer.getWidth());
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(4));
assertEquals(2, this.hideShowLayer.getHiddenColumnIndexes().size());
assertTrue("1 is not contained in hidden column indexes", this.hideShowLayer.getHiddenColumnIndexes().contains(Integer.valueOf(1)));
assertTrue("4 is not contained in hidden column indexes", this.hideShowLayer.getHiddenColumnIndexes().contains(Integer.valueOf(4)));
assertFalse(this.bodyDataLayer.isColumnPositionResizable(1));
assertFalse(this.bodyDataLayer.isColumnPositionResizable(4));
this.hideShowLayer.showAllColumns();
assertEquals(4, this.listener.getReceivedEvents().size());
assertEquals(new Range(1, 2), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(2)).getColumnDiffs().iterator().next().getAfterPositionRange());
assertEquals(new Range(4, 5), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(3)).getColumnDiffs().iterator().next().getAfterPositionRange());
assertEquals(500, this.hideShowLayer.getWidth());
assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(1));
assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(4));
assertTrue("hidden column indexes are not empty", this.hideShowLayer.getHiddenColumnIndexes().isEmpty());
assertTrue(this.bodyDataLayer.isColumnPositionResizable(1));
assertTrue(this.bodyDataLayer.isColumnPositionResizable(4));
}
Aggregations