Revision a1171a3c
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixUtility.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix; |
10 | 10 |
|
11 | 11 |
import java.util.Set; |
12 |
import java.util.stream.Collectors; |
|
13 | 12 |
|
14 | 13 |
import org.eclipse.swt.graphics.Image; |
15 | 14 |
|
... | ... | |
17 | 16 |
import eu.etaxonomy.cdm.model.description.DescriptionType; |
18 | 17 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
19 | 18 |
import eu.etaxonomy.cdm.model.description.Feature; |
20 |
import eu.etaxonomy.cdm.model.description.QuantitativeData; |
|
21 |
import eu.etaxonomy.cdm.model.description.StatisticalMeasure; |
|
22 | 19 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
23 | 20 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
24 | 21 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
... | ... | |
40 | 37 |
return feature.getLabel(); |
41 | 38 |
} |
42 | 39 |
|
43 |
/** |
|
44 |
* Returns a string representation for the given {@link QuantitativeData} |
|
45 |
* @param data the quantitative data |
|
46 |
* @return a string representation of the data |
|
47 |
*/ |
|
48 |
public static String getQuantitativeLabel(QuantitativeData data) { |
|
49 |
String label = ""; |
|
50 |
Float min = data.getMin(); |
|
51 |
Float max = data.getMax(); |
|
52 |
if(min!=null||max!=null){ |
|
53 |
label += "["+(min!=null?min.toString():"?")+"-"+(max!=null?max.toString():"?")+"] "; |
|
54 |
} |
|
55 |
label += data.getStatisticalValues().stream(). |
|
56 |
filter(value->value.getType().equals(StatisticalMeasure.EXACT_VALUE())) |
|
57 |
.map(exact->Float.toString(exact.getValue())) |
|
58 |
.collect(Collectors.joining(", ")); |
|
59 |
|
|
60 |
return label; |
|
61 |
} |
|
62 |
|
|
63 | 40 |
/** |
64 | 41 |
* Returns a string representation for the given min/max values |
65 | 42 |
* @param minTotal the min value |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/categorical/CategoricalDataCellEditor.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical; |
10 | 10 |
|
11 |
import java.util.List; |
|
12 |
import java.util.stream.Collectors; |
|
13 |
|
|
14 | 11 |
import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor; |
15 | 12 |
import org.eclipse.nebula.widgets.nattable.widget.NatCombo; |
16 | 13 |
import org.eclipse.swt.events.SelectionEvent; |
... | ... | |
19 | 16 |
import org.eclipse.swt.widgets.Control; |
20 | 17 |
|
21 | 18 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
22 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
|
23 | 19 |
import eu.etaxonomy.cdm.model.description.Feature; |
24 |
import eu.etaxonomy.cdm.model.description.State; |
|
25 | 20 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrix; |
26 | 21 |
|
27 | 22 |
/** |
... | ... | |
52 | 47 |
((RowWrapperDTO) rowWrapper).addCategoricalData(feature); |
53 | 48 |
} |
54 | 49 |
} |
55 |
if(canonicalValue instanceof CategoricalData){ |
|
56 |
List<State> statesOnly = ((CategoricalData) canonicalValue).getStatesOnly(); |
|
57 |
super.setCanonicalValue(statesOnly.stream().map(state->state.getTitleCache()).collect(Collectors.toList())); |
|
58 |
return; |
|
59 |
} |
|
60 | 50 |
super.setCanonicalValue(canonicalValue); |
61 | 51 |
} |
62 | 52 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/categorical/CategoricalDataDisplayConverter.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
|
16 |
import eu.etaxonomy.cdm.model.description.State; |
|
17 | 15 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
18 | 16 |
import eu.etaxonomy.cdm.remote.l10n.TermRepresentation_L10n; |
19 |
import eu.etaxonomy.taxeditor.model.DescriptionHelper; |
|
20 | 17 |
|
21 | 18 |
/** |
22 | 19 |
* Converts CategoricalData and States of one cell of the character matrix to a |
... | ... | |
28 | 25 |
*/ |
29 | 26 |
public class CategoricalDataDisplayConverter extends DisplayConverter { |
30 | 27 |
|
31 |
/** |
|
32 |
* {@inheritDoc} |
|
33 |
*/ |
|
34 | 28 |
@Override |
35 | 29 |
public Object canonicalToDisplayValue(Object canonicalValue) { |
36 |
if(canonicalValue instanceof CategoricalData){ |
|
37 |
String text = DescriptionHelper.getLabel(canonicalValue); |
|
38 |
return text.equals(DescriptionHelper.NO_LABEL_STRING)?"":text; |
|
39 |
} |
|
40 |
else if(canonicalValue instanceof State){ |
|
41 |
return ((State) canonicalValue).getLabel(); |
|
42 |
} |
|
43 |
else if(canonicalValue instanceof TermDto){ |
|
30 |
if(canonicalValue instanceof TermDto){ |
|
44 | 31 |
((TermDto) canonicalValue).localize(new TermRepresentation_L10n()); |
45 | 32 |
return ((TermDto) canonicalValue).getRepresentation_L10n(); |
46 | 33 |
} |
... | ... | |
59 | 46 |
return null; |
60 | 47 |
} |
61 | 48 |
|
62 |
/** |
|
63 |
* {@inheritDoc} |
|
64 |
*/ |
|
65 | 49 |
@Override |
66 | 50 |
public Object displayToCanonicalValue(Object displayValue) { |
67 | 51 |
return null; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/quantitative/QuantitativeDataNormalModeDisplayConverter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative; |
10 | 10 |
|
11 |
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
|
|
11 |
import java.util.Collection;
|
|
12 | 12 |
|
13 |
import eu.etaxonomy.cdm.model.description.QuantitativeData; |
|
14 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.MatrixUtility; |
|
13 |
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter; |
|
15 | 14 |
|
16 | 15 |
/** |
17 | 16 |
* Converts QuantitativeData of one cell of the character matrix to a String. |
... | ... | |
24 | 23 |
|
25 | 24 |
@Override |
26 | 25 |
public Object canonicalToDisplayValue(Object canonicalValue) { |
27 |
if(canonicalValue instanceof QuantitativeData){ |
|
28 |
return MatrixUtility.getQuantitativeLabel((QuantitativeData) canonicalValue); |
|
26 |
if (canonicalValue instanceof Collection) { |
|
27 |
// Collection.toString() will add [ and ] around |
|
28 |
// the values in the Collection |
|
29 |
// So by removing the leading and ending |
|
30 |
// character, we remove the brackets |
|
31 |
String result = canonicalValue.toString(); |
|
32 |
result = result.substring(1, result.length() - 1); |
|
33 |
return result; |
|
29 | 34 |
} |
30 | 35 |
if(canonicalValue!=null){ |
31 | 36 |
return canonicalValue.toString(); |
Also available in: Unified diff
ref #8313 Adapt display converter to Collection display value