Search in sources :

Example 11 with MultiColumnHideCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand in project nebula.widgets.nattable by eclipse.

the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsertAndDelete.

@Test
public void shouldUpdateHiddenOnInsertAndDelete() {
    DefaultBodyLayerStack body = this.grid.getBodyLayer();
    ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
    body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(7);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(6);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 12 with MultiColumnHideCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand in project nebula.widgets.nattable by eclipse.

the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsertAndDelete.

@Test
public void shouldUpdateOnInsertAndDelete() {
    DefaultBodyLayerStack body = this.grid.getBodyLayer();
    ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
    ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
    body.doCommand(new ColumnReorderCommand(body, 3, 6));
    body.doCommand(new ColumnReorderCommand(body, 3, 5));
    body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
    assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(7);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(6);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 13 with MultiColumnHideCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand in project nebula.widgets.nattable by eclipse.

the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsert.

@Test
public void shouldUpdateOnInsert() {
    DefaultBodyLayerStack body = this.grid.getBodyLayer();
    ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
    ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
    body.doCommand(new ColumnReorderCommand(body, 3, 6));
    body.doCommand(new ColumnReorderCommand(body, 3, 5));
    body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
    assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
    this.provider.setColumnCount(7);
    this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
    assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
    assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Also used : ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 14 with MultiColumnHideCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand in project nebula.widgets.nattable by eclipse.

the class HideMultipleColumnsIntegrationTest method hideAllColumnsWithColumnGroupsEnabled.

/**
 * Exposing bug: http://nattable.org/jira/browse/NTBL-471
 */
@Test
public void hideAllColumnsWithColumnGroupsEnabled() throws Exception {
    BodyLayerStackFixture<RowDataFixture> bodyLayerStackFixture = new BodyLayerStackFixture<RowDataFixture>(GlazedLists.eventList(RowDataListFixture.getList()), new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()), new ConfigRegistry());
    NatTableFixture natTableFixture = new NatTableFixture(bodyLayerStackFixture);
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    natTableFixture.addLayerListener(listenerFixture);
    Assert.assertEquals(37, bodyLayerStackFixture.getBodyDataProvider().getColumnCount());
    Assert.assertEquals(6, natTableFixture.getColumnCount());
    MultiColumnHideCommand hideAllCommand = new MultiColumnHideCommand(natTableFixture, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 });
    natTableFixture.doCommand(hideAllCommand);
    Assert.assertEquals(1, listenerFixture.getEventsCount());
    ILayerEvent receivedEvent = listenerFixture.getReceivedEvent(HideColumnPositionsEvent.class);
    Assert.assertNotNull(receivedEvent);
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.LayerListenerFixture) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 15 with MultiColumnHideCommand

use of org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand in project nebula.widgets.nattable by eclipse.

the class CompositeFreezeLayerHideShowTest method testFreezeHideShowColumnBothRegionsFreezeAll.

@Test
public void testFreezeHideShowColumnBothRegionsFreezeAll() {
    // 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 MultiColumnHideCommand(this.compositeFreezeLayer, new int[] { 0, 1, 2 }));
    assertEquals(0, 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(0, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    // show again
    this.compositeFreezeLayer.doCommand(new ShowAllColumnsCommand());
    assertEquals(0, this.freezeLayer.getColumnCount());
    assertEquals(0, this.freezeLayer.getRowCount());
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(-1, this.freezeLayer.getBottomRightPosition().rowPosition);
    assertEquals(5, this.viewportLayer.getColumnCount());
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(0, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
    assertEquals(0, this.viewportLayer.getMinimumOrigin().getY());
    reset();
}
Also used : ShowAllColumnsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand) FreezeColumnCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Aggregations

MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)20 Test (org.junit.Test)18 ShowAllColumnsCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand)9 FreezeColumnCommand (org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand)8 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)5 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)4 ColumnInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent)4 ColumnDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent)2 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 SelectColumnCommandHandler (org.eclipse.nebula.widgets.nattable.selection.SelectColumnCommandHandler)2 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)1 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.LayerListenerFixture)1 NatTableFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)1 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)1 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)1