Revision 942a8769
Added by Katja Luther almost 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionColumnAccessor.java | ||
---|---|---|
24 | 24 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
25 | 25 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
26 | 26 |
import eu.etaxonomy.cdm.model.description.Distribution; |
27 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
28 | 27 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
29 | 28 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
30 | 29 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
... | ... | |
117 | 116 |
*/ |
118 | 117 |
@Override |
119 | 118 |
public void setDataValue(TaxonDistributionDTO taxonWrapper, int columnIndex, Object newValue) { |
120 |
if (newValue instanceof PresenceAbsenceTerm){
|
|
119 |
if (newValue instanceof StatusHelper){
|
|
121 | 120 |
NamedArea area =editor.getAreaToColumnIndexMap().get(columnIndex); |
122 | 121 |
Map<NamedArea, Set<DescriptionElementBase>> distributionMap = editor.taxonDistributionMap.get(taxonWrapper.getTaxonUuid()); |
123 | 122 |
if (distributionMap == null){ |
... | ... | |
129 | 128 |
if (distributions != null && !distributions.isEmpty()){ |
130 | 129 |
DescriptionElementBase desc = distributions.iterator().next(); |
131 | 130 |
if (desc instanceof Distribution){ |
132 |
if (((PresenceAbsenceTerm)newValue).getId() == 0){
|
|
131 |
if (((StatusHelper)newValue).term.getId() == 0){
|
|
133 | 132 |
desc.getInDescription().removeElement(desc); |
134 | 133 |
distributions.remove(desc); |
135 | 134 |
}else { |
136 |
((Distribution)desc).setStatus((PresenceAbsenceTerm)newValue);
|
|
135 |
((Distribution)desc).setStatus(((StatusHelper)newValue).term);
|
|
137 | 136 |
} |
138 | 137 |
} |
139 | 138 |
}else{ |
140 |
if (((PresenceAbsenceTerm)newValue).getId() == 0){
|
|
139 |
if (((StatusHelper)newValue).term.getId() == 0){
|
|
141 | 140 |
return; |
142 | 141 |
} |
143 | 142 |
if (distributions == null){ |
144 | 143 |
distributions = new HashSet(); |
145 | 144 |
distributionMap.put(area, distributions); |
146 | 145 |
} |
147 |
dist = Distribution.NewInstance(area, (PresenceAbsenceTerm)newValue);
|
|
146 |
dist = Distribution.NewInstance(area, ((StatusHelper)newValue).term);
|
|
148 | 147 |
Set<TaxonDescription> descs = taxonWrapper.getDescriptionsWrapper().getDescriptions(); |
149 | 148 |
TaxonDescription desc; |
150 | 149 |
if (descs.size() >= 1){ |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/StatusComboBoxDataProvider.java | ||
---|---|---|
69 | 69 |
|
70 | 70 |
|
71 | 71 |
public static List<?> getValues(CdmPreference pref){ |
72 |
List<DefinedTermBase> inputAll = new ArrayList<>();
|
|
72 |
List<StatusHelper> inputAll = new ArrayList<>();
|
|
73 | 73 |
PresenceAbsenceTerm noneTerm = PresenceAbsenceTerm.NewInstance(); |
74 | 74 |
noneTerm.setTitleCache(" - ", true); |
75 | 75 |
noneTerm.addRepresentation(Representation.NewInstance(" - ", " ", " ", CdmStore.getDefaultLanguage())); |
76 |
inputAll.add(noneTerm);
|
|
76 |
inputAll.add(new StatusHelper(noneTerm));
|
|
77 | 77 |
String statusString = pref.getValue(); |
78 | 78 |
|
79 | 79 |
List<PresenceAbsenceTerm> inputList; |
... | ... | |
93 | 93 |
Comparator<DefinedTermBase> comp = new OrderedTermComparator<>(); |
94 | 94 |
Collections.sort(inputList, comp); |
95 | 95 |
Collections.sort(inputList, Collections.reverseOrder()); |
96 |
|
|
97 |
inputAll.addAll(1, inputList); |
|
96 |
int index = 1; |
|
97 |
for (PresenceAbsenceTerm term: inputList){ |
|
98 |
inputAll.add(index, new StatusHelper(term)); |
|
99 |
} |
|
100 |
// inputAll.addAll(1, inputList); |
|
98 | 101 |
return inputAll; |
99 | 102 |
} |
100 | 103 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/StatusHelper.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.editor.view.checklist.e4; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
12 |
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum; |
|
13 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author k.luther |
|
17 |
* @since 27.05.2019 |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class StatusHelper { |
|
21 |
PresenceAbsenceTerm term; |
|
22 |
String label; |
|
23 |
|
|
24 |
public StatusHelper(PresenceAbsenceTerm term){ |
|
25 |
this.term = term; |
|
26 |
TermDisplayEnum display = TermDisplayEnum.valueOf(PreferencesUtil.displayStatusInChecklistEditor()); |
|
27 |
if (display.equals(TermDisplayEnum.IdInVocabulary) && term.getIdInVocabulary() != null){ |
|
28 |
label = "[" + term.getIdInVocabulary()+ "] " + term.getTitleCache(); |
|
29 |
}else if (display.equals(TermDisplayEnum.Symbol1) && term.getSymbol() != null){ |
|
30 |
label = "[" + term.getSymbol()+ "] " + term.getTitleCache(); |
|
31 |
} else if (display.equals(TermDisplayEnum.Symbol2) && term.getSymbol2() != null){ |
|
32 |
label = "[" + term.getSymbol2()+ "] " + term.getTitleCache(); |
|
33 |
} else{ |
|
34 |
label = term.getTitleCache(); |
|
35 |
} |
|
36 |
} |
|
37 |
@Override |
|
38 |
public String toString(){ |
|
39 |
return label; |
|
40 |
} |
|
41 |
|
|
42 |
} |
Also available in: Unified diff
ref #8047: show symbol and label in drop down of distribution editor