Revision cb531fce
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.workingSet.matrix; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 | 11 |
import java.util.Date; |
13 |
import java.util.HashMap; |
|
14 |
import java.util.List; |
|
15 |
import java.util.Map; |
|
16 | 12 |
|
17 | 13 |
import javax.annotation.PostConstruct; |
18 | 14 |
|
... | ... | |
45 | 41 |
|
46 | 42 |
@PostConstruct |
47 | 43 |
public void create(Composite parent) { |
48 |
List<Person> people = new ArrayList<>(); |
|
49 |
people.add(new Person(0, "Thenning", new Date(2015, 11, 11))); |
|
50 |
people.add(new Person(1, "Nkilian", new Date(1991, 10, 1))); |
|
51 |
people.add(new Person(2, "T Borsch", new Date(1954, 3, 9))); |
|
52 |
|
|
53 |
// mapping from property to label, needed for column header labels |
|
54 |
Map<String, String> propertyToLabelMap = new HashMap<String, String>(); |
|
55 |
propertyToLabelMap.put("id", "ID"); |
|
56 |
propertyToLabelMap.put("name", "Full Name"); |
|
57 |
propertyToLabelMap.put("birthDate", "Birthday"); |
|
58 |
|
|
59 | 44 |
parent.setLayout(new GridLayout()); |
60 | 45 |
|
61 | 46 |
// create the data provider |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/DataSource.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.cdm.model.description.State; |
21 | 21 |
import eu.etaxonomy.cdm.model.description.WorkingSet; |
22 | 22 |
import eu.etaxonomy.cdm.model.name.Rank; |
23 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
24 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
23 | 25 |
|
24 | 26 |
/** |
25 | 27 |
* @author pplitzner |
... | ... | |
46 | 48 |
|
47 | 49 |
public static List<SpecimenDescription> getDescriptions(){ |
48 | 50 |
List<SpecimenDescription> descriptions = new ArrayList<>(); |
49 |
descriptions.add(createDescription(0.3f, 2.4f, "blue")); |
|
50 |
descriptions.add(createDescription(1.6f, 6.4f, "red")); |
|
51 |
|
|
52 |
SpecimenDescription description = createDescription(0.3f, 2.4f, "blue"); |
|
53 |
DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
54 |
derivedUnit.setAccessionNumber("B 10 35489"); |
|
55 |
description.setDescribedSpecimenOrObservation(derivedUnit); |
|
56 |
|
|
57 |
SpecimenDescription description2 = createDescription(1.6f, 6.4f, "red"); |
|
58 |
DerivedUnit derivedUnit2 = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
59 |
derivedUnit2.setAccessionNumber("B 10 44556"); |
|
60 |
description2.setDescribedSpecimenOrObservation(derivedUnit2); |
|
61 |
|
|
62 |
descriptions.add(description); |
|
63 |
descriptions.add(description2); |
|
51 | 64 |
return descriptions; |
52 | 65 |
} |
53 | 66 |
|
... | ... | |
69 | 82 |
|
70 | 83 |
CategoricalData color = CategoricalData.NewInstance(LEAF_COLOR_FEATURE); |
71 | 84 |
color.addStateData(State.NewInstance(colorLabel, colorLabel, colorLabel)); |
85 |
desc.addElement(color); |
|
72 | 86 |
|
73 | 87 |
|
74 | 88 |
return desc; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/SpecimenColumnPropertyAccessor.java | ||
---|---|---|
16 | 16 |
import org.apache.commons.collections4.map.LinkedMap; |
17 | 17 |
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor; |
18 | 18 |
|
19 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
19 | 20 |
import eu.etaxonomy.cdm.model.description.Feature; |
20 | 21 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
21 | 22 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
22 | 23 |
import eu.etaxonomy.cdm.model.description.WorkingSet; |
24 |
import eu.etaxonomy.taxeditor.model.DescriptionHelper; |
|
23 | 25 |
|
24 | 26 |
/** |
25 | 27 |
* @author pplitzner |
... | ... | |
52 | 54 |
*/ |
53 | 55 |
@Override |
54 | 56 |
public Object getDataValue(SpecimenDescription rowObject, int columnIndex) { |
55 |
return features.get(columnIndex); |
|
57 |
Feature feature = features.get(columnIndex); |
|
58 |
Set<DescriptionElementBase> elements = rowObject.getElements(); |
|
59 |
for (DescriptionElementBase descriptionElementBase : elements) { |
|
60 |
if(descriptionElementBase.getFeature().equals(feature)){ |
|
61 |
return DescriptionHelper.getLabel(descriptionElementBase); |
|
62 |
} |
|
63 |
} |
|
64 |
return null; |
|
56 | 65 |
} |
57 | 66 |
|
58 | 67 |
/** |
Also available in: Unified diff
ref #7095 Enhance label in matrix editor