Search in sources :

Example 1 with IColumnAccessor

use of org.eclipse.nebula.widgets.nattable.data.IColumnAccessor in project nebula.widgets.nattable by eclipse.

the class GroupByDataLayerSummaryRowConcurrencyTest method setup.

@Before
public void setup() {
    List<Value> values = new ArrayList<Value>();
    values.add(new Value(1));
    values.add(new Value(2));
    values.add(new Value(3));
    values.add(new Value(4));
    values.add(new Value(5));
    values.add(new Value(6));
    values.add(new Value(7));
    values.add(new Value(8));
    values.add(new Value(9));
    values.add(new Value(10));
    IColumnAccessor<Value> columnAccessor = new IColumnAccessor<Value>() {

        @Override
        public Object getDataValue(Value rowObject, int columnIndex) {
            if (columnIndex % 2 == 0) {
                try {
                    Thread.sleep(80);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            return rowObject.value;
        }

        @Override
        public void setDataValue(Value rowObject, int columnIndex, Object newValue) {
        }

        @Override
        public int getColumnCount() {
            return 10;
        }
    };
    EventList<Value> eventList = GlazedLists.eventList(values);
    TransformedList<Value, Value> rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);
    ConfigRegistry configRegistry = new ConfigRegistry();
    final GroupByDataLayer<Value> dataLayer = new GroupByDataLayer<Value>(new GroupByModel(), eventList, columnAccessor);
    // DataLayer dataLayer = new DataLayer(dataProvider);
    GlazedListsEventLayer<Value> glazedListsEventLayer = new GlazedListsEventLayer<Value>(dataLayer, rowObjectsGlazedList);
    DefaultBodyLayerStack bodyLayerStack = new DefaultBodyLayerStack(glazedListsEventLayer);
    this.summaryRowLayer = new FixedSummaryRowLayer(dataLayer, bodyLayerStack, configRegistry, false);
    this.summaryRowLayer.setHorizontalCompositeDependency(false);
    CompositeLayer composite = new CompositeLayer(1, 2);
    composite.setChildLayer("SUMMARY", this.summaryRowLayer, 0, 0);
    composite.setChildLayer(GridRegion.BODY, bodyLayerStack, 0, 1);
    NatTable natTable = new NatTableFixture(composite, false);
    natTable.addConfiguration(new DefaultSummaryRowConfiguration() {

        @Override
        protected void addSummaryProviderConfig(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(SummaryRowConfigAttributes.SUMMARY_PROVIDER, new SummationSummaryProvider(dataLayer.getDataProvider(), false), DisplayMode.NORMAL, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL);
        }
    });
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.setConfigRegistry(configRegistry);
    natTable.configure();
}
Also used : GroupByDataLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByDataLayer) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) ArrayList(java.util.ArrayList) GlazedListsEventLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) IColumnAccessor(org.eclipse.nebula.widgets.nattable.data.IColumnAccessor) SummationSummaryProvider(org.eclipse.nebula.widgets.nattable.summaryrow.SummationSummaryProvider) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) FixedSummaryRowLayer(org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer) GroupByModel(org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByModel) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) DefaultSummaryRowConfiguration(org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)1 IColumnAccessor (org.eclipse.nebula.widgets.nattable.data.IColumnAccessor)1 GlazedListsEventLayer (org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer)1 NatTableFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture)1 GroupByDataLayer (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByDataLayer)1 GroupByModel (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByModel)1 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)1 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)1 DefaultSummaryRowConfiguration (org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration)1 FixedSummaryRowLayer (org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer)1 SummationSummaryProvider (org.eclipse.nebula.widgets.nattable.summaryrow.SummationSummaryProvider)1 Before (org.junit.Before)1