Merge branch 'release/4.4.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / key / polytomous / handler / RemotingCreateSiblingPolytomousKeyNodeHandler.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.editor.key.polytomous.handler;
11
12 import org.eclipse.core.commands.ExecutionEvent;
13 import org.eclipse.core.commands.operations.AbstractOperation;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.ui.IEditorPart;
18 import org.eclipse.ui.handlers.HandlerUtil;
19
20 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
21 import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
22 import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
23 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorLabels;
24 import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.RemotingCreatePolytomousKeyNodeOperation;
25
26 /**
27 * @author cmathew
28 * @date 21 Jul 2015
29 *
30 */
31 public class RemotingCreateSiblingPolytomousKeyNodeHandler extends AbstractPolytomousKeyNodeHandler {
32
33 private PolytomousKeyNode parentNode;
34
35
36 public RemotingCreateSiblingPolytomousKeyNodeHandler() {
37 super(PolytomousKeyEditorLabels.CREATE_SIBLING_POLYTOMOUS_KEY_NODE_LABEL);
38 }
39 /* (non-Javadoc)
40 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
41 */
42 @Override
43 public IStatus allowOperations(ExecutionEvent event) {
44 IEditorPart editor = HandlerUtil.getActiveEditor(event);
45 IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
46 editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor)
47 .getActiveEditor();
48 if (selection.getFirstElement() instanceof PolytomousKeyNode) {
49 parentNode = (PolytomousKeyNode) selection.getFirstElement();
50 } else {
51 return new Status(IStatus.ERROR,
52 "unknown",
53 PolytomousKeyEditorLabels.NO_KEY_NODE_FOR_SIBLING_SELECTED_MESSAGE);
54 }
55
56 return Status.OK_STATUS;
57 }
58
59 /* (non-Javadoc)
60 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
61 */
62 @Override
63 public AbstractOperation prepareOperation(ExecutionEvent event) {
64 return new RemotingCreatePolytomousKeyNodeOperation(event.getTrigger(), false, parentNode.getParent(), editorPage);
65 }
66
67 /* (non-Javadoc)
68 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
69 */
70 @Override
71 public void onComplete() {
72 // TODO Auto-generated method stub
73
74 }
75
76 }