use of org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent in project nebula.widgets.nattable by eclipse.
the class DataLayerCommandHandlingTest method handleSameUpdateDataCommandRaisesNoEvents.
@Test
public void handleSameUpdateDataCommandRaisesNoEvents() throws Exception {
LayerListenerFixture listener = new LayerListenerFixture();
this.dataLayer.addLayerListener(listener);
this.dataLayer.doCommand(this.command);
Assert.assertTrue(listener.getReceivedEvents().size() == 1);
Assert.assertTrue(listener.getReceivedEvents().get(0) instanceof CellVisualChangeEvent);
// as calling the UpdateCommand with the same value should not trigger
// any event
// the size of the received events will stay 1 (the one event from
// before which is cached)
this.dataLayer.doCommand(this.command);
Assert.assertTrue(listener.getReceivedEvents().size() == 1);
}
use of org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent 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);
}
use of org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent in project nebula.widgets.nattable by eclipse.
the class TickUpdateCommandHandlerTest method shouldNotThrowExceptionOnNoSelection.
@Test
public void shouldNotThrowExceptionOnNoSelection() {
// if no exception occurs this test succeeds
// we also check that no update has been triggered
this.selectionLayer.clear();
this.selectionLayer.addLayerListener(new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof CellVisualChangeEvent) {
fail("update triggered");
}
}
});
this.commandHandler.doCommand(new TickUpdateCommand(this.testConfigRegistry, true));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent in project nebula.widgets.nattable by eclipse.
the class GroupByDataLayerSummaryRowConcurrencyTest method shouldCorrectlyCalculateSummaryValues.
// summary value == 55
@Test
public void shouldCorrectlyCalculateSummaryValues() {
this.summaryRowLayer.addLayerListener(new ILayerListener() {
@Override
public synchronized void handleLayerEvent(ILayerEvent event) {
if (event instanceof CellVisualChangeEvent) {
GroupByDataLayerSummaryRowConcurrencyTest.this.calcCount++;
}
}
});
assertNull(this.summaryRowLayer.getDataValueByPosition(0, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(1, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(2, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(3, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(4, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(5, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(6, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(7, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(8, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(9, 0));
assertNull(this.summaryRowLayer.getDataValueByPosition(10, 0));
while (this.calcCount < 11) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(0, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(1, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(2, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(3, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(4, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(5, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(6, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(7, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(8, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(9, 0));
assertEquals(55.0, this.summaryRowLayer.getDataValueByPosition(10, 0));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent in project nebula.widgets.nattable by eclipse.
the class DataLayerCommandHandlingTest method handleUpdateDataCommandRaisesEvents.
@Test
public void handleUpdateDataCommandRaisesEvents() throws Exception {
LayerListenerFixture listener = new LayerListenerFixture();
this.dataLayer.addLayerListener(listener);
this.dataLayer.doCommand(this.command);
Assert.assertTrue(listener.getReceivedEvents().get(0) instanceof CellVisualChangeEvent);
}
Aggregations