Revision 6931cd11
Added by Cherian Mathew almost 11 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/handler/CreateDefinedTermHandler.java | ||
---|---|---|
14 | 14 |
import org.eclipse.core.commands.ExecutionException; |
15 | 15 |
import org.eclipse.core.commands.IHandler; |
16 | 16 |
import org.eclipse.core.commands.common.NotDefinedException; |
17 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
17 | 18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
18 | 19 |
import org.eclipse.ui.handlers.HandlerUtil; |
19 | 20 |
|
21 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
20 | 22 |
import eu.etaxonomy.cdm.model.common.TermBase; |
23 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
21 | 24 |
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor; |
22 | 25 |
import eu.etaxonomy.taxeditor.editor.definedterm.operation.CreateDefinedTermOperation; |
23 | 26 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
... | ... | |
43 | 46 |
IPostOperationEnabled editor = (IPostOperationEnabled) HandlerUtil |
44 | 47 |
.getActiveEditor(event); |
45 | 48 |
|
46 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
47 |
.getCurrentSelection(event); |
|
49 |
if (editor instanceof DefinedTermEditor){ |
|
50 |
DefinedTermEditor dfe = (DefinedTermEditor) editor; |
|
51 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
52 |
.getCurrentSelection(event); |
|
53 |
if (selection.getFirstElement() instanceof TermBase) { |
|
54 |
try { |
|
55 |
String label = event.getCommand().getName(); |
|
56 |
IUndoContext undoContext = StoreUtil.getUndoContext(); |
|
48 | 57 |
|
49 |
TermBase selectedElement = (TermBase) selection.getFirstElement();
|
|
58 |
TermBase termBase = (TermBase) selection.getFirstElement();
|
|
50 | 59 |
|
51 |
try { |
|
52 |
AbstractPostOperation operation = new CreateDefinedTermOperation( |
|
53 |
event.getCommand().getName(), StoreUtil.getUndoContext(), |
|
54 |
selectedElement, editor); |
|
55 |
StoreUtil.executeOperation(operation); |
|
60 |
AbstractPostOperation operation = |
|
61 |
new CreateDefinedTermOperation(label, |
|
62 |
undoContext, |
|
63 |
termBase, |
|
64 |
dfe.getDefinedTermEditorInput(), |
|
65 |
editor); |
|
66 |
StoreUtil.executeOperation(operation); |
|
56 | 67 |
|
57 |
} catch (NotDefinedException e) { |
|
58 |
StoreUtil.error(getClass(), e); |
|
68 |
} catch (NotDefinedException e) { |
|
69 |
StoreUtil.error(getClass(), e); |
|
70 |
} |
|
71 |
} |
|
59 | 72 |
} |
60 | 73 |
|
61 | 74 |
return null; |
62 | 75 |
} |
63 | 76 |
|
64 |
} |
|
77 |
} |
Also available in: Unified diff
updated handlers to be more consistent and use the new TermEditorInput which stores the in memory list of vocabularies
OpenDefinedTermMenu : not used anymore