Search in sources :

Example 1 with NatTableFixture

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

the class VisualChangeEventConflaterTest method shouldAccumulateEvents.

@Test
public void shouldAccumulateEvents() throws Exception {
    NatTableFixture natTable = new NatTableFixture();
    VisualChangeEventConflater conflater = new VisualChangeEventConflater(natTable);
    EventConflaterChain chain = new EventConflaterChain();
    chain.add(conflater);
    conflater.addEvent(new LayerEventFixture());
    conflater.addEvent(new LayerEventFixture());
    assertEquals(2, conflater.getCount());
    chain.start();
    Thread.sleep(EventConflaterChain.DEFAULT_INITIAL_DELAY + 100);
    assertEquals(0, conflater.getCount());
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) LayerEventFixture(org.eclipse.nebula.widgets.nattable.test.fixture.LayerEventFixture) EventConflaterChain(org.eclipse.nebula.widgets.nattable.conflation.EventConflaterChain) VisualChangeEventConflater(org.eclipse.nebula.widgets.nattable.conflation.VisualChangeEventConflater) Test(org.junit.Test)

Example 2 with NatTableFixture

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

the class EditUtilsTest method setup.

@Before
public void setup() {
    this.gridLayerStack = new DummyGridLayerStack(5, 5);
    this.selectionLayer = this.gridLayerStack.getBodyLayer().getSelectionLayer();
    this.natTable = new NatTableFixture(this.gridLayerStack);
    // Ensure no active editor (static) is present
    // Although deprecated this needs to still work for backwards
    // compatibility
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) Before(org.junit.Before)

Example 3 with NatTableFixture

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

the class RowSelectionEditUtilsTest method setup.

@Before
public void setup() {
    List<RowDataFixture> listFixture = RowDataListFixture.getList(10);
    IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
    this.gridLayerStack = new GridLayerFixture(bodyDataProvider);
    this.selectionLayer = this.gridLayerStack.getBodyLayer().getSelectionLayer();
    this.selectionLayer.setSelectionModel(new RowSelectionModel<RowDataFixture>(this.selectionLayer, bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {

        @Override
        public Serializable getRowId(RowDataFixture rowObject) {
            return rowObject.getSecurity_id();
        }
    }));
    this.natTable = new NatTableFixture(this.gridLayerStack);
    // Ensure no active editor (static) is present
    // Although deprecated this needs to still work for backwards
    // compatibility
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) Before(org.junit.Before)

Example 4 with NatTableFixture

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

the class ColumnHideShowLayerTest2 method shouldFireTheCorrectEventOnColumnHide.

@Test
public void shouldFireTheCorrectEventOnColumnHide() throws Exception {
    NatTable natTable = new NatTableFixture();
    LayerListenerFixture listener = new LayerListenerFixture();
    natTable.addLayerListener(listener);
    // Grid coordinates
    natTable.doCommand(new ColumnHideCommand(natTable, 5));
    assertEquals(1, listener.getReceivedEvents().size());
    HideColumnPositionsEvent hideEvent = (HideColumnPositionsEvent) listener.getReceivedEvents().get(0);
    Range range = hideEvent.getColumnPositionRanges().iterator().next();
    assertEquals(5, range.start);
    assertEquals(6, range.end);
    // The range Before hide: 5 -> 6
    // The range After hide: 5 -> 5 (column is not there anymore)
    StructuralDiff columnDiff = hideEvent.getColumnDiffs().iterator().next();
    assertEquals(5, columnDiff.getBeforePositionRange().start);
    assertEquals(6, columnDiff.getBeforePositionRange().end);
    assertEquals(5, columnDiff.getAfterPositionRange().start);
    assertEquals(5, columnDiff.getAfterPositionRange().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) StructuralDiff(org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 5 with NatTableFixture

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

the class BoxingStyleTest method setUp.

@Before
public void setUp() throws Exception {
    this.natTable = new NatTableFixture();
    this.configRegistry = (ConfigRegistry) this.natTable.getConfigRegistry();
    this.cellStyle = new Style();
    this.cellPainter = new TextPainter();
    this.gc = new GC(Display.getDefault());
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) Style(org.eclipse.nebula.widgets.nattable.style.Style) GC(org.eclipse.swt.graphics.GC) 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