Revision 86f28971
Added by Katja Luther about 5 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java | ||
---|---|---|
8 | 8 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
9 | 9 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
10 | 10 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
11 |
import org.eclipse.swt.widgets.Display; |
|
12 | 11 |
|
13 | 12 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
14 | 13 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
... | ... | |
20 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
21 | 20 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
22 | 21 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
22 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
23 | 23 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
24 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
25 |
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput; |
|
26 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
27 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
24 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
|
25 |
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; |
|
28 | 26 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
29 | 27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
30 | 28 |
|
... | ... | |
58 | 56 |
subtreeNode = CdmStore.getService(ITaxonNodeService.class).load(config.getSubtreeUuid()); |
59 | 57 |
} |
60 | 58 |
public void updateNameEditors(){ |
61 |
List<Taxon> taxaToUpdate = new ArrayList(); |
|
59 |
|
|
60 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, true); |
|
61 |
|
|
62 |
List<TaxonBase> taxaToUpdate = new ArrayList(); |
|
62 | 63 |
for (CdmBase object: updateResult.getUpdatedObjects()){ |
63 |
Taxon taxon = null;
|
|
64 |
TaxonBase taxonBase = null;
|
|
64 | 65 |
TaxonNode node = null; |
65 | 66 |
if (object instanceof Taxon){ |
66 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
67 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
67 |
taxonBase = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
68 |
|
|
69 |
}else { |
|
70 |
taxonBase = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
68 | 71 |
|
69 |
}else if (object instanceof Synonym){ |
|
70 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
71 |
taxon = syn.getAcceptedTaxon(); |
|
72 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
73 | 72 |
} |
74 |
taxaToUpdate.add(taxon); |
|
73 |
taxaToUpdate.add(taxonBase); |
|
74 |
|
|
75 | 75 |
} |
76 | 76 |
|
77 |
Display.getDefault().asyncExec(new Runnable() { |
|
78 |
@Override |
|
79 |
public void run() { |
|
80 |
|
|
81 |
for (MPart part : partService.getParts()){ |
|
82 |
Object object = part.getObject(); |
|
83 |
boolean setFocus = false; |
|
84 |
if (part == activePart){ |
|
85 |
setFocus = true; |
|
86 |
} |
|
87 |
if (object instanceof TaxonNameEditorE4){ |
|
88 |
if (object != null ){ |
|
89 |
if (taxaToUpdate.contains(((TaxonNameEditorE4)object).getTaxon())){ |
|
90 |
EditorUtil.openTaxonBaseE4(((TaxonNameEditorE4)object).getTaxon().getUuid(), modelService, partService, application); |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
94 |
if (object instanceof BulkEditorE4 && ((BulkEditorE4)object).getEditorInput() instanceof TaxonEditorInput){ |
|
95 |
((BulkEditorE4)object).getEditorInput().performSearch( ((BulkEditorE4)object).getLastQuery(), ((BulkEditorE4)object).getSelection()); |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
}); |
|
77 |
for (TaxonBase taxon: taxaToUpdate){ |
|
78 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, taxon); |
|
79 |
} |
|
80 |
|
|
81 |
|
|
100 | 82 |
|
101 | 83 |
} |
102 | 84 |
|
Also available in: Unified diff
fix #7428: use eventbus for propagating update information