Search in sources :

Example 1 with DefaultBodyLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.

the class FreezeHandlerTest method setUp.

@Before
public void setUp() {
    final DataLayer bodyDataLayer = new DataLayer(new DummyBodyDataProvider(10, 10));
    final DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(bodyDataLayer);
    this.selectionLayer = bodyLayer.getSelectionLayer();
    this.freezeLayer = new FreezeLayer(this.selectionLayer);
    this.compositeFreezeLayer = new CompositeFreezeLayer(this.freezeLayer, bodyLayer.getViewportLayer(), bodyLayer.getSelectionLayer());
    this.viewportLayer = bodyLayer.getViewportLayer();
    this.commandHandler = new FreezeCommandHandler(this.freezeLayer, this.viewportLayer, this.selectionLayer);
    this.compositeFreezeLayer.registerCommandHandler(this.commandHandler);
    this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 600, 400);
        }
    });
    // Shoot this command so that the viewport can be initialized
    this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
}
Also used : DummyBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) CompositeFreezeLayer(org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer) FreezeLayer(org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer) Rectangle(org.eclipse.swt.graphics.Rectangle) CompositeFreezeLayer(org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) Before(org.junit.Before)

Example 2 with DefaultBodyLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.

the class SelectionModelStructuralChangeEventHandlerTest method setup.

@Before
public void setup() {
    this.dataLayer = new DataLayerFixture(10, 10);
    DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(this.dataLayer);
    this.selectionLayer = bodyLayer.getSelectionLayer();
    this.selectionModel = this.selectionLayer.getSelectionModel();
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) Before(org.junit.Before)

Example 3 with DefaultBodyLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.

the class ReorderColumnEventTest method reorderMultipleNotConsecutiveColumnsInHiddenState.

@Test
public void reorderMultipleNotConsecutiveColumnsInHiddenState() {
    DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new DataLayerFixture(10, 10, 100, 20));
    NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer, 1000, 400, true);
    // Add listener
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    natTableFixture.addLayerListener(listenerFixture);
    assertEquals(10, natTableFixture.getColumnCount());
    // hide some columns
    natTableFixture.doCommand(new MultiColumnHideCommand(natTableFixture, new int[] { 2, 5, 8 }));
    assertEquals(7, natTableFixture.getColumnCount());
    List<Integer> columnToMove = Arrays.asList(3, 4, 6, 7);
    int destinationPosition = 0;
    natTableFixture.doCommand(new MultiColumnReorderCommand(underlyingLayer.getColumnReorderLayer(), columnToMove, destinationPosition));
    // verify the event
    ColumnReorderEvent event = (ColumnReorderEvent) listenerFixture.getReceivedEvent(ColumnReorderEvent.class);
    assertNotNull(event);
    assertTrue(StructuralChangeEventHelper.isReorder(event.getColumnDiffs()));
    assertEquals(7, natTableFixture.getColumnCount());
    assertEquals(0, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(3));
    assertEquals(1, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(4));
    assertEquals(2, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(6));
    assertEquals(3, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(7));
    assertEquals(4, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(0));
    assertEquals(5, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(1));
    assertEquals(6, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(2));
    assertEquals(7, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(5));
    assertEquals(8, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(8));
    assertEquals(9, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(9));
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 4 with DefaultBodyLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.

the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsert.

@Test
public void shouldUpdateHiddenOnInsert() {
    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());
}
Also used : 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 5 with DefaultBodyLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack 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)

Aggregations

DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)23 Test (org.junit.Test)10 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)7 ColumnInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent)7 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)6 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)6 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)6 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)5 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)5 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)5 Before (org.junit.Before)5 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)4 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)4 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)4 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)4 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)4 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)4 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)4 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)4 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)4