Search in sources :

Example 1 with ILayerEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.

the class AbstractLayerTest method testFireOriginalEventIfOnlyOneListener.

@Test
public void testFireOriginalEventIfOnlyOneListener() {
    ILayerEvent event = new ColumnResizeEvent(this.dataLayer, 2);
    this.dataLayer.fireLayerEvent(event);
    List<ILayerEvent> receivedEvents = this.firstListener.getReceivedEvents();
    assertNotNull(receivedEvents);
    assertEquals(1, receivedEvents.size());
    assertSame(event, receivedEvents.get(0));
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) Test(org.junit.Test)

Example 2 with ILayerEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.

the class AbstractLayerTest method testFireClonedEventIfMultipleListeners.

@Test
public void testFireClonedEventIfMultipleListeners() {
    LayerListenerFixture secondListener = new LayerListenerFixture();
    this.dataLayer.addLayerListener(secondListener);
    ILayerEvent event = new ColumnResizeEvent(this.dataLayer, 2);
    this.dataLayer.fireLayerEvent(event);
    List<ILayerEvent> receivedEvents = this.firstListener.getReceivedEvents();
    assertNotNull(receivedEvents);
    assertEquals(1, receivedEvents.size());
    assertNotSame(event, receivedEvents.get(0));
    receivedEvents = secondListener.getReceivedEvents();
    assertNotNull(receivedEvents);
    assertEquals(1, receivedEvents.size());
    assertSame(event, receivedEvents.get(0));
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Test(org.junit.Test)

Example 3 with ILayerEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.

the class FormulaIntegrationTest method testCacheUpdate.

@Test
public void testCacheUpdate() throws InterruptedException {
    assertNull(this.natTable.getDataValueByPosition(3, 5));
    // wait until calculation is processed
    Thread.sleep(50);
    assertEquals(new BigDecimal("16"), this.natTable.getDataValueByPosition(3, 5));
    ILayerEvent receivedEvent = this.listenerFixture.getReceivedEvent(CellVisualChangeEvent.class);
    assertNotNull(receivedEvent);
    // update a value in the first sum
    ((DataLayer) this.gridLayerStack.getBodyDataLayer()).setDataValue(0, 2, 20);
    // right after the update we still get the old value from the cache
    assertEquals(new BigDecimal("16"), this.natTable.getDataValueByPosition(3, 5));
    // wait until calculation is processed
    Thread.sleep(50);
    assertEquals(new BigDecimal("31"), this.natTable.getDataValueByPosition(3, 5));
    assertEquals(2, this.listenerFixture.getEventsCount());
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 4 with ILayerEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.

the class FormulaIntegrationTest method testResultCachingDisabled.

@Test
public void testResultCachingDisabled() throws InterruptedException {
    this.natTable.doCommand(new DisableFormulaCachingCommand());
    assertNotNull(this.natTable.getDataValueByPosition(3, 1));
    assertEquals(new BigDecimal("15"), this.natTable.getDataValueByPosition(3, 1));
    ILayerEvent receivedEvent = this.listenerFixture.getReceivedEvent(CellVisualChangeEvent.class);
    assertNull(receivedEvent);
    this.natTable.doCommand(new EnableFormulaCachingCommand());
    assertNull(this.natTable.getDataValueByPosition(3, 1));
    // wait until calculation is processed
    Thread.sleep(50);
    assertEquals(new BigDecimal("15"), this.natTable.getDataValueByPosition(3, 1));
    receivedEvent = this.listenerFixture.getReceivedEvent(CellVisualChangeEvent.class);
    assertNotNull(receivedEvent);
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) EnableFormulaCachingCommand(org.eclipse.nebula.widgets.nattable.formula.command.EnableFormulaCachingCommand) DisableFormulaCachingCommand(org.eclipse.nebula.widgets.nattable.formula.command.DisableFormulaCachingCommand) BigDecimal(java.math.BigDecimal) CellVisualChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent) Test(org.junit.Test)

Example 5 with ILayerEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.

the class FormulaIntegrationTest method testResultCaching.

@Test
public void testResultCaching() throws InterruptedException {
    assertNull(this.natTable.getDataValueByPosition(3, 1));
    // wait until calculation is processed
    Thread.sleep(50);
    assertEquals(new BigDecimal("15"), this.natTable.getDataValueByPosition(3, 1));
    ILayerEvent receivedEvent = this.listenerFixture.getReceivedEvent(CellVisualChangeEvent.class);
    assertNotNull(receivedEvent);
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)28 Test (org.junit.Test)17 ILayerListener (org.eclipse.nebula.widgets.nattable.layer.ILayerListener)14 HashSet (java.util.HashSet)4 IVisualChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.IVisualChangeEvent)4 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)4 CellSelectionEvent (org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent)4 BaseDataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 BigDecimal (java.math.BigDecimal)3 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)3 CellVisualChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent)3 ColumnReorderEvent (org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent)3 RowSelectionEvent (org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)2 ColumnResizeEvent (org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent)2