Project

General

Profile

Download (2.78 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.key.polytomous.handler;
10

    
11
import org.eclipse.core.commands.ExecutionEvent;
12
import org.eclipse.core.commands.operations.AbstractOperation;
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.Status;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.ui.IEditorPart;
17
import org.eclipse.ui.handlers.HandlerUtil;
18

    
19
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
20
import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
21
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
22
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorLabels;
23
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.RemotingCreatePolytomousKeyNodeOperation;
24

    
25
/**
26
 * @author cmathew
27
 * @date 21 Jul 2015
28
 *
29
 */
30
public class RemotingCreateSiblingPolytomousKeyNodeHandler extends AbstractPolytomousKeyNodeHandler {
31

    
32
    private PolytomousKeyNode parentNode;
33

    
34

    
35
    public RemotingCreateSiblingPolytomousKeyNodeHandler() {
36
        super(PolytomousKeyEditorLabels.CREATE_SIBLING_POLYTOMOUS_KEY_NODE_LABEL);
37
    }
38
    /* (non-Javadoc)
39
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
40
     */
41
    @Override
42
    public IStatus allowOperations(ExecutionEvent event) {
43
        IEditorPart editor = HandlerUtil.getActiveEditor(event);
44
        IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
45
        editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor)
46
                .getActiveEditor();
47
        if (selection.getFirstElement() instanceof PolytomousKeyNode) {
48
            parentNode = (PolytomousKeyNode) selection.getFirstElement();
49
        } else {
50
            return new Status(IStatus.ERROR,
51
                    "unknown", //$NON-NLS-1$
52
                    PolytomousKeyEditorLabels.NO_KEY_NODE_FOR_INSERT_NODE_SELECTED_MESSAGE);
53
        }
54

    
55
        return Status.OK_STATUS;
56
    }
57

    
58
    /* (non-Javadoc)
59
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
60
     */
61
    @Override
62
    public AbstractOperation prepareOperation(ExecutionEvent event) {
63
        return new RemotingCreatePolytomousKeyNodeOperation(event.getTrigger(), false, parentNode.getParent(), editorPage);
64
    }
65

    
66
    /* (non-Javadoc)
67
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
68
     */
69
    @Override
70
    public void onComplete() {
71
        // TODO Auto-generated method stub
72

    
73
    }
74

    
75
}
(8-8/8)