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();
}
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);
}
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();
}
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();
}
Aggregations