Search in sources :

Example 1 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture 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)

Example 2 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.

the class HideMultipleColumnsIntegrationTest method hideAllColumnsWithColumnGroupsEnabled.

/**
 * Exposing bug: http://nattable.org/jira/browse/NTBL-471
 */
@Test
public void hideAllColumnsWithColumnGroupsEnabled() throws Exception {
    BodyLayerStackFixture<RowDataFixture> bodyLayerStackFixture = new BodyLayerStackFixture<RowDataFixture>(GlazedLists.eventList(RowDataListFixture.getList()), new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()), new ConfigRegistry());
    NatTableFixture natTableFixture = new NatTableFixture(bodyLayerStackFixture);
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    natTableFixture.addLayerListener(listenerFixture);
    Assert.assertEquals(37, bodyLayerStackFixture.getBodyDataProvider().getColumnCount());
    Assert.assertEquals(6, natTableFixture.getColumnCount());
    MultiColumnHideCommand hideAllCommand = new MultiColumnHideCommand(natTableFixture, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 });
    natTableFixture.doCommand(hideAllCommand);
    Assert.assertEquals(1, listenerFixture.getEventsCount());
    ILayerEvent receivedEvent = listenerFixture.getReceivedEvent(HideColumnPositionsEvent.class);
    Assert.assertNotNull(receivedEvent);
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.LayerListenerFixture) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 3 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.

the class SortIntegrationTest method setup.

@Before
public void setup() {
    EventList<RowDataFixture> eventList = GlazedLists.eventList(RowDataListFixture.getList().subList(0, 4));
    ConfigRegistry configRegistry = new ConfigRegistry();
    this.gridLayerStack = new GlazedListsGridLayer<RowDataFixture>(GlazedLists.threadSafeList(eventList), RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
    this.nattable = new NatTableFixture(this.gridLayerStack, false);
    this.nattable.setConfigRegistry(configRegistry);
    this.nattable.addConfiguration(new DefaultNatTableStyleConfiguration());
    this.nattable.addConfiguration(new DefaultSortConfiguration());
    this.nattable.configure();
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) DefaultSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Example 4 with NatTableFixture

use of org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.

the class RowSelectionIntegrationTest method setup.

@Before
public void setup() {
    IConfigRegistry configRegistry = new ConfigRegistry();
    // 10 rows in fixture
    this.eventListFixture = GlazedLists.eventList(RowDataListFixture.getList(10));
    GlazedListsGridLayer<RowDataFixture> gridLayer = new GlazedListsGridLayer<>(this.eventListFixture, RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
    this.nattable = new NatTableFixture(gridLayer, false);
    this.nattable.setConfigRegistry(configRegistry);
    this.selectionLayer = gridLayer.getBodyLayerStack().getSelectionLayer();
    this.bodyDataProvider = gridLayer.getBodyDataProvider();
    this.selectionProvider = new RowSelectionProvider<>(this.selectionLayer, this.bodyDataProvider);
    this.nattable.addConfiguration(new DefaultSortConfiguration());
    // Enable preserve selection on data update
    this.selectionLayer.setSelectionModel(new RowSelectionModel<>(this.selectionLayer, this.bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {

        @Override
        public Serializable getRowId(RowDataFixture rowObject) {
            return rowObject.getSecurity_id();
        }
    }));
    // Enable test mode - events can be fired outside the Display thread
    gridLayer.getGlazedListsEventLayer().setTestMode(true);
    this.nattable.configure();
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Aggregations

ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)4 NatTableFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture)4 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)3 Before (org.junit.Before)3 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 DefaultSortConfiguration (org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration)2 ArrayList (java.util.ArrayList)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 IColumnAccessor (org.eclipse.nebula.widgets.nattable.data.IColumnAccessor)1 IRowIdAccessor (org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor)1 GlazedListsEventLayer (org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer)1 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.LayerListenerFixture)1 GroupByDataLayer (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByDataLayer)1 GroupByModel (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByModel)1 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)1 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)1 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)1 DefaultSummaryRowConfiguration (org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration)1