commit 2fa5cd448bbd6124297975fe1d8757f22d4d4e6a
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Thu Aug 16 15:43:18 2018 +0200

    Allow only exact values xOR aggregated values in cell editor

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialog.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialog.java
index 7a2ad250a..cf12519fb 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialog.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialog.java
@@ -75,12 +75,14 @@ public class QuantitativeDataDialog extends CellEditDialog {
         Map<StatisticalMeasure, List<Text>> textFields = composite.getTextFields();
         textFields.forEach((measure, texts)->{
             texts.forEach(text->{
-            String string = text.getText();
-            try {
-                float exactValue = Float.parseFloat(string);
-                quantitativeData.addStatisticalValue(StatisticalMeasurementValue.NewInstance(measure, exactValue));
-            } catch (NumberFormatException e) {
-            }
+                if(text.isEnabled()){
+                    String string = text.getText();
+                    try {
+                        float exactValue = Float.parseFloat(string);
+                        quantitativeData.addStatisticalValue(StatisticalMeasurementValue.NewInstance(measure, exactValue));
+                    } catch (NumberFormatException e) {
+                    }
+                }
             });
         });
     }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialogComposite.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialogComposite.java
index c4ea27629..044de0c5b 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialogComposite.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialogComposite.java
@@ -25,6 +25,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.model.description.QuantitativeData;
 import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
 import eu.etaxonomy.taxeditor.model.ImageResources;
@@ -76,6 +77,10 @@ public class QuantitativeDataDialogComposite extends Composite {
 
         scrolledComposite_1.setContent(valuesComposite);
         scrolledComposite_1.setMinSize(valuesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+        if(initialInput!=null){
+            enableAggregationFields(false);
+        }
     }
 
     private Text addText(Composite valuesComposite, StatisticalMeasure type, String value){
@@ -113,9 +118,27 @@ public class QuantitativeDataDialogComposite extends Composite {
                 text.setText("");
             }
         });
+        text.addModifyListener(e->{
+            boolean hasExactValues = textFieldMap.entrySet().stream()
+                    .filter(entry->entry.getKey().equals(StatisticalMeasure.EXACT_VALUE()))
+            .anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText()))
+            );
+            if(hasExactValues){
+                enableAggregationFields(false);
+            }
+            else{
+                enableAggregationFields(true);
+            }
+        });
         return text;
     }
 
+    private void enableAggregationFields(boolean enabled){
+        textFieldMap.entrySet().stream()
+        .filter(entry->!entry.getKey().equals(StatisticalMeasure.EXACT_VALUE()))
+        .forEach(aggEntry->aggEntry.getValue().forEach(aggText->aggText.setEnabled(enabled)));
+    }
+
     public Map<StatisticalMeasure, List<Text>> getTextFields() {
         return textFieldMap;
     }
