Revision e598b1c7
Added by Katja Luther almost 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/edit/DistributionEditingSupport.java | ||
---|---|---|
26 | 26 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
27 | 27 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
28 | 28 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor; |
29 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistLabelProvider;
|
|
29 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
|
30 | 30 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
31 | 31 |
|
32 | 32 |
public final class DistributionEditingSupport extends EditingSupport { |
... | ... | |
71 | 71 |
Taxon taxon = (Taxon) element; |
72 | 72 |
Distribution distributionForColumn = getDistributionForColumn(taxon); |
73 | 73 |
if (distributionForColumn != null) { |
74 |
distributionForColumn.getStatus().getTitleCache(); |
|
74 |
return distributionForColumn.getStatus().getTitleCache();
|
|
75 | 75 |
} |
76 | 76 |
// return PresenceAbsenceTerms |
77 | 77 |
} |
... | ... | |
91 | 91 |
createDistributionForColumn(taxon, occurenceStatus); |
92 | 92 |
} |
93 | 93 |
// viewer.update(distribution, null); |
94 |
viewer.update(element, null); |
|
95 |
viewer.refresh(); |
|
96 |
editor.setDirty(true); |
|
94 |
// viewer.update(element, null);
|
|
95 |
// viewer.refresh();
|
|
96 |
// editor.setDirty(true);
|
|
97 | 97 |
editor.changed(element); |
98 | 98 |
viewer.refresh(); |
99 | 99 |
} |
... | ... | |
115 | 115 |
for (DescriptionElementBase deb : td.getElements()) { |
116 | 116 |
if (deb instanceof Distribution) { |
117 | 117 |
Distribution distribution = (Distribution) deb; |
118 |
if (column.getText().equalsIgnoreCase(distribution.getArea().getTitleCache())) { |
|
119 |
return distribution; |
|
118 |
if (distribution.getArea() != null){ |
|
119 |
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
120 |
if (column.getText().equalsIgnoreCase(distribution.getArea().getIdInVocabulary())) { |
|
121 |
return distribution; |
|
122 |
} |
|
123 |
}else{ |
|
124 |
if (column.getText().equalsIgnoreCase(distribution.getArea().getTitleCache())) { |
|
125 |
return distribution; |
|
126 |
} |
|
127 |
} |
|
120 | 128 |
} |
121 | 129 |
} |
122 | 130 |
} |
... | ... | |
127 | 135 |
private void createDistributionForColumn(Taxon taxon, PresenceAbsenceTerm occurenceStatus) { |
128 | 136 |
TableColumn column = viewer.getTable().getColumn(columnIndex); |
129 | 137 |
|
130 |
ChecklistLabelProvider labelProvider = new ChecklistLabelProvider(); |
|
131 |
List<DefinedTermBase<?>> namedAreas = labelProvider.getNamedAreas(); |
|
132 |
SortedSet<DefinedTermBase<?>> terms = (SortedSet<DefinedTermBase<?>>) labelProvider.getTermsOrderedByLabels( |
|
133 |
namedAreas, CdmStore.getDefaultLanguage()); |
|
138 |
SortedSet<DefinedTermBase> namedAreas = this.editor.getLabelProvider().getNamedAreas(); |
|
134 | 139 |
|
135 |
if (terms != null) { |
|
136 |
for (DefinedTermBase term : terms) { |
|
137 |
if (column.getText().equalsIgnoreCase(term.getTitleCache())) { |
|
140 |
|
|
141 |
if (namedAreas != null) { |
|
142 |
for (DefinedTermBase term : namedAreas) { |
|
143 |
boolean sameArea = true; |
|
144 |
if (!PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
145 |
sameArea = column.getText().equalsIgnoreCase(term.getTitleCache()); |
|
146 |
} else{ |
|
147 |
sameArea = column.getText().equalsIgnoreCase(term.getIdInVocabulary()); |
|
148 |
} |
|
149 |
if (sameArea) { |
|
138 | 150 |
NamedArea area = (NamedArea) term; |
139 | 151 |
Distribution distribution = Distribution.NewInstance(area, occurenceStatus); |
140 | 152 |
Set<TaxonDescription> descriptions = taxon.getDescriptions(); |
141 |
if (descriptions != null) {
|
|
153 |
if (!descriptions.isEmpty()) {
|
|
142 | 154 |
for (TaxonDescription desc : descriptions) { |
143 | 155 |
// add to first taxon description |
144 | 156 |
desc.addElement(distribution); |
... | ... | |
147 | 159 |
} else {// there are no TaxonDescription yet. |
148 | 160 |
TaxonDescription td = TaxonDescription.NewInstance(taxon); |
149 | 161 |
td.addElement(distribution); |
162 |
break; |
|
150 | 163 |
} |
151 | 164 |
} |
152 | 165 |
} |
Also available in: Unified diff
changes to fix the checklist editor