Search in sources :

Example 21 with LayerListenerFixture

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

the class SummaryRowIntegrationTest method shouldFireCellVisualChangeEventOnceSummaryIsCalculated.

@Test
public void shouldFireCellVisualChangeEventOnceSummaryIsCalculated() throws Exception {
    // need to resize because otherwise the ViewportLayer would not process
    // the CellVisualChangeEvent any further
    this.natTable.setSize(800, 400);
    LayerListenerFixture listener = new LayerListenerFixture();
    this.natTable.addLayerListener(listener);
    // Trigger summary calculation
    this.natTable.getDataValueByPosition(this.askPriceColumnIndex, 4);
    Thread.sleep(500);
    assertTrue(listener.containsInstanceOf(CellVisualChangeEvent.class));
    CellVisualChangeEvent event = (CellVisualChangeEvent) listener.getReceivedEvents().get(0);
    assertEquals(this.askPriceColumnIndex, event.getColumnPosition());
    assertEquals(4, event.getRowPosition());
    Collection<Rectangle> changedPositionRectangles = event.getChangedPositionRectangles();
    assertEquals(1, changedPositionRectangles.size());
    // only the cell gets updated
    Rectangle rectangle = changedPositionRectangles.iterator().next();
    assertEquals(6, rectangle.x);
    assertEquals(4, rectangle.y);
    assertEquals(1, rectangle.width);
    assertEquals(1, rectangle.height);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) CellVisualChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent) Test(org.junit.Test)

Example 22 with LayerListenerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture 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 23 with LayerListenerFixture

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

the class DataChangeLayerTempStorageTest method setup.

@Before
public void setup() {
    this.dataModel = PersonService.getFixedPersons();
    this.dataLayer = new DataLayer(new ListDataProvider<>(this.dataModel, new ReflectiveColumnPropertyAccessor<>(new String[] { "firstName", "lastName", "gender", "married", "birthday" })));
    this.dataChangeLayer = new DataChangeLayer(this.dataLayer, new PointKeyHandler(), true);
    this.listener = new LayerListenerFixture();
    this.dataLayer.addLayerListener(this.listener);
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Before(org.junit.Before)

Example 24 with LayerListenerFixture

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

the class NatTableTest method shouldPassOnLayerEventsToListeners.

@Test
public void shouldPassOnLayerEventsToListeners() throws Exception {
    LayerListenerFixture listener = new LayerListenerFixture();
    this.natTable.addLayerListener(listener);
    this.natTable.handleLayerEvent(new LayerEventFixture());
    assertTrue(listener.containsInstanceOf(LayerEventFixture.class));
}
Also used : LayerEventFixture(org.eclipse.nebula.widgets.nattable.test.fixture.LayerEventFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Test(org.junit.Test)

Example 25 with LayerListenerFixture

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

the class ResizeEventPropagationTest method shouldFireResizeEventAfterRowResizeCommand.

@Test
public void shouldFireResizeEventAfterRowResizeCommand() {
    this.dataLayer.addLayerListener(new LayerListenerFixture());
    this.dataLayer.setRowHeightByPosition(2, 100);
}
Also used : LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Test(org.junit.Test)

Aggregations

LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)37 Test (org.junit.Test)21 Before (org.junit.Before)16 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)11 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)7 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 Shell (org.eclipse.swt.widgets.Shell)4 Properties (java.util.Properties)3 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)3 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)3 CellVisualChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent)3 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)3 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)3 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)2 DummyBodyDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider)2 ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)2 RowHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand)2 HideColumnPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent)2 HideRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent)2