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.operation;
|
10
|
|
11
|
import org.eclipse.core.runtime.IAdaptable;
|
12
|
import org.eclipse.core.runtime.IProgressMonitor;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
|
15
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
16
|
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
|
17
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
18
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
19
|
import eu.etaxonomy.taxeditor.operation.RemotingCdmDefaultOperation;
|
20
|
|
21
|
/**
|
22
|
* @author cmathew
|
23
|
* @date 21 Jul 2015
|
24
|
*
|
25
|
*/
|
26
|
public class RemotingCreatePolytomousKeyNodeOperation extends RemotingCdmDefaultOperation {
|
27
|
|
28
|
private final PolytomousKeyNode parentNode;
|
29
|
private PolytomousKeyNode childNode;
|
30
|
/**
|
31
|
*
|
32
|
*/
|
33
|
protected IPostOperationEnabled postOperationEnabled;
|
34
|
|
35
|
public PolytomousKeyNode getChildNode() {
|
36
|
return childNode;
|
37
|
}
|
38
|
|
39
|
private final static String LABEL = Messages.RemotingCreatePolytomousKeyNodeOperation_CREATE_KEY;
|
40
|
|
41
|
public RemotingCreatePolytomousKeyNodeOperation(Object source,
|
42
|
boolean async,
|
43
|
PolytomousKeyNode parentNode, IPostOperationEnabled postOperationEnabled){
|
44
|
super(LABEL, Action.Create, source, async);
|
45
|
this.parentNode = parentNode;
|
46
|
this.postOperationEnabled = postOperationEnabled;
|
47
|
}
|
48
|
|
49
|
/* (non-Javadoc)
|
50
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmSimpleOperation#doSimpleExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
51
|
*/
|
52
|
@Override
|
53
|
protected CdmBase doSimpleExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
|
54
|
childNode = PolytomousKeyNode.NewInstance();
|
55
|
parentNode.addChild(childNode);
|
56
|
if (postOperationEnabled.postOperation(childNode)){
|
57
|
return childNode;
|
58
|
}else {
|
59
|
return null;
|
60
|
}
|
61
|
}
|
62
|
|
63
|
|
64
|
|
65
|
|
66
|
|
67
|
|
68
|
}
|