Project

General

Profile

Download (2.03 KB) Statistics
| Branch: | Tag: | Revision:
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.operation;
11

    
12
import org.eclipse.core.runtime.IAdaptable;
13
import org.eclipse.core.runtime.IProgressMonitor;
14

    
15
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
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 = "Create new polytomous key node";
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
}
(5-5/5)