Revision 53521cab
Added by Katja Luther over 2 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataDialogComposite.java | ||
---|---|---|
142 | 142 |
|
143 | 143 |
|
144 | 144 |
//add aggregation values |
145 |
editorValue.getFeatureDto().getRecommendedStatisticalMeasures() |
|
146 |
.stream() |
|
147 |
.filter(sm->!sm.equals(exactValueDto)) |
|
148 |
.forEach(measure->{ |
|
149 |
BigDecimal specificStatisticalValue = editorValue.getSpecificStatisticalValue(measure.getUuid()); |
|
150 |
addText(valuesComposite, measure, specificStatisticalValue!=null?specificStatisticalValue.toString():null); |
|
151 |
}); |
|
145 |
if (editorValue.getFeatureDto().getRecommendedMeasurementUnits() != null){ |
|
146 |
editorValue.getFeatureDto().getRecommendedStatisticalMeasures() |
|
147 |
.stream() |
|
148 |
.filter(sm->!sm.equals(exactValueDto)) |
|
149 |
.forEach(measure->{ |
|
150 |
BigDecimal specificStatisticalValue = editorValue.getSpecificStatisticalValue(measure.getUuid()); |
|
151 |
addText(valuesComposite, measure, specificStatisticalValue!=null?specificStatisticalValue.toString():null); |
|
152 |
}); |
|
153 |
} |
|
152 | 154 |
|
153 | 155 |
scrolledComposite_1.setContent(valuesComposite); |
154 | 156 |
scrolledComposite_1.setMinSize(valuesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
155 | 157 |
|
156 |
if(initialInput!=null){ |
|
157 |
enableAggregationFields(false); |
|
158 |
} |
|
158 |
// if(initialInput!=null){ |
|
159 |
boolean hasExactValues = textFieldMap.entrySet().stream() |
|
160 |
.filter(entry->entry.getKey().equals(exactValueDto)) |
|
161 |
.anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText())) |
|
162 |
); |
|
163 |
|
|
164 |
boolean hasAggregatedValues = textFieldMap.entrySet().stream() |
|
165 |
.filter(entry->!entry.getKey().equals(exactValueDto)) |
|
166 |
.anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText())) |
|
167 |
); |
|
168 |
enableAggregationFields(hasExactValues, hasAggregatedValues); |
|
169 |
// } |
|
159 | 170 |
} |
160 | 171 |
|
161 | 172 |
private Text addText(Composite valuesComposite, TermDto type, String value){ |
... | ... | |
187 | 198 |
textFieldMap.put(type, list); |
188 | 199 |
list.add(text); |
189 | 200 |
|
190 |
Button btnNewButton_2 = new Button(composite_2, SWT.NONE);
|
|
191 |
btnNewButton_2.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
|
|
201 |
Button btnRemove = new Button(composite_2, SWT.NONE);
|
|
202 |
btnRemove.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
|
|
192 | 203 |
new Label(composite_2, SWT.NONE); |
193 |
btnNewButton_2.addSelectionListener(new SelectionAdapter() {
|
|
204 |
btnRemove.addSelectionListener(new SelectionAdapter() {
|
|
194 | 205 |
@Override |
195 | 206 |
public void widgetSelected(SelectionEvent e) { |
196 | 207 |
text.setText(""); |
208 |
boolean hasExactValues = textFieldMap.entrySet().stream() |
|
209 |
.filter(entry->entry.getKey().equals(exactValueDto)) |
|
210 |
.anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText())) |
|
211 |
); |
|
212 |
|
|
213 |
boolean hasAggregatedValues = textFieldMap.entrySet().stream() |
|
214 |
.filter(entry->!entry.getKey().equals(exactValueDto)) |
|
215 |
.anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText())) |
|
216 |
); |
|
217 |
|
|
218 |
enableAggregationFields(hasExactValues, hasAggregatedValues); |
|
197 | 219 |
} |
198 | 220 |
}); |
199 | 221 |
text.addModifyListener(e->{ |
... | ... | |
201 | 223 |
.filter(entry->entry.getKey().equals(exactValueDto)) |
202 | 224 |
.anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText())) |
203 | 225 |
); |
226 |
|
|
227 |
boolean hasAggregatedValues = textFieldMap.entrySet().stream() |
|
228 |
.filter(entry->!entry.getKey().equals(exactValueDto)) |
|
229 |
.anyMatch(exactEntry->exactEntry.getValue().stream().anyMatch(exactText->CdmUtils.isNotBlank(exactText.getText())) |
|
230 |
); |
|
204 | 231 |
|
205 |
enableAggregationFields(!hasExactValues);
|
|
232 |
enableAggregationFields(hasExactValues, hasAggregatedValues);
|
|
206 | 233 |
// if(hasExactValues){ |
207 | 234 |
// enableAggregationFields(false); |
208 | 235 |
// } |
... | ... | |
213 | 240 |
return text; |
214 | 241 |
} |
215 | 242 |
|
216 |
private void enableAggregationFields(boolean enabled){ |
|
243 |
private void enableAggregationFields(boolean hasExactValues, boolean hasAggregatedValues){ |
|
244 |
boolean enableAggregatedValues = hasAggregatedValues ==( hasAggregatedValues != hasExactValues); |
|
217 | 245 |
textFieldMap.entrySet().stream() |
218 | 246 |
.filter(entry->!entry.getKey().equals(exactValueDto)) |
219 |
.forEach(aggEntry->aggEntry.getValue().forEach(aggText->aggText.setEnabled(enabled)));
|
|
220 |
|
|
247 |
.forEach(aggEntry->aggEntry.getValue().forEach(aggText->aggText.setEnabled(enableAggregatedValues)));
|
|
248 |
boolean enableExactValues = hasExactValues ==( hasAggregatedValues != hasExactValues); |
|
221 | 249 |
textFieldMap.entrySet().stream() |
222 | 250 |
.filter(entry->entry.getKey().equals(exactValueDto)) |
223 |
.forEach(aggEntry->aggEntry.getValue().forEach(aggText->aggText.setEnabled(!enabled)));
|
|
251 |
.forEach(aggEntry->aggEntry.getValue().forEach(aggText->aggText.setEnabled(enableExactValues)));
|
|
224 | 252 |
} |
225 | 253 |
|
226 | 254 |
public Map<TermDto, List<Text>> getTextFields() { |
Also available in: Unified diff
ref #9800: correct handling of enabled/disabled fields in quantitative data dialog