Search in sources :

Example 1 with SpanningDataLayer

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);
}
Also used : SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) ColumnLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) Before(org.junit.Before)

Example 2 with SpanningDataLayer

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]);
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) DummySpanningBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummySpanningBodyDataProvider) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DefaultEditBindings(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings) ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) DefaultEditConfiguration(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) InlineCellEditEvent(org.eclipse.nebula.widgets.nattable.edit.event.InlineCellEditEvent) Test(org.junit.Test)

Example 3 with SpanningDataLayer

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);
}
Also used : SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) DummySpanningBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummySpanningBodyDataProvider) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer)

Example 4 with SpanningDataLayer

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));
}
Also used : HierarchicalWrapper(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapper) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) GlazedListsEventLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) HierarchicalWrapperComparator(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapperComparator) ColumnLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) HierarchicalReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalReflectiveColumnPropertyAccessor) HierarchicalSpanningDataProvider(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalSpanningDataProvider) HierarchicalTreeLayer(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer) Before(org.junit.Before)

Example 5 with SpanningDataLayer

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));
}
Also used : DefaultEditConfiguration(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) DummySpanningBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummySpanningBodyDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DefaultEditBindings(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings) Test(org.junit.Test)

Aggregations

SpanningDataLayer (org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer)7 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)7 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)5 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)3 DefaultEditBindings (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings)3 DefaultEditConfiguration (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration)3 DummySpanningBodyDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DummySpanningBodyDataProvider)3 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)3 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)2 ColumnLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator)2 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)2 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)2 Before (org.junit.Before)2 Test (org.junit.Test)2 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)1 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)1 AutomaticSpanningDataProvider (org.eclipse.nebula.widgets.nattable.data.AutomaticSpanningDataProvider)1 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)1 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)1