Search in sources :

Example 16 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.

the class RowSizeResetCommandTest method testResetAllRegions.

@Test
public void testResetAllRegions() {
    DummyGridLayerStack dummyGridLayerStack = new DummyGridLayerStack();
    NatTable natTable = new NatTableFixture(dummyGridLayerStack);
    assertEquals(20, dummyGridLayerStack.getColumnHeaderDataLayer().getRowHeightByPosition(0));
    assertEquals(20, dummyGridLayerStack.getBodyDataLayer().getRowHeightByPosition(2));
    ((DataLayer) dummyGridLayerStack.getColumnHeaderDataLayer()).setRowHeightByPosition(0, 50);
    ((DataLayer) dummyGridLayerStack.getBodyDataLayer()).setRowHeightByPosition(2, 50);
    assertEquals(50, dummyGridLayerStack.getColumnHeaderDataLayer().getRowHeightByPosition(0));
    assertEquals(50, dummyGridLayerStack.getBodyDataLayer().getRowHeightByPosition(2));
    natTable.doCommand(new RowHeightResetCommand());
    assertEquals(20, dummyGridLayerStack.getColumnHeaderDataLayer().getRowHeightByPosition(0));
    assertEquals(20, dummyGridLayerStack.getBodyDataLayer().getRowHeightByPosition(2));
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Test(org.junit.Test)

Example 17 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture 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 18 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.

the class ResizeColumnTest method reiszeColumnInATableWithNoRows.

/**
 * Test for bug NTBL-431
 */
@Test
public void reiszeColumnInATableWithNoRows() throws Exception {
    NatTableFixture natTable = new NatTableFixture(new DummyGridLayerStack(5, 0), true);
    assertEquals(100, natTable.getColumnWidthByPosition(2));
    natTable.doCommand(new ColumnResizeCommand(natTable, 2, 150));
    assertEquals(150, natTable.getColumnWidthByPosition(2));
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) Test(org.junit.Test)

Example 19 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.

the class ColumnSizeResetCommandTest method testResetAllRegions.

@Test
public void testResetAllRegions() {
    DummyGridLayerStack dummyGridLayerStack = new DummyGridLayerStack();
    NatTable natTable = new NatTableFixture(dummyGridLayerStack);
    assertEquals(40, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
    assertEquals(100, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
    ((DataLayer) dummyGridLayerStack.getRowHeaderDataLayer()).setColumnWidthByPosition(0, 100);
    ((DataLayer) dummyGridLayerStack.getBodyDataLayer()).setColumnWidthByPosition(2, 50);
    assertEquals(100, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
    assertEquals(50, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
    natTable.doCommand(new ColumnWidthResetCommand());
    assertEquals(40, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
    assertEquals(100, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Test(org.junit.Test)

Example 20 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.

the class SummaryRowIntegrationTest method initLayerStackWithSummaryRow.

@Before
public void initLayerStackWithSummaryRow() {
    this.dataList = RowDataListFixture.getList().subList(0, 4);
    // Rows 0, 1, 2, 3; Summary row would be position 4
    assertEquals(4, this.dataList.size());
    this.dataProvider = new ListDataProvider<RowDataFixture>(this.dataList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
    IConfigRegistry configRegistry = new ConfigRegistry();
    this.dataLayer = new DataLayer(this.dataProvider);
    this.summaryRowLayer = new SummaryRowLayer(this.dataLayer, configRegistry);
    IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(this.summaryRowLayer);
    IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
    IUniqueIndexLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
    this.layerStackWithSummary = new ViewportLayer(selectionLayer);
    // NatTableFixture initializes the client area
    this.natTable = new NatTableFixture(this.layerStackWithSummary, false);
    this.natTable.setConfigRegistry(configRegistry);
    this.natTable.addConfiguration(new TestSummaryRowConfiguration());
    this.natTable.configure();
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer) Before(org.junit.Before)

Aggregations

NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)51 Test (org.junit.Test)29 Before (org.junit.Before)22 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)16 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)13 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)13 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)11 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)8 Properties (java.util.Properties)7 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)7 GridLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture)6 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)5 SpanningDataLayer (org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer)5 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)5 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)5 IRowIdAccessor (org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor)4 DefaultEditBindings (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings)4 DefaultEditConfiguration (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration)4 IUniqueIndexLayer (org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)4 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)4