Project

General

Profile

Download (1.86 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.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.CdmDefaultOperation;
19
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
20

    
21
/**
22
 * @author cmathew
23
 * @date 21 Jul 2015
24
 */
25
public class CreatePolytomousKeyNodeOperation extends CdmDefaultOperation {
26

    
27
    private final static String LABEL = Messages.RemotingCreatePolytomousKeyNodeOperation_CREATE_KEY;
28

    
29
    private final PolytomousKeyNode parentNode;
30
    private PolytomousKeyNode childNode;
31
    private IPostOperationEnabled postOperationEnabled;
32

    
33
    public PolytomousKeyNode getChildNode() {
34
        return childNode;
35
    }
36

    
37
    public CreatePolytomousKeyNodeOperation(Object source,
38
            boolean async,
39
            PolytomousKeyNode parentNode, IPostOperationEnabled postOperationEnabled){
40
        super(LABEL, Action.Create, source, async);
41
        this.parentNode = parentNode;
42
        this.postOperationEnabled = postOperationEnabled;
43
    }
44

    
45
    @Override
46
    protected CdmBase doSimpleExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
47
        childNode = PolytomousKeyNode.NewInstance();
48
        parentNode.addChild(childNode);
49
        if (postOperationEnabled.postOperation(childNode)){
50
            return childNode;
51
        } else {
52
            return null;
53
        }
54
    }
55
}
(2-2/5)