DisplayMode.NORMAL,
ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3);
configRegistry.registerConfigAttribute(
CellConfigAttributes.DISPLAY_CONVERTER,
new DefaultDoubleDisplayConverter(),
DisplayMode.NORMAL,
ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3);
// the main styling of the summary row cell in the row header is
// done via
// summary row default style, but we need to override the
// alignment
style = new Style();
style.setAttributeValue(
CellStyleAttributes.HORIZONTAL_ALIGNMENT,
HorizontalAlignmentEnum.CENTER);
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE, style,
DisplayMode.NORMAL, ROW_HEADER_SUMMARY_ROW);
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE, style,
DisplayMode.SELECT, ROW_HEADER_SUMMARY_ROW);
}
});
// add sorting configuration
natTable.addConfiguration(new SingleClickSortConfiguration());
this.sumMoneyGroupBySummaryProvider = new SummationGroupBySummaryProvider<ExtendedPersonWithAddress>(
columnPropertyAccessor);
this.avgMoneyGroupBySummaryProvider = new AverageMoneyGroupBySummaryProvider();
// create a new IDataProvider that operates on the basic underlying list
// this is necessary because the IDataProvider in the body layer stack
// is operating
// on the TreeList, and on collapsing a node, the children will be not
// visible, which
// has effect on the summary value.
final IDataProvider summaryDataProvider = new ListDataProvider<ExtendedPersonWithAddress>(
persons, columnPropertyAccessor);
this.sumMoneySummaryProvider = new SummationSummaryProvider(
summaryDataProvider, false);
this.avgMoneySummaryProvider = new AverageMoneySummaryProvider(
summaryDataProvider);
// add group by summary configuration
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// GroupBy summary configuration
configRegistry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER,
_809_GroupBySummarySummaryRowExample.this.sumMoneyGroupBySummaryProvider, DisplayMode.NORMAL,
GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + 3);
configRegistry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER,
new AverageAgeGroupBySummaryProvider(),
DisplayMode.NORMAL,
GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + 2);
configRegistry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_CHILD_COUNT_PATTERN,
"[{0}] - ({1})");
// set a custom display converter to the money groupby column
// that transforms the values correctly localized
configRegistry.registerConfigAttribute(
CellConfigAttributes.DISPLAY_CONVERTER,
new SummaryDisplayConverter(
new DefaultDoubleDisplayConverter()),
DisplayMode.NORMAL,
GroupByDataLayer.GROUP_BY_SUMMARY_COLUMN_PREFIX + 3);
// SummaryRow configuration
configRegistry
.registerConfigAttribute(
SummaryRowConfigAttributes.SUMMARY_PROVIDER,
_809_GroupBySummarySummaryRowExample.this.sumMoneySummaryProvider,
DisplayMode.NORMAL,
SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + 3);
configRegistry
.registerConfigAttribute(
SummaryRowConfigAttributes.SUMMARY_PROVIDER,
new AverageAgeSummaryProvider(
summaryDataProvider),
DisplayMode.NORMAL,
SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + 2);
configRegistry
.registerConfigAttribute(
CellConfigAttributes.DISPLAY_CONVERTER,
new SummaryDisplayConverter(
new DefaultDoubleDisplayConverter()),
DisplayMode.NORMAL,
SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + 3);
}
});