Revision 070a27a4
Added by Katja Luther almost 3 years ago
eu.etaxonomy.taxeditor.store/fragment.e4xmi | ||
---|---|---|
146 | 146 |
<elements xsi:type="commands:Command" xmi:id="_8aaicD4fEeuM4JU-Ch98ZA" elementId="eu.etaxonomy.taxeditor.store.command.OpenTermTreeEditor" commandName="Open Term Tree Editor"> |
147 | 147 |
<parameters xmi:id="_8aaicT4fEeuM4JU-Ch98ZA" elementId="eu.etaxonomy.taxeditor.store.commandparameter.termType" name="TermType" optional="false"/> |
148 | 148 |
</elements> |
149 |
<elements xsi:type="commands:Command" xmi:id="_MkieEMKuEeufc9n3VJNAaA" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.createFeatureTree_flat" commandName="%command.commandname.flat_tree"/> |
|
150 |
<elements xsi:type="commands:Command" xmi:id="_ukIJAMKuEeufc9n3VJNAaA" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.createFeatureTree_ordered" commandName="%command.commandname.ordered_tree"/> |
|
149 | 151 |
</fragments> |
150 | 152 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="xpath:/"> |
151 | 153 |
<elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.termtree.e4.handler.RemoveTermHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/> |
eu.etaxonomy.taxeditor.store/plugin.xml | ||
---|---|---|
409 | 409 |
viewerName="%viewCommandMapping.viewerName.TAXON_NODE_WIZARD"> |
410 | 410 |
</viewCommandMapping> |
411 | 411 |
<viewCommandMapping |
412 |
commandId="eu.etaxonomy.taxeditor.store.openDefinedTermEditor"
|
|
413 |
selection="eu.etaxonomy.cdm.persistence.dto.TermNodeDto"
|
|
412 |
commandId="eu.etaxonomy.taxeditor.store.command.OpenDefinedTermEditor"
|
|
413 |
selection="eu.etaxonomy.cdm.model.term.DefinedTermBase"
|
|
414 | 414 |
viewerName="Vocabulary"> |
415 | 415 |
</viewCommandMapping> |
416 | 416 |
</extension> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermEditorE4.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.definedterm.e4; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
11 | 12 |
import java.util.Collection; |
12 | 13 |
import java.util.HashSet; |
14 |
import java.util.List; |
|
13 | 15 |
import java.util.Set; |
14 | 16 |
|
15 | 17 |
import javax.annotation.PostConstruct; |
... | ... | |
36 | 38 |
import org.eclipse.swt.layout.FillLayout; |
37 | 39 |
import org.eclipse.swt.widgets.Composite; |
38 | 40 |
import org.eclipse.swt.widgets.Tree; |
41 |
import org.eclipse.swt.widgets.TreeItem; |
|
39 | 42 |
import org.eclipse.ui.IMemento; |
40 | 43 |
|
41 | 44 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
... | ... | |
183 | 186 |
this.input = input; |
184 | 187 |
|
185 | 188 |
viewer.setInput(input.getVocabularies()); |
189 |
for (TermVocabularyDto voc:input.getVocabularies()){ |
|
190 |
for (TermDto dto: this.contentProvider.getChildTerms(voc)){ |
|
191 |
voc.addTerm(dto);; |
|
192 |
} |
|
193 |
} |
|
186 | 194 |
thisPart.setLabel(label); |
187 | 195 |
} |
188 | 196 |
|
... | ... | |
190 | 198 |
@Persist |
191 | 199 |
public void save(IProgressMonitor monitor) { |
192 | 200 |
getConversationHolder().commit(); |
201 |
List<DefinedTermBase> terms = new ArrayList<>(); |
|
202 |
List<TermVocabulary> vocs = new ArrayList<>(); |
|
193 | 203 |
for(TermBase term:changedTerms){ |
194 | 204 |
if(term.isInstanceOf(DefinedTermBase.class)){ |
195 | 205 |
DefinedTermBase<?> definedTermBase = (DefinedTermBase<?>) term; |
196 |
CdmStore.getService(ITermService.class).merge(definedTermBase); |
|
206 |
terms.add(definedTermBase); |
|
207 |
|
|
197 | 208 |
} |
198 | 209 |
else if(term.isInstanceOf(TermVocabulary.class)){ |
199 | 210 |
TermVocabulary<?> voc = (TermVocabulary<?>) term; |
200 |
CdmStore.getService(IVocabularyService.class).merge(voc);
|
|
211 |
vocs.add(voc);
|
|
201 | 212 |
} |
202 | 213 |
} |
214 |
if (!terms.isEmpty()){ |
|
215 |
CdmStore.getService(ITermService.class).merge(terms, true); |
|
216 |
} |
|
217 |
if (!vocs.isEmpty()){ |
|
218 |
CdmStore.getService(IVocabularyService.class).merge(vocs, true); |
|
219 |
} |
|
203 | 220 |
setDirty(false); |
204 | 221 |
input.initialiseVocabularies(); |
205 | 222 |
changedTerms.clear(); |
... | ... | |
319 | 336 |
@Override |
320 | 337 |
public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) { |
321 | 338 |
} |
339 |
|
|
340 |
public void setSelection(TermDto toBeSelected){ |
|
341 |
TreeItem[] children = viewer.getTree().getItems(); |
|
342 |
for (TreeItem con: children){ |
|
343 |
if (con.getData() == toBeSelected){ |
|
344 |
this.viewer.setSelection(new StructuredSelection(toBeSelected)); |
|
345 |
return; |
|
346 |
}else { |
|
347 |
if (con instanceof TreeItem){ |
|
348 |
TreeItem[] items = con.getItems(); |
|
349 |
for (TreeItem item:items){ |
|
350 |
if(item.getData() != null && item.getData() instanceof TermDto ){ |
|
351 |
if(((TermDto)item.getData()).getUuid().equals(toBeSelected.getUuid())){ |
|
352 |
this.viewer.setSelection(new StructuredSelection(toBeSelected)); |
|
353 |
return; |
|
354 |
} |
|
355 |
} |
|
356 |
} |
|
357 |
} |
|
358 |
} |
|
359 |
} |
|
360 |
|
|
361 |
} |
|
322 | 362 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/handler/OpenDefinedTermEditorHandlerE4.java | ||
---|---|---|
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.editor.definedterm.e4.handler; |
10 |
import java.util.ArrayList; |
|
11 |
import java.util.HashSet; |
|
10 | 12 |
import java.util.List; |
13 |
import java.util.Set; |
|
14 |
import java.util.UUID; |
|
11 | 15 |
import java.util.stream.Collectors; |
12 | 16 |
|
13 | 17 |
import org.eclipse.e4.core.di.annotations.Execute; |
... | ... | |
20 | 24 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
21 | 25 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
22 | 26 |
|
27 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
28 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
29 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
30 |
import eu.etaxonomy.cdm.model.description.MeasurementUnit; |
|
31 |
import eu.etaxonomy.cdm.model.description.StatisticalMeasure; |
|
32 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
23 | 33 |
import eu.etaxonomy.cdm.model.term.TermType; |
34 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
|
35 |
import eu.etaxonomy.cdm.persistence.dto.FeatureDto; |
|
36 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
37 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
|
38 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
24 | 39 |
import eu.etaxonomy.taxeditor.editor.definedterm.e4.DefinedTermEditorE4; |
25 | 40 |
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput; |
41 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
26 | 42 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
27 | 43 |
|
28 | 44 |
|
... | ... | |
39 | 55 |
List<MParameter> parameters = menuItem.getParameters(); |
40 | 56 |
TermType termType = null; |
41 | 57 |
for (MParameter param: parameters){ |
42 |
termType = TermType.getByKey(param.getValue()); |
|
58 |
try{ |
|
59 |
termType = TermType.getByKey(param.getValue()); |
|
60 |
}catch(Exception e){ |
|
61 |
|
|
62 |
} |
|
43 | 63 |
} |
44 | 64 |
|
45 |
// UUID termTypeUuid = (UUID) menuItem.getTransientData().get(commandId+".termTypeUuid"); |
|
65 |
|
|
46 | 66 |
// |
47 | 67 |
// TermType termType = TermType.getByUuid(termTypeUuid); |
48 | 68 |
if(termType != null){ |
... | ... | |
67 | 87 |
DefinedTermEditorE4 termEditor = (DefinedTermEditorE4) part.getObject(); |
68 | 88 |
termEditor.init(termEditorInput, menuItem.getLocalizedLabel()); |
69 | 89 |
} |
90 |
}else{ |
|
91 |
List<UuidAndTitleCache<? extends ICdmBase>> termUuidAndTitleCaches = (List<UuidAndTitleCache<? extends ICdmBase>> ) menuItem.getTransientData().get(commandId+".uuid"); |
|
92 |
Set<TermType> termTypes = new HashSet<>(); |
|
93 |
Set<UUID> termUuids = new HashSet<>(); |
|
94 |
for (UuidAndTitleCache<?> uuidAndTitleCache: termUuidAndTitleCaches){ |
|
95 |
termUuids.add(uuidAndTitleCache.getUuid()); |
|
96 |
} |
|
97 |
List<DefinedTermBase> terms = CdmStore.getService(ITermService.class).load(new ArrayList<>(termUuids), null); |
|
98 |
|
|
99 |
for (DefinedTermBase term: terms){ |
|
100 |
// TermType type = termType; |
|
101 |
TermEditorInput termEditorInput = new TermEditorInput(term.getTermType()); |
|
102 |
List<MPart> alreadyOpenedEditors = partService.getParts().stream() |
|
103 |
.filter(part->part.getObject()!=null && part.getObject() instanceof DefinedTermEditorE4) |
|
104 |
.filter(part->((DefinedTermEditorE4)part.getObject()).getDefinedTermEditorInput().getTermType().equals(term.getTermType())) |
|
105 |
.collect(Collectors.toList()); |
|
106 |
if(!alreadyOpenedEditors.isEmpty()){ |
|
107 |
//there should never be more than one already opened editor |
|
108 |
//so we just open the first |
|
109 |
MPart openPart = alreadyOpenedEditors.iterator().next(); |
|
110 |
partService.activate(openPart); |
|
111 |
|
|
112 |
|
|
113 |
} |
|
114 |
else{ |
|
115 |
MPart part = partService.createPart(eu.etaxonomy.taxeditor.store.AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_DEFINEDTERM); |
|
116 |
MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService); |
|
117 |
if(editorAreaPartStack!=null){ |
|
118 |
editorAreaPartStack.getChildren().add(part); |
|
119 |
} |
|
120 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
121 |
DefinedTermEditorE4 termEditor = (DefinedTermEditorE4) part.getObject(); |
|
122 |
termEditor.init(termEditorInput, menuItem.getLocalizedLabel()); |
|
123 |
TermDto dto = null; |
|
124 |
FeatureDto featureDto = null; |
|
125 |
if (term instanceof Feature){ |
|
126 |
Feature feature = (Feature)term; |
|
127 |
Set<TermVocabularyDto> supportedCategoricalEnumerations = new HashSet<>(); |
|
128 |
if (feature.getSupportedCategoricalEnumerations()!= null && !feature.getSupportedCategoricalEnumerations().isEmpty()){ |
|
129 |
for (TermVocabulary voc: feature.getSupportedCategoricalEnumerations()){ |
|
130 |
supportedCategoricalEnumerations.add(TermVocabularyDto.fromVocabulary(voc)); |
|
131 |
} |
|
132 |
} |
|
133 |
Set<TermVocabularyDto> recommendedModifierEnumerations = new HashSet<>(); |
|
134 |
if (feature.getRecommendedModifierEnumeration()!= null && !feature.getRecommendedModifierEnumeration().isEmpty()){ |
|
135 |
for (TermVocabulary voc: feature.getRecommendedModifierEnumeration()){ |
|
136 |
recommendedModifierEnumerations.add(TermVocabularyDto.fromVocabulary(voc)); |
|
137 |
} |
|
138 |
} |
|
139 |
Set<TermDto> recommendedMeasurementUnits = new HashSet<>(); |
|
140 |
if (feature.getRecommendedMeasurementUnits()!= null && !feature.getRecommendedMeasurementUnits().isEmpty()){ |
|
141 |
for (MeasurementUnit unit: feature.getRecommendedMeasurementUnits()){ |
|
142 |
recommendedMeasurementUnits.add(TermDto.fromTerm(unit)); |
|
143 |
} |
|
144 |
} |
|
145 |
Set<TermDto> recommendedStatisticalMeasures = new HashSet<>(); |
|
146 |
if (feature.getRecommendedStatisticalMeasures()!= null && !feature.getRecommendedStatisticalMeasures().isEmpty()){ |
|
147 |
for (StatisticalMeasure measures: feature.getRecommendedStatisticalMeasures()){ |
|
148 |
recommendedStatisticalMeasures.add(TermDto.fromTerm(measures)); |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
|
|
153 |
featureDto = new FeatureDto(term.getUuid(), term.getRepresentations(), term.getPartOf() != null? term.getPartOf().getUuid(): null, term.getKindOf() != null? term.getKindOf().getUuid(): null, |
|
154 |
term.getVocabulary()!= null? term.getVocabulary().getUuid(): null, null, term.getIdInVocabulary(), term.getVocabulary()!= null?term.getVocabulary().getRepresentations(): null, feature.isAvailableForTaxon(), |
|
155 |
feature.isAvailableForTaxonName(),feature.isAvailableForOccurrence(), feature.getTitleCache(), feature.isSupportsCategoricalData(), feature.isSupportsQuantitativeData(), |
|
156 |
supportedCategoricalEnumerations, recommendedModifierEnumerations, recommendedMeasurementUnits, recommendedStatisticalMeasures); |
|
157 |
|
|
158 |
}else{ |
|
159 |
dto = TermDto.fromTerm(term); |
|
160 |
} |
|
161 |
termEditor.getViewer().expandToLevel(dto, 1); |
|
162 |
if (featureDto != null){ |
|
163 |
termEditor.setSelection(featureDto); |
|
164 |
}else{ |
|
165 |
termEditor.setSelection(dto); |
|
166 |
} |
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
} |
|
171 |
} |
|
172 |
|
|
70 | 173 |
} |
71 | 174 |
} |
72 | 175 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/input/TermEditorInput.java | ||
---|---|---|
68 | 68 |
} |
69 | 69 |
List<TermVocabularyDto> vocs = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(termType, false); |
70 | 70 |
vocabularies.addAll(vocs); |
71 |
|
|
71 | 72 |
} |
72 | 73 |
|
73 | 74 |
public Set<TermVocabularyDto> getVocabularies() { |
Also available in: Unified diff
ref #9337: open in... vocabulary