Revision 4cc2aab3
Added by Niels Hoffmann almost 13 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateNodeHandler.java | ||
---|---|---|
14 | 14 |
|
15 | 15 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
16 | 16 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
17 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyGraphEditor; |
|
17 |
import eu.etaxonomy.taxeditor.editor.key.KeyEditor; |
|
18 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage; |
|
18 | 19 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.CreateNodeOperation; |
19 | 20 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
20 | 21 |
|
21 | 22 |
/** |
22 | 23 |
* @author n.hoffmann |
23 |
* |
|
24 |
*
|
|
24 | 25 |
*/ |
25 | 26 |
public class CreateNodeHandler extends AbstractHandler { |
26 | 27 |
|
27 |
/* (non-Javadoc) |
|
28 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
28 |
/* |
|
29 |
* (non-Javadoc) |
|
30 |
* |
|
31 |
* @see |
|
32 |
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. |
|
33 |
* ExecutionEvent) |
|
29 | 34 |
*/ |
30 | 35 |
@Override |
31 | 36 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
32 |
|
|
37 |
|
|
33 | 38 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
34 |
|
|
35 |
if(editor instanceof PolytomousKeyGraphEditor){ |
|
36 |
PolytomousKeyGraphEditor keyEditor = (PolytomousKeyGraphEditor) editor; |
|
37 |
|
|
38 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event); |
|
39 |
|
|
40 |
if(selection.getFirstElement() instanceof PolytomousKeyNode){ |
|
39 |
|
|
40 |
if (editor instanceof KeyEditor) { |
|
41 |
IPolytomousKeyEditorPage editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor) |
|
42 |
.getActiveEditor(); |
|
43 |
|
|
44 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
|
45 |
.getActiveMenuSelection(event); |
|
46 |
|
|
47 |
if (selection.getFirstElement() instanceof PolytomousKeyNode) { |
|
41 | 48 |
try { |
42 | 49 |
String label = event.getCommand().getName(); |
43 | 50 |
IUndoContext undoContext = EditorUtil.getUndoContext(); |
44 |
|
|
45 |
PolytomousKeyNode keyNode = (PolytomousKeyNode) selection.getFirstElement(); |
|
46 |
|
|
47 |
AbstractPostOperation operation = new CreateNodeOperation(label, undoContext, keyNode, keyEditor); |
|
51 |
|
|
52 |
PolytomousKeyNode keyNode = (PolytomousKeyNode) selection |
|
53 |
.getFirstElement(); |
|
54 |
|
|
55 |
AbstractPostOperation operation = new CreateNodeOperation( |
|
56 |
label, undoContext, keyNode, editorPage); |
|
48 | 57 |
EditorUtil.executeOperation(operation); |
49 | 58 |
} catch (NotDefinedException e) { |
50 | 59 |
EditorUtil.warn(getClass(), "Command name not set."); |
51 | 60 |
} |
52 |
|
|
61 |
|
|
53 | 62 |
} |
54 | 63 |
} |
55 |
|
|
64 |
|
|
56 | 65 |
return null; |
57 | 66 |
} |
58 | 67 |
|
Also available in: Unified diff
Finalizing PolytomousKeyListEditor