Revision 62d0d2ff
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java | ||
---|---|---|
325 | 325 |
TaxonNode node = taxonEditor.getEditorInput().getTaxonNode(); |
326 | 326 |
if (node.treeIndex()!= null){ |
327 | 327 |
if(node.treeIndex().startsWith(treeIndex)){ |
328 |
partService.hidePart(part, true);
|
|
328 |
partService.hidePart(part); |
|
329 | 329 |
} |
330 | 330 |
}else{ |
331 | 331 |
logger.debug("The taxonnode of taxon " + node.getTaxon().getTitleCache() + " uuid: " + node.getUuid() + " has no treeindex");; |
... | ... | |
334 | 334 |
} |
335 | 335 |
} |
336 | 336 |
|
337 |
public static void updateEditor(TaxonNode taxonNode, EPartService partService, MApplication application){
|
|
337 |
public static void updateEditor(TaxonNode taxonNode, TaxonNameEditorE4 editor){
|
|
338 | 338 |
String treeIndex = taxonNode.treeIndex(); |
339 |
Collection<MPart> parts = partService.getParts(); |
|
340 |
for (MPart part : parts) { |
|
341 |
Object object = part.getObject(); |
|
342 |
if(object instanceof TaxonNameEditorE4){ |
|
343 |
TaxonNameEditorE4 taxonEditor = (TaxonNameEditorE4)object; |
|
344 |
TaxonNode node = taxonEditor.getEditorInput().getTaxonNode(); |
|
345 |
if(node.treeIndex().startsWith(treeIndex)){ |
|
346 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(node.getTaxon().getUuid()); |
|
347 |
taxonEditor.init(input); |
|
348 |
} |
|
349 |
} |
|
339 |
TaxonNode node = editor.getEditorInput().getTaxonNode(); |
|
340 |
if(node.treeIndex().equals(treeIndex)){ |
|
341 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(node.getUuid()); |
|
342 |
editor.init(input); |
|
343 |
|
|
344 |
|
|
350 | 345 |
} |
351 | 346 |
} |
352 | 347 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetPublishFlagForSubtreeHandlerE4.java | ||
---|---|---|
110 | 110 |
partService, |
111 | 111 |
activePart, |
112 | 112 |
application, |
113 |
modelService, |
|
113 | 114 |
configurator); |
114 | 115 |
|
115 | 116 |
return operation; |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetSecReferenceForSubtreeHandlerE4.java | ||
---|---|---|
104 | 104 |
new SetSecundumForSubtreeOperation(getTrigger(), |
105 | 105 |
true, |
106 | 106 |
taxonNode.getUuid(), |
107 |
partService, activePart, application, |
|
107 |
partService, activePart, application, modelService,
|
|
108 | 108 |
configurator); |
109 | 109 |
|
110 | 110 |
return operation; |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/RemotingChangeAcceptedTaxonToSynonymOperation.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
24 | 24 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
25 | 25 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
26 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
27 | 26 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
28 | 27 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
29 | 28 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
... | ... | |
57 | 56 |
super(LABEL, Action.Update, source, async, partService, activePart, application); |
58 | 57 |
this.oldTaxonNodeUuids.addAll(oldTaxonNodeUuids); |
59 | 58 |
this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid; |
60 |
|
|
59 |
|
|
61 | 60 |
} |
62 |
|
|
61 |
|
|
63 | 62 |
/** |
64 | 63 |
* @param label |
65 | 64 |
*/ |
... | ... | |
74 | 73 |
this.oldTaxonNodeUuids.add(oldTaxonNodeUuid); |
75 | 74 |
this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid; |
76 | 75 |
} |
77 |
|
|
76 |
|
|
78 | 77 |
/** |
79 | 78 |
* @param label |
80 | 79 |
*/ |
... | ... | |
92 | 91 |
*/ |
93 | 92 |
@Override |
94 | 93 |
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception { |
95 |
|
|
94 |
|
|
96 | 95 |
if (this.oldTaxonNodeUuids.size() == 1){ |
97 | 96 |
updateResult = CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNodeUuids.iterator().next(), |
98 | 97 |
newAcceptedTaxonNodeUuid, |
... | ... | |
108 | 107 |
} |
109 | 108 |
updateNameEditor(); |
110 | 109 |
return updateResult; |
111 |
|
|
110 |
|
|
112 | 111 |
} |
113 |
|
|
112 |
|
|
114 | 113 |
private void updateNameEditor(){ |
115 | 114 |
if (partService != null){ |
116 | 115 |
Display.getDefault().asyncExec(new Runnable() { |
117 |
public void run() { |
|
116 |
|
|
117 |
@Override |
|
118 |
public void run() { |
|
118 | 119 |
for (MPart part : partService.getParts()){ |
119 | 120 |
Object object = part.getObject(); |
121 |
boolean setFocus = false; |
|
122 |
if (part == activePart){ |
|
123 |
setFocus = true; |
|
124 |
} |
|
120 | 125 |
if (object instanceof TaxonNameEditorE4){ |
121 | 126 |
Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes(); |
122 | 127 |
for (TaxonNode node: nodes){ |
123 | 128 |
if (node.getTaxon().getUuid().equals(newAcceptedTaxonNodeUuid)){ |
124 |
EditorUtil.updateEditor(node, partService, application);
|
|
129 |
EditorUtil.updateEditor(node, (TaxonNameEditorE4)object);
|
|
125 | 130 |
} |
126 |
|
|
131 |
|
|
127 | 132 |
} |
128 | 133 |
} |
129 |
}
|
|
134 |
} |
|
130 | 135 |
} |
131 | 136 |
}); |
132 | 137 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetPublishForSubtreeOperation.java | ||
---|---|---|
20 | 20 |
import org.eclipse.core.runtime.jobs.Job; |
21 | 21 |
import org.eclipse.e4.ui.model.application.MApplication; |
22 | 22 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
23 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
23 | 24 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
24 | 25 |
import org.eclipse.swt.widgets.Display; |
25 | 26 |
import org.eclipse.ui.progress.IProgressConstants; |
... | ... | |
52 | 53 |
EPartService partService, |
53 | 54 |
MPart activePart, |
54 | 55 |
MApplication application, |
56 |
EModelService modelService, |
|
55 | 57 |
PublishForSubtreeConfigurator config) { |
56 |
super(source, async, taxonNodeUuid, partService, activePart, application, config, LABEL); |
|
58 |
super(source, async, taxonNodeUuid, partService, activePart, application, modelService, config, LABEL);
|
|
57 | 59 |
|
58 | 60 |
} |
59 | 61 |
@Override |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java | ||
---|---|---|
22 | 22 |
import org.eclipse.e4.ui.di.UISynchronize; |
23 | 23 |
import org.eclipse.e4.ui.model.application.MApplication; |
24 | 24 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
25 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
25 | 26 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
26 | 27 |
import org.eclipse.swt.widgets.Display; |
27 | 28 |
import org.eclipse.ui.progress.IProgressConstants; |
... | ... | |
52 | 53 |
|
53 | 54 |
|
54 | 55 |
public SetSecundumForSubtreeOperation(Object source, boolean async, UUID taxonNodeUuid, EPartService partService, |
55 |
MPart activePart, MApplication application, SecundumForSubtreeConfigurator config) { |
|
56 |
super(source, async, taxonNodeUuid, partService, activePart, application, config, LABEL); |
|
56 |
MPart activePart, MApplication application, EModelService modelService, SecundumForSubtreeConfigurator config) {
|
|
57 |
super(source, async, taxonNodeUuid, partService, activePart, application, modelService, config, LABEL);
|
|
57 | 58 |
|
58 | 59 |
} |
59 | 60 |
|
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.navigation.navigator.operation; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
3 | 5 |
import java.util.Set; |
4 | 6 |
import java.util.UUID; |
5 | 7 |
|
6 |
import org.eclipse.core.runtime.IAdaptable; |
|
7 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
8 | 8 |
import org.eclipse.e4.ui.model.application.MApplication; |
9 | 9 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
10 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
10 | 11 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
11 | 12 |
import org.eclipse.swt.widgets.Display; |
12 | 13 |
|
13 |
import eu.etaxonomy.cdm.api.application.CdmApplicationException; |
|
14 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
15 | 14 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
16 | 15 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
17 | 16 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
18 | 17 |
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase; |
19 |
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator; |
|
20 | 18 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
21 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
22 | 20 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
... | ... | |
24 | 22 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
25 | 23 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
26 | 24 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
27 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
|
28 | 25 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
26 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
29 | 27 |
|
30 | 28 |
public abstract class UpdateSubtreeOperation extends RemotingCdmUpdateOperation { |
31 |
|
|
29 |
|
|
32 | 30 |
ForSubtreeConfiguratorBase config; |
33 |
|
|
31 |
|
|
34 | 32 |
UUID parentUuid; |
35 |
|
|
36 |
TaxonNode subtreeNode;
|
|
33 |
|
|
34 |
TaxonNode subtreeNode; |
|
37 | 35 |
ITaxonNodeService taxonNodeService; |
38 |
|
|
36 |
protected EModelService modelService = null; |
|
37 |
|
|
39 | 38 |
public UpdateSubtreeOperation(Object source, |
40 | 39 |
boolean async, |
41 | 40 |
UUID taxonNodeUuid, |
42 | 41 |
EPartService partService, |
43 | 42 |
MPart activePart, |
44 | 43 |
MApplication application, |
44 |
EModelService modelService, |
|
45 | 45 |
ForSubtreeConfiguratorBase config, |
46 | 46 |
String label) { |
47 | 47 |
super(label, Action.Update, source, async, partService, activePart, application); |
48 | 48 |
parentUuid = taxonNodeUuid; |
49 | 49 |
this.config = config; |
50 | 50 |
this.updateResult = new UpdateResult(); |
51 |
|
|
52 |
try { |
|
53 |
taxonNodeService = CdmApplicationState.getService(ITaxonNodeService.class); |
|
54 |
} catch (CdmApplicationException e) { |
|
55 |
// TODO Auto-generated catch block |
|
56 |
e.printStackTrace(); |
|
57 |
} |
|
51 |
this.modelService = modelService; |
|
52 |
taxonNodeService = CdmStore.getService(ITaxonNodeService.class); |
|
58 | 53 |
subtreeNode = taxonNodeService.load(config.getSubtreeUuid()); |
59 | 54 |
} |
60 | 55 |
public void updateNameEditors(){ |
61 |
for (CdmBase object: updateResult.getUpdatedObjects()){ |
|
62 |
Taxon taxon = null; |
|
63 |
TaxonNode node = null; |
|
64 |
if (object instanceof Taxon){ |
|
65 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
66 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
67 |
|
|
68 |
}else if (object instanceof Synonym){ |
|
69 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
70 |
taxon = syn.getAcceptedTaxon(); |
|
71 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
72 |
} |
|
73 |
|
|
74 |
Display.getDefault().asyncExec(new Runnable() { |
|
75 |
public void run() { |
|
76 |
for (MPart part : partService.getParts()){ |
|
77 |
Object object = part.getObject(); |
|
78 |
if (object instanceof TaxonNameEditorE4){ |
|
79 |
Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes(); |
|
80 |
for (TaxonNode node: nodes){ |
|
81 |
if (node.treeIndex().startsWith(subtreeNode.treeIndex())){ |
|
82 |
EditorUtil.updateEditor(node, partService, application); |
|
83 |
} |
|
84 |
|
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
}); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
56 |
List<TaxonNode> nodesToUpdate = new ArrayList(); |
|
57 |
for (CdmBase object: updateResult.getUpdatedObjects()){ |
|
58 |
Taxon taxon = null; |
|
59 |
TaxonNode node = null; |
|
60 |
if (object instanceof Taxon){ |
|
61 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
62 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
63 |
|
|
64 |
}else if (object instanceof Synonym){ |
|
65 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
66 |
taxon = syn.getAcceptedTaxon(); |
|
67 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
68 |
} |
|
69 |
nodesToUpdate.add(node); |
|
70 |
} |
|
71 |
|
|
72 |
Display.getDefault().asyncExec(new Runnable() { |
|
73 |
@Override |
|
74 |
public void run() { |
|
75 |
|
|
76 |
for (MPart part : partService.getParts()){ |
|
77 |
Object object = part.getObject(); |
|
78 |
boolean setFocus = false; |
|
79 |
if (part == activePart){ |
|
80 |
setFocus = true; |
|
81 |
} |
|
82 |
if (object instanceof TaxonNameEditorE4){ |
|
83 |
Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes(); |
|
84 |
for (TaxonNode node: nodes){ |
|
85 |
if (nodesToUpdate.contains(node)){ |
|
86 |
// EditorUtil.closeObsoleteEditor(node, partService); |
|
87 |
EditorUtil.openTaxonNodeE4(node.getUuid(), modelService, partService, application); |
|
88 |
} |
|
89 |
|
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
94 |
}); |
|
95 |
|
|
96 |
} |
|
97 |
|
|
93 | 98 |
} |
Also available in: Unified diff
ref #7065: instead of creating new taxoneditorInput reopen the name editor