Search in sources :

Example 6 with SpanningDataLayer

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

the class _5014_SpanningDataLayerExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // To make the default edit and selection configurations work correctly,
    // the region label
    // GridRegion.BODY is necessary, which is directly set to the
    // ViewportLayer instance here.
    ViewportLayer layer = new ViewportLayer(new SelectionLayer(new SpanningDataLayer(new DummySpanningBodyDataProvider(100, 100))));
    layer.setRegionName(GridRegion.BODY);
    NatTable natTable = new NatTable(parent, layer, false);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    // add configurations to enable editing
    // this is to verify that spanned cells are also editable and update the
    // data model correctly
    // @see Bug 414754
    layer.addConfiguration(new DefaultEditBindings());
    layer.addConfiguration(new DefaultEditConfiguration());
    layer.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
        }
    });
    natTable.configure();
    return natTable;
}
Also used : DefaultEditConfiguration(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DefaultEditBindings(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings)

Example 7 with SpanningDataLayer

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

the class _5015_AutomaticDataSpanningExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // property names of the NumberValues class
    String[] propertyNames = { "columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber" };
    IColumnPropertyAccessor<NumberValues> cpa = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider dataProvider = new ListDataProvider<>(createNumberValueList(), cpa);
    AutomaticSpanningDataProvider spanningDataProvider = new AutomaticSpanningDataProvider(dataProvider, true, false);
    // spanningDataProvider.addAutoSpanningColumnPositions(0, 1, 2);
    // spanningDataProvider.addAutoSpanningColumnPositions(2, 3, 4);
    // spanningDataProvider.addAutoSpanningColumnPositions(0, 1, 3, 4);
    // spanningDataProvider.addAutoSpanningRowPositions(0, 1, 2);
    // spanningDataProvider.addAutoSpanningRowPositions(2, 3, 4);
    // spanningDataProvider.addAutoSpanningRowPositions(0, 1, 3, 4);
    NatTable natTable = new NatTable(parent, new ViewportLayer(new SelectionLayer(new SpanningDataLayer(spanningDataProvider))), false);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.addConfiguration(new BodyMenuConfiguration(natTable, spanningDataProvider));
    natTable.configure();
    natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler());
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) AutomaticSpanningDataProvider(org.eclipse.nebula.widgets.nattable.data.AutomaticSpanningDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) DisplayPersistenceDialogCommandHandler(org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) NatTable(org.eclipse.nebula.widgets.nattable.NatTable)

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