use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method setup.
@Before
public void setup() {
// de-normalize the object graph without parent structure objects
this.data = HierarchicalHelper.deNormalize(CarService.getInput(), false, CarService.PROPERTY_NAMES_COMPACT);
HierarchicalReflectiveColumnPropertyAccessor columnPropertyAccessor = new HierarchicalReflectiveColumnPropertyAccessor(CarService.PROPERTY_NAMES_COMPACT);
this.bodyDataProvider = new ListDataProvider<>(this.data, columnPropertyAccessor);
HierarchicalSpanningDataProvider spanningDataProvider = new HierarchicalSpanningDataProvider(this.bodyDataProvider, CarService.PROPERTY_NAMES_COMPACT);
this.bodyDataLayer = new SpanningDataLayer(spanningDataProvider);
// simply apply labels for every column by index
this.bodyDataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
this.columnReorderLayer = new ColumnReorderLayer(this.bodyDataLayer);
this.selectionLayer = new SelectionLayer(this.columnReorderLayer);
this.treeLayer = new HierarchicalTreeLayer(this.selectionLayer, this.data, CarService.PROPERTY_NAMES_COMPACT);
this.layerListener = new LayerListenerFixture();
this.treeLayer.addLayerListener(this.layerListener);
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture 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));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture 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.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.
the class ColumnGroupHeaderLayerSelectionTest method setup.
@Before
public void setup() {
this.dataProvider = new ListDataProvider<>(getNumberValues(), new ReflectiveColumnPropertyAccessor<>("columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber", "columnSixNumber", "columnSevenNumber", "columnEightNumber", "columnNineNumber", "columnTenNumber"));
this.gridLayer = new GridLayerFixture(this.dataProvider);
this.model = new ColumnGroupModel();
// 10 columns in header
this.columnGroupLayer = new ColumnGroupHeaderLayer(this.gridLayer.getColumnHeaderLayer(), this.gridLayer.getBodyLayer().getSelectionLayer(), this.model, false);
this.columnGroupLayer.addConfiguration(new DefaultColumnGroupHeaderLayerConfiguration(this.model, true));
this.gridLayer.getBodyLayer().getViewportLayer().registerCommandHandler(new ViewportSelectColumnGroupCommandHandler(this.gridLayer.getBodyLayer().getViewportLayer(), this.columnGroupLayer));
this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_1, 0, 1, 2);
this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_2, 5, 6);
this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_3, 8, 9);
this.gridLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 1050, 200);
}
});
this.gridLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
this.layerListener = new LayerListenerFixture();
this.gridLayer.getBodyLayer().addLayerListener(this.layerListener);
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture 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);
}
Aggregations