use of org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer 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.layer.SpanningDataLayer in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method openEditorForSpannedCellsShouldOpenInline.
@Test
public void openEditorForSpannedCellsShouldOpenInline() throws Exception {
CompositeLayer layer = new CompositeLayer(1, 1);
SelectionLayer selectionLayer = new SelectionLayer(new SpanningDataLayer(new DummySpanningBodyDataProvider(100, 100)));
layer.setChildLayer(GridRegion.BODY, new ViewportLayer(selectionLayer), 0, 0);
this.natTable = new NatTableFixture(layer, 1200, 300, false);
layer.addConfiguration(new DefaultEditBindings());
layer.addConfiguration(new DefaultEditConfiguration());
this.natTable.enableEditingOnAllCells();
final boolean[] inlineFired = new boolean[1];
inlineFired[0] = false;
selectionLayer.addLayerListener(new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof InlineCellEditEvent) {
inlineFired[0] = true;
}
}
});
this.natTable.configure();
this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.F2));
// Verify edit mode
assertNotNull(this.natTable.getActiveCellEditor());
assertEquals("Col: 1, Row: 1", this.natTable.getActiveCellEditor().getCanonicalValue());
assertNotNull(ActiveCellEditorRegistry.getActiveCellEditor());
assertEquals("Col: 1, Row: 1", ActiveCellEditorRegistry.getActiveCellEditor().getCanonicalValue());
// verify that inline editing is used and not dialog
assertTrue("No InlineCellEditEvent fired", inlineFired[0]);
}
use of org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer in project nebula.widgets.nattable by eclipse.
the class SpanningDataLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
CompositeLayer layer = new CompositeLayer(1, 1);
layer.setChildLayer(GridRegion.BODY, new ViewportLayer(new SelectionLayer(new SpanningDataLayer(new DummySpanningBodyDataProvider(1000000, 1000000)))), 0, 0);
return new NatTable(parent, layer);
}
use of org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerGlazedListsTest method setup.
@Before
public void setup() {
// de-normalize the object graph without parent structure objects
List<HierarchicalWrapper> data = HierarchicalHelper.deNormalize(CarService.getInput(), false, CarService.PROPERTY_NAMES_COMPACT);
EventList<HierarchicalWrapper> eventList = GlazedLists.eventList(data);
TransformedList<HierarchicalWrapper, HierarchicalWrapper> rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);
this.columnPropertyAccessor = new HierarchicalReflectiveColumnPropertyAccessor(CarService.PROPERTY_NAMES_COMPACT);
this.sortedList = new SortedList<>(rowObjectsGlazedList, new HierarchicalWrapperComparator(this.columnPropertyAccessor, HierarchicalHelper.getLevelIndexMapping(CarService.PROPERTY_NAMES_COMPACT)));
this.filterList = new FilterList<>(this.sortedList);
this.bodyDataProvider = new ListDataProvider<>(this.filterList, this.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());
// layer for event handling of GlazedLists and PropertyChanges
GlazedListsEventLayer<HierarchicalWrapper> glazedListsEventLayer = new GlazedListsEventLayer<>(this.bodyDataLayer, this.filterList);
glazedListsEventLayer.setTestMode(true);
this.selectionLayer = new SelectionLayer(glazedListsEventLayer);
this.treeLayer = new HierarchicalTreeLayer(this.selectionLayer, this.filterList, CarService.PROPERTY_NAMES_COMPACT);
// create a dummy config registry
this.configRegistry = new ConfigRegistry();
this.configRegistry.registerConfigAttribute(SortConfigAttributes.SORT_COMPARATOR, DefaultComparator.getInstance());
this.columnHeaderDataLayer = new DataLayer(new DefaultColumnHeaderDataProvider(CarService.PROPERTY_NAMES_COMPACT));
}
use of org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method updateAllUnderlyingCellsIfSpanned.
@Test
public void updateAllUnderlyingCellsIfSpanned() throws Exception {
CompositeLayer layer = new CompositeLayer(1, 1);
DummySpanningBodyDataProvider dataProvider = new DummySpanningBodyDataProvider(100, 100);
SelectionLayer selectionLayer = new SelectionLayer(new SpanningDataLayer(dataProvider));
layer.setChildLayer(GridRegion.BODY, new ViewportLayer(selectionLayer), 0, 0);
this.natTable = new NatTableFixture(layer, 1200, 300, false);
layer.addConfiguration(new DefaultEditBindings());
layer.addConfiguration(new DefaultEditConfiguration());
this.natTable.enableEditingOnAllCells();
this.natTable.configure();
assertEquals("Col: 1, Row: 1", dataProvider.getDataValue(0, 0));
assertEquals("Col: 1, Row: 2", dataProvider.getDataValue(0, 1));
assertEquals("Col: 2, Row: 1", dataProvider.getDataValue(1, 0));
assertEquals("Col: 2, Row: 2", dataProvider.getDataValue(1, 1));
this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEventWithChar('C'));
assertNotNull(this.natTable.getActiveCellEditor());
this.natTable.getActiveCellEditor().getEditorControl().notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.CR));
assertEquals("C", dataProvider.getDataValue(0, 0));
assertEquals("C", dataProvider.getDataValue(0, 1));
assertEquals("C", dataProvider.getDataValue(1, 0));
assertEquals("C", dataProvider.getDataValue(1, 1));
}
Aggregations