use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerHideShowTest method testFreezeHideShowColumnViewportRegion.
@Test
public void testFreezeHideShowColumnViewportRegion() {
// freeze
this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 1));
assertEquals(2, this.freezeLayer.getColumnCount());
assertEquals(0, this.freezeLayer.getRowCount());
assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(3, this.viewportLayer.getColumnCount());
assertEquals(5, this.viewportLayer.getRowCount());
assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
// hide
this.compositeFreezeLayer.doCommand(new ColumnHideCommand(this.compositeFreezeLayer, 3));
assertEquals(2, this.freezeLayer.getColumnCount());
assertEquals(0, this.freezeLayer.getRowCount());
assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(2, this.viewportLayer.getColumnCount());
assertEquals(5, this.viewportLayer.getRowCount());
assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
// show again
this.compositeFreezeLayer.doCommand(new ShowAllColumnsCommand());
assertEquals(2, this.freezeLayer.getColumnCount());
assertEquals(0, this.freezeLayer.getRowCount());
assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(3, this.viewportLayer.getColumnCount());
assertEquals(5, this.viewportLayer.getRowCount());
assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
reset();
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerHideShowTest method testFreezeHideShowColumnFrozenRegion.
// Column hide/show
@Test
public void testFreezeHideShowColumnFrozenRegion() {
// freeze
this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 1));
assertEquals(2, this.freezeLayer.getColumnCount());
assertEquals(0, this.freezeLayer.getRowCount());
assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(3, this.viewportLayer.getColumnCount());
assertEquals(5, this.viewportLayer.getRowCount());
assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
// hide
this.compositeFreezeLayer.doCommand(new ColumnHideCommand(this.compositeFreezeLayer, 0));
assertEquals(1, this.freezeLayer.getColumnCount());
assertEquals(0, this.freezeLayer.getRowCount());
assertEquals(0, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(3, this.viewportLayer.getColumnCount());
assertEquals(5, this.viewportLayer.getRowCount());
assertEquals(1, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(100, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
// show again
this.compositeFreezeLayer.doCommand(new ShowAllColumnsCommand());
assertEquals(2, this.freezeLayer.getColumnCount());
assertEquals(0, this.freezeLayer.getRowCount());
assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(3, this.viewportLayer.getColumnCount());
assertEquals(5, this.viewportLayer.getRowCount());
assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(200, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
reset();
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class FreezeLayerTest method testHideShowInteriorColumn.
@Test
public void testHideShowInteriorColumn() {
this.hideShowLayer.doCommand(new ColumnHideCommand(this.hideShowLayer, 2));
Assert.assertEquals(2, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(3, this.freezeLayer.getColumnIndexByPosition(1));
this.hideShowLayer.doCommand(new ShowAllColumnsCommand());
Assert.assertEquals(3, this.freezeLayer.getColumnCount());
Assert.assertEquals(1, this.freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(2, this.freezeLayer.getColumnIndexByPosition(1));
Assert.assertEquals(3, this.freezeLayer.getColumnIndexByPosition(2));
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerTest2 method scrollAndHideTheLastColumn.
/**
* Integration test
*/
@Test
public void scrollAndHideTheLastColumn() throws Exception {
// Total columns in fixture - 20 (index 0 - 19)
NatTableFixture natTable = new NatTableFixture();
LayerListenerFixture natTableListener = new LayerListenerFixture();
natTable.addLayerListener(natTableListener);
// Scroll to position 14 in grid/14 in body
natTable.scrollToColumn(14);
assertEquals(14, natTable.getColumnIndexByPosition(1));
// Hide last column - position 6/index 19
assertEquals(19, natTable.getColumnIndexByPosition(6));
natTable.doCommand(new ColumnHideCommand(natTable, 6));
// Assert event received
assertNotNull(natTableListener.getReceivedEvent(HideColumnPositionsEvent.class));
HideColumnPositionsEvent hideEvent = (HideColumnPositionsEvent) natTableListener.getReceivedEvent(HideColumnPositionsEvent.class);
// When last column is hidden it is not carrying the following info
assertEquals(1, hideEvent.getColumnPositionRanges().size());
// View port adjusted origin to move an extra column in
Range hiddenRange = hideEvent.getColumnPositionRanges().iterator().next();
assertEquals(7, hiddenRange.start);
assertEquals(8, hiddenRange.end);
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerTest method getCellSpanWhenColumnsInGroupAreHidden.
@Test
public void getCellSpanWhenColumnsInGroupAreHidden() {
// Index in group: 5, 6, 7
this.model.addColumnsIndexesToGroup(TEST_GROUP_NAME_2, 7);
assertEquals(3, this.columnGroupLayer.getColumnSpan(5));
// Hide position 6
ColumnHideCommand hideColumnCommand = new ColumnHideCommand(this.gridLayer.getBodyLayer(), 6);
this.gridLayer.getBodyLayer().getColumnHideShowLayer().doCommand(hideColumnCommand);
assertEquals(2, this.columnGroupLayer.getColumnSpan(5));
// Hide position 5
hideColumnCommand = new ColumnHideCommand(this.gridLayer.getBodyLayer(), 6);
this.gridLayer.getBodyLayer().getColumnHideShowLayer().doCommand(hideColumnCommand);
assertEquals(1, this.columnGroupLayer.getColumnSpan(5));
}
Aggregations