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.handlers.HandlerUtil;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
|
20
|
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorLabels;
|
21
|
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.RemotingCreatePolytomousKeyNodeOperation;
|
22
|
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
|
23
|
|
24
|
/**
|
25
|
* @author cmathew
|
26
|
* @date 21 Jul 2015
|
27
|
*
|
28
|
*/
|
29
|
public class RemotingCreateSiblingPolytomousKeyNodeHandler extends RemotingCdmHandler {
|
30
|
|
31
|
private PolytomousKeyNode parentNode;
|
32
|
|
33
|
public RemotingCreateSiblingPolytomousKeyNodeHandler() {
|
34
|
super(PolytomousKeyEditorLabels.CREATE_SIBLING_POLYTOMOUS_KEY_NODE_LABEL);
|
35
|
}
|
36
|
/* (non-Javadoc)
|
37
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
|
38
|
*/
|
39
|
@Override
|
40
|
public IStatus allowOperations(ExecutionEvent event) {
|
41
|
|
42
|
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
|
43
|
|
44
|
if (selection.getFirstElement() instanceof PolytomousKeyNode) {
|
45
|
parentNode = (PolytomousKeyNode) selection.getFirstElement();
|
46
|
} else {
|
47
|
return new Status(IStatus.ERROR,
|
48
|
"unknown",
|
49
|
PolytomousKeyEditorLabels.NO_KEY_NODE_FOR_SIBLING_SELECTED_MESSAGE);
|
50
|
}
|
51
|
|
52
|
return Status.OK_STATUS;
|
53
|
}
|
54
|
|
55
|
/* (non-Javadoc)
|
56
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
|
57
|
*/
|
58
|
@Override
|
59
|
public AbstractOperation prepareOperation(ExecutionEvent event) {
|
60
|
return new RemotingCreatePolytomousKeyNodeOperation(event.getTrigger(), false, parentNode.getParent());
|
61
|
}
|
62
|
|
63
|
/* (non-Javadoc)
|
64
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
|
65
|
*/
|
66
|
@Override
|
67
|
public void onComplete() {
|
68
|
// TODO Auto-generated method stub
|
69
|
|
70
|
}
|
71
|
|
72
|
}
|