Search in sources :

Example 26 with NatTableFixture

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

the class CellLabelMouseEventMatcherTest method setUpCustomCellLabel.

@Before
public void setUpCustomCellLabel() {
    DummyGridLayerStack gridLayerStack = new DummyGridLayerStack(5, 5);
    this.natTableFixture = new NatTableFixture(gridLayerStack);
    // Register custom label
    DataLayer bodyDataLayer = (DataLayer) gridLayerStack.getBodyDataLayer();
    this.natTableFixture.registerLabelOnColumn(bodyDataLayer, 0, TEST_LABEL);
}
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) Before(org.junit.Before)

Example 27 with NatTableFixture

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

the class ColumnStructuralChangeEventIntegrationTest method setup.

@Before
public void setup() {
    this.natTableFixture = new NatTableFixture(this.grid);
    this.listener = new LayerListenerFixture();
    this.natTableFixture.addLayerListener(this.listener);
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Before(org.junit.Before)

Example 28 with NatTableFixture

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

the class EventConflaterChainTest method setup.

@Before
public void setup() {
    this.conflaterChain = new EventConflaterChain(10, 10);
    this.natTableFixture = new NatTableFixture();
    this.conflater1 = new VisualChangeEventConflater(this.natTableFixture);
    this.conflater2 = new VisualChangeEventConflater(this.natTableFixture);
    this.conflaterChain.add(this.conflater1);
    this.conflaterChain.add(this.conflater2);
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) EventConflaterChain(org.eclipse.nebula.widgets.nattable.conflation.EventConflaterChain) VisualChangeEventConflater(org.eclipse.nebula.widgets.nattable.conflation.VisualChangeEventConflater) Before(org.junit.Before)

Example 29 with NatTableFixture

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

the class RowSizeResetCommandTest method testResetOnlyBody.

@Test
public void testResetOnlyBody() {
    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(GridRegion.BODY));
    assertEquals(50, 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 30 with NatTableFixture

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

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