Revision 2fa5cd44
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialog.java | ||
---|---|---|
75 | 75 |
Map<StatisticalMeasure, List<Text>> textFields = composite.getTextFields(); |
76 | 76 |
textFields.forEach((measure, texts)->{ |
77 | 77 |
texts.forEach(text->{ |
78 |
String string = text.getText(); |
|
79 |
try { |
|
80 |
float exactValue = Float.parseFloat(string); |
|
81 |
quantitativeData.addStatisticalValue(StatisticalMeasurementValue.NewInstance(measure, exactValue)); |
|
82 |
} catch (NumberFormatException e) { |
|
83 |
} |
|
78 |
if(text.isEnabled()){ |
|
79 |
String string = text.getText(); |
|
80 |
try { |
|
81 |
float exactValue = Float.parseFloat(string); |
|
82 |
quantitativeData.addStatisticalValue(StatisticalMeasurementValue.NewInstance(measure, exactValue)); |
|
83 |
} catch (NumberFormatException e) { |
|
84 |
} |
|
85 |
} |
|
84 | 86 |
}); |
85 | 87 |
}); |
86 | 88 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialogComposite.java | ||
---|---|---|
25 | 25 |
import org.eclipse.swt.widgets.Label; |
26 | 26 |
import org.eclipse.swt.widgets.Text; |
27 | 27 |
|
28 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
28 | 29 |
import eu.etaxonomy.cdm.model.description.QuantitativeData; |
29 | 30 |
import eu.etaxonomy.cdm.model.description.StatisticalMeasure; |
30 | 31 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
... | ... | |
76 | 77 |
|
77 | 78 |
scrolledComposite_1.setContent(valuesComposite); |
78 | 79 |
scrolledComposite_1.setMinSize(valuesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
80 |
|
|
81 |
if(initialInput!=null){ |
|
82 |
enableAggregationFields(false); |
|
83 |
} |
|
79 | 84 |
} |
80 | 85 |
|
81 | 86 |
private Text addText(Composite valuesComposite, StatisticalMeasure type, String value){ |
... | ... | |
113 | 118 |
text.setText(""); |
114 | 119 |
} |
115 | 120 |
}); |
121 |
text.addModifyListener(e->{ |
|
122 |
boolean hasExactValues = textFieldMap.entrySet().stream() |
|
123 |
.filter(entry->entry.getKey().equals(StatisticalMeasure.EXACT_VALUE())) |
|
124 |
.anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText())) |
|
125 |
); |
|
126 |
if(hasExactValues){ |
|
127 |
enableAggregationFields(false); |
|
128 |
} |
|
129 |
else{ |
|
130 |
enableAggregationFields(true); |
|
131 |
} |
|
132 |
}); |
|
116 | 133 |
return text; |
117 | 134 |
} |
118 | 135 |
|
136 |
private void enableAggregationFields(boolean enabled){ |
|
137 |
textFieldMap.entrySet().stream() |
|
138 |
.filter(entry->!entry.getKey().equals(StatisticalMeasure.EXACT_VALUE())) |
|
139 |
.forEach(aggEntry->aggEntry.getValue().forEach(aggText->aggText.setEnabled(enabled))); |
|
140 |
} |
|
141 |
|
|
119 | 142 |
public Map<StatisticalMeasure, List<Text>> getTextFields() { |
120 | 143 |
return textFieldMap; |
121 | 144 |
} |
Also available in: Unified diff
Allow only exact values xOR aggregated values in cell editor