Search in sources :

Example 6 with ColumnHideCommand

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();
}
Also used : MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) FreezeColumnCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand) Test(org.junit.Test)

Example 7 with ColumnHideCommand

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();
}
Also used : MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) FreezeColumnCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand) Test(org.junit.Test)

Example 8 with ColumnHideCommand

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));
}
Also used : ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) Test(org.junit.Test)

Example 9 with ColumnHideCommand

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);
}
Also used : ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) HideColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 10 with ColumnHideCommand

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));
}
Also used : ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) Test(org.junit.Test)

Aggregations

ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)16 Test (org.junit.Test)13 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)7 ShowAllColumnsCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand)6 FreezeColumnCommand (org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand)4 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)3 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)2 HideColumnPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent)2 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)2 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)2 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)2 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1