import org.apache.commons.lang.StringUtils;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration;
import org.eclipse.nebula.widgets.nattable.summaryrow.ISummaryProvider;
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowConfigAttributes;
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
-import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.description.CategoricalData;
*/
public class AggregationConfiguration extends DefaultSummaryRowConfiguration {
- private final IDataProvider dataProvider;
- private Feature feature;
+ private CharacterMatrix matrix;
- public AggregationConfiguration(IDataProvider dataProvider, Feature feature) {
- this.dataProvider = dataProvider;
- this.feature = feature;
- this.summaryRowBgColor = GUIHelper.COLOR_BLUE;
- this.summaryRowFgColor = GUIHelper.COLOR_WHITE;
+ public AggregationConfiguration(CharacterMatrix matrix) {
+ this.matrix = matrix;
}
@Override
public void addSummaryProviderConfig(IConfigRegistry configRegistry) {
- if(feature.isSupportsQuantitativeData()){
- configRegistry.registerConfigAttribute(
- SummaryRowConfigAttributes.SUMMARY_PROVIDER,
- new QuantitativeSummaryProvider(),
- DisplayMode.NORMAL,
- SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+MatrixUtility.getProperty(feature));
- }
- if(feature.isSupportsCategoricalData()){
- configRegistry.registerConfigAttribute(
- SummaryRowConfigAttributes.SUMMARY_PROVIDER,
- new CategoricalSummaryProvider(),
- DisplayMode.NORMAL,
- SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+MatrixUtility.getProperty(feature));
+ for(int i=0;i<matrix.getFeatures().size();i++){
+ //no summary for the supplemental columns
+ if(i<CharacterMatrix.LEADING_COLUMN_COUNT){
+ int index = i;
+ configRegistry.registerConfigAttribute(
+ SummaryRowConfigAttributes.SUMMARY_PROVIDER,
+ columnIndex -> "",
+ DisplayMode.NORMAL,
+ SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+index);
+ }
+ //register aggregation configuration for each feature
+ Feature feature = matrix.getFeatures().get(i);
+ if(feature.isSupportsQuantitativeData()){
+ configRegistry.registerConfigAttribute(
+ SummaryRowConfigAttributes.SUMMARY_PROVIDER,
+ new QuantitativeSummaryProvider(),
+ DisplayMode.NORMAL,
+ SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+MatrixUtility.getProperty(feature));
+ }
+ if(feature.isSupportsCategoricalData()){
+ configRegistry.registerConfigAttribute(
+ SummaryRowConfigAttributes.SUMMARY_PROVIDER,
+ new CategoricalSummaryProvider(),
+ DisplayMode.NORMAL,
+ SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+MatrixUtility.getProperty(feature));
+ }
}
}
public Object summarize(int columnIndex) {
Float minTotal = null;
Float maxTotal = null;
- int rowCount = AggregationConfiguration.this.dataProvider.getRowCount();
+ int rowCount = AggregationConfiguration.this.matrix.getBodyDataProvider().getRowCount();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
- Object dataValue = AggregationConfiguration.this.dataProvider.getDataValue(columnIndex,
+ Object dataValue = AggregationConfiguration.this.matrix.getBodyDataProvider().getDataValue(columnIndex,
rowIndex);
if(HibernateProxyHelper.isInstanceOf(dataValue, QuantitativeData.class)){
QuantitativeData quantitativeData = HibernateProxyHelper.deproxy(dataValue, QuantitativeData.class);
private class CategoricalSummaryProvider implements ISummaryProvider {
@Override
public Object summarize(int columnIndex) {
- int rowCount = AggregationConfiguration.this.dataProvider.getRowCount();
+ int rowCount = AggregationConfiguration.this.matrix.getBodyDataProvider().getRowCount();
Set states = new HashSet<>();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
- Object dataValue = AggregationConfiguration.this.dataProvider.getDataValue(columnIndex,
+ Object dataValue = AggregationConfiguration.this.matrix.getBodyDataProvider().getDataValue(columnIndex,
rowIndex);
if(dataValue instanceof CategoricalData){
states.addAll(((CategoricalData) dataValue).getStatesOnly());
+++ /dev/null
-// $Id$
-/**
-* Copyright (C) 2018 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
-
-import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
-import org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration;
-import org.eclipse.nebula.widgets.nattable.summaryrow.ISummaryProvider;
-import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowConfigAttributes;
-import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
-
-/**
- * @author pplitzner
- * @date 09.07.2018
- *
- */
-final class SummaryRowConfiguration extends DefaultSummaryRowConfiguration {
-
- public SummaryRowConfiguration() {
- super();
- }
-
-
- @Override
- public void addSummaryProviderConfig(IConfigRegistry configRegistry) {
- for(int i=0;i<CharacterMatrix.LEADING_COLUMN_COUNT;i++){
- int index = i;
- configRegistry.registerConfigAttribute(
- SummaryRowConfigAttributes.SUMMARY_PROVIDER,
- new ISummaryProvider() {
-
- @Override
- public Object summarize(int columnIndex) {
- return "";
- }
- },
- DisplayMode.NORMAL,
- SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+index);
- }
- }
-}