Search in sources :

Example 16 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class _5123_SummaryRowPositionExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 20;
    panel.setLayout(layout);
    // 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);
    ConfigRegistry configRegistry = new ConfigRegistry();
    // Summary row fixed on top
    DataLayer dataLayer = new DataLayer(dataProvider);
    ViewportLayer viewportLayer = new ViewportLayer(dataLayer);
    // Plug in the SummaryRowLayer
    FixedSummaryRowLayer summaryRowLayer = new FixedSummaryRowLayer(dataLayer, viewportLayer, configRegistry, false);
    summaryRowLayer.setHorizontalCompositeDependency(false);
    CompositeLayer composite = new CompositeLayer(1, 2);
    composite.setChildLayer("SUMMARY", summaryRowLayer, 0, 0);
    composite.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
    NatTable natTable = new NatTable(panel, composite, false);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
    // Configure custom summary formula for a column
    natTable.addConfiguration(new ExampleSummaryRowConfiguration(dataProvider));
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.setConfigRegistry(configRegistry);
    natTable.configure();
    // Summary row fixed at the bottom
    dataLayer = new DataLayer(dataProvider);
    // IMPORTANT:
    // since the summary row layer is to the bottom of the viewport layer
    // we need to configure a GridLineCellLayerPainter that clips the top
    // cell. This means the body data layer is clipped at the bottom since
    // the painter is used globally
    dataLayer.setLayerPainter(new GridLineCellLayerPainter(false, true));
    viewportLayer = new ViewportLayer(dataLayer);
    // Plug in the SummaryRowLayer
    summaryRowLayer = new FixedSummaryRowLayer(dataLayer, viewportLayer, configRegistry, false);
    summaryRowLayer.setHorizontalCompositeDependency(false);
    composite = new CompositeLayer(1, 2);
    composite.setChildLayer(GridRegion.BODY, viewportLayer, 0, 0);
    composite.setChildLayer("SUMMARY", summaryRowLayer, 0, 1);
    natTable = new NatTable(panel, composite, false);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
    // Configure custom summary formula for a column
    natTable.addConfiguration(new ExampleSummaryRowConfiguration(dataProvider));
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.setConfigRegistry(configRegistry);
    natTable.configure();
    return panel;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) Composite(org.eclipse.swt.widgets.Composite) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) FixedSummaryRowLayer(org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) GridLayout(org.eclipse.swt.layout.GridLayout) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) GridLineCellLayerPainter(org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter)

Example 17 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class _5123_SummaryRowPositionExample method createNumberValueList.

private List<NumberValues> createNumberValueList() {
    List<NumberValues> result = new ArrayList<>();
    NumberValues nv = new NumberValues();
    nv.setColumnOneNumber(5);
    nv.setColumnTwoNumber(4);
    nv.setColumnThreeNumber(3);
    nv.setColumnFourNumber(1);
    nv.setColumnFiveNumber(1);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(1);
    nv.setColumnTwoNumber(1);
    nv.setColumnThreeNumber(2);
    nv.setColumnFourNumber(2);
    nv.setColumnFiveNumber(3);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(1);
    nv.setColumnTwoNumber(2);
    nv.setColumnThreeNumber(2);
    nv.setColumnFourNumber(3);
    nv.setColumnFiveNumber(3);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(1);
    nv.setColumnTwoNumber(2);
    nv.setColumnThreeNumber(4);
    nv.setColumnFourNumber(4);
    nv.setColumnFiveNumber(3);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(5);
    nv.setColumnTwoNumber(4);
    nv.setColumnThreeNumber(4);
    nv.setColumnFourNumber(4);
    nv.setColumnFiveNumber(7);
    result.add(nv);
    for (int i = 0; i < 10; i++) {
        nv = new NumberValues();
        nv.setColumnOneNumber(5);
        nv.setColumnTwoNumber(4);
        nv.setColumnThreeNumber(4);
        nv.setColumnFourNumber(4);
        nv.setColumnFiveNumber(7);
        result.add(nv);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues)

Example 18 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class _5015_AutomaticDataSpanningExample method createNumberValueList.

private List<NumberValues> createNumberValueList() {
    List<NumberValues> result = new ArrayList<>();
    NumberValues nv = new NumberValues();
    nv.setColumnOneNumber(5);
    nv.setColumnTwoNumber(4);
    nv.setColumnThreeNumber(3);
    nv.setColumnFourNumber(1);
    nv.setColumnFiveNumber(1);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(1);
    nv.setColumnTwoNumber(1);
    nv.setColumnThreeNumber(2);
    nv.setColumnFourNumber(2);
    nv.setColumnFiveNumber(3);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(1);
    nv.setColumnTwoNumber(2);
    nv.setColumnThreeNumber(2);
    nv.setColumnFourNumber(3);
    nv.setColumnFiveNumber(3);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(1);
    nv.setColumnTwoNumber(2);
    nv.setColumnThreeNumber(4);
    nv.setColumnFourNumber(4);
    nv.setColumnFiveNumber(3);
    result.add(nv);
    nv = new NumberValues();
    nv.setColumnOneNumber(5);
    nv.setColumnTwoNumber(4);
    nv.setColumnThreeNumber(4);
    nv.setColumnFourNumber(4);
    nv.setColumnFiveNumber(7);
    result.add(nv);
    return result;
}
Also used : ArrayList(java.util.ArrayList) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues)

Example 19 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues 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)

Example 20 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class _774_MultiExportExample method createNumberValues.

private NumberValues createNumberValues() {
    NumberValues nv = new NumberValues();
    nv.setColumnOneNumber(10);
    nv.setColumnTwoNumber(20);
    nv.setColumnThreeNumber(30);
    nv.setColumnFourNumber(40);
    nv.setColumnFiveNumber(50);
    return nv;
}
Also used : NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues)

Aggregations

NumberValues (org.eclipse.nebula.widgets.nattable.dataset.NumberValues)22 ArrayList (java.util.ArrayList)10 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)6 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)6 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)5 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)5 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)5 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)5 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)4 HashMap (java.util.HashMap)3 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 FixedSummaryRowLayer (org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer)2 Map (java.util.Map)1 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)1 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)1 AutomaticSpanningDataProvider (org.eclipse.nebula.widgets.nattable.data.AutomaticSpanningDataProvider)1