use of org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByModel 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.groupBy.GroupByModel in project nebula.widgets.nattable by eclipse.
the class GroupByDataLayerTest method setup.
@Before
public void setup() {
this.groupByModel = new GroupByModel();
EventList<Person> eventList = GlazedLists.eventList(PersonService.getFixedPersons());
this.sortedList = new SortedList<>(eventList, null);
this.columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(this.propertyNames);
this.dataLayer = new GroupByDataLayer<>(this.groupByModel, this.sortedList, this.columnPropertyAccessor, this.configRegistry);
this.dataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
}
use of org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByModel in project nebula.widgets.nattable by eclipse.
the class _200_Group_by method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(1, false));
// Underlying data source
EventList<RowDataFixture> eventList = GlazedLists.eventList(RowDataListFixture.getList(200));
String[] propertyNames = RowDataListFixture.getPropertyNames();
Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
IColumnPropertyAccessor<RowDataFixture> reflectiveColumnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
GroupByModel groupByModel = new GroupByModel();
// Summary
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER, new SummationGroupBySummaryProvider<>(reflectiveColumnPropertyAccessor), DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.LOT_SIZE_PROP_NAME));
GroupByDataLayer<RowDataFixture> bodyDataLayer = new GroupByDataLayer<>(groupByModel, eventList, reflectiveColumnPropertyAccessor, configRegistry);
// Body layer
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
TreeLayer treeLayer = new TreeLayer(selectionLayer, bodyDataLayer.getTreeRowModel());
FreezeLayer freeze = new FreezeLayer(treeLayer);
ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
CompositeFreezeLayer compFreeze = new CompositeFreezeLayer(freeze, viewportLayer, selectionLayer);
// Column header layer
final IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
final DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, compFreeze, selectionLayer);
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(columnHeaderDataLayer);
columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);
bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
// Register labels
labelAccumulator.registerColumnOverrides(RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.RATING_PROP_NAME), "CUSTOM_COMPARATOR_LABEL");
// Row header layer
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataLayer.getDataProvider());
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, compFreeze, selectionLayer);
// Corner layer
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(compFreeze, columnHeaderLayer, rowHeaderLayer, cornerLayer, false);
CompositeLayer compositeGridLayer = new CompositeLayer(1, 2);
final GroupByHeaderLayer groupByHeaderLayer = new GroupByHeaderLayer(groupByModel, gridLayer, columnHeaderDataProvider);
compositeGridLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION, groupByHeaderLayer, 0, 0);
compositeGridLayer.setChildLayer("Grid", gridLayer, 0, 1);
NatTable natTable = new NatTable(comp, compositeGridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new GroupByHeaderMenuConfiguration(natTable, groupByHeaderLayer));
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.addConfiguration(new DebugMenuConfiguration(natTable));
natTable.setConfigRegistry(configRegistry);
natTable.configure();
natTable.setLayoutData(new GridData(GridData.FILL_BOTH));
Button button = new Button(comp, SWT.NONE);
button.setText("Toggle Group By Header");
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
groupByHeaderLayer.setVisible(!groupByHeaderLayer.isVisible());
}
});
return comp;
}
Aggregations