Revision d175d20f
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SwapSynonymAndAcceptedHandler.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
47 | 47 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
48 | 48 |
*/ |
49 | 49 |
/** {@inheritDoc} */ |
50 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
50 |
@Override |
|
51 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
51 | 52 |
editor = EditorUtil.getActiveMultiPageTaxonEditor(); |
52 | 53 |
Shell shell = HandlerUtil.getActiveShell(event); |
53 | 54 |
Synonym synonym = (Synonym) EditorUtil.getSelection(event).getFirstElement(); |
54 |
|
|
55 |
|
|
55 | 56 |
|
56 | 57 |
// Force user to save taxon - not really necessary though, is it? |
57 | 58 |
if (!EditorUtil.forceUserSave(editor, shell)) { |
58 | 59 |
return null; |
59 | 60 |
} |
60 |
|
|
61 |
|
|
61 | 62 |
try { |
62 | 63 |
SwapSynonymAndAcceptedOperation operation = new SwapSynonymAndAcceptedOperation(event.getCommand().getName(), editor.getUndoContext(), |
63 |
editor.getTaxon(), synonym, this); |
|
64 |
|
|
64 |
editor.getTaxon(), synonym, this, editor);
|
|
65 |
|
|
65 | 66 |
EditorUtil.executeOperation(operation); |
66 |
|
|
67 |
|
|
67 | 68 |
} catch (NotDefinedException e) { |
68 | 69 |
logger.warn("Command name not set"); |
69 |
}
|
|
70 |
} |
|
70 | 71 |
|
71 | 72 |
return null; |
72 | 73 |
} |
... | ... | |
78 | 79 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
79 | 80 |
// Redraw existing editor |
80 | 81 |
//((IPostOperationEnabled) editor).postOperation(null); |
81 |
|
|
82 |
|
|
82 | 83 |
editor.doSave(EditorUtil.getMonitor()); |
83 | 84 |
editor.close(true); |
84 |
|
|
85 |
|
|
85 | 86 |
if (objectAffectedByOperation instanceof Taxon) { |
86 |
|
|
87 |
|
|
87 | 88 |
taxon = (Taxon) objectAffectedByOperation; |
88 |
|
|
89 |
|
|
89 |
|
|
90 |
|
|
90 | 91 |
} |
91 | 92 |
return true; |
92 | 93 |
} |
... | ... | |
98 | 99 |
public boolean onComplete() { |
99 | 100 |
Display display = Display.getCurrent(); |
100 | 101 |
display.asyncExec(new Runnable() { |
101 |
public void run() { |
|
102 |
@Override |
|
103 |
public void run() { |
|
102 | 104 |
try { |
103 | 105 |
EditorUtil.openTaxonBase(taxon.getUuid()); |
104 |
|
|
106 |
|
|
105 | 107 |
} catch (Exception e) { |
106 | 108 |
MessagingUtils.warningDialog("Could not open editor for taxon", this, e.getMessage()); |
107 | 109 |
} |
108 |
|
|
110 |
|
|
109 | 111 |
} |
110 | 112 |
}); |
111 | 113 |
return true; |
Also available in: Unified diff
added cdm entitysession enabled objects to operations