Project

General

Profile

« Previous | Next » 

Revision 034d4a6a

Added by Patrick Plitzner over 4 years ago

ref #7095 Add categorical data support for summary row

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/AggregationConfiguration.java
17 17
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
18 18
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
19 19

  
20
import eu.etaxonomy.cdm.model.description.CategoricalData;
20 21
import eu.etaxonomy.cdm.model.description.Feature;
21 22
import eu.etaxonomy.cdm.model.description.QuantitativeData;
23
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
22 24

  
23 25
/**
24 26
 * @author pplitzner
......
46 48
                    DisplayMode.NORMAL,
47 49
                    SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+MatrixUtility.getProperty(feature));
48 50
        }
51
        if(feature.isSupportsCategoricalData()){
52
            configRegistry.registerConfigAttribute(
53
                    SummaryRowConfigAttributes.SUMMARY_PROVIDER,
54
                    new CategoricalSummaryProvider(),
55
                    DisplayMode.NORMAL,
56
                    SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+MatrixUtility.getProperty(feature));
57
        }
49 58
    }
50 59

  
51
    class QuantitativeSummaryProvider implements ISummaryProvider {
60
    private class QuantitativeSummaryProvider implements ISummaryProvider {
52 61
        @Override
53 62
        public Object summarize(int columnIndex) {
54 63
            Float minTotal = null;
......
81 90
        }
82 91
    }
83 92

  
93
    private class CategoricalSummaryProvider implements ISummaryProvider {
94
        @Override
95
        public Object summarize(int columnIndex) {
96
            String summaryString = "";
97
            String separator = ", ";
98
            int rowCount = AggregationConfiguration.this.dataProvider.getRowCount();
99
            for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
100
                Object dataValue = AggregationConfiguration.this.dataProvider.getDataValue(columnIndex,
101
                        rowIndex);
102
                if(dataValue instanceof CategoricalData){
103
                    CategoricalData categoricalData = (CategoricalData)dataValue;
104
                    summaryString += DescriptionHelper.getLabel(categoricalData)+separator;
105
                }
106
            }
107
            summaryString = summaryString.substring(0, summaryString.length()-separator.length());
108
            return summaryString;
109
        }
110
    }
111

  
84 112
}

Also available in: Unified diff