Add remoting operation / handlers for key list editor
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / key / polytomous / operation / RemotingCreatePolytomousKeyNodeOperation.java
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.CdmApplicationState;
16 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
17 import eu.etaxonomy.cdm.model.common.CdmBase;
18 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
19 import eu.etaxonomy.taxeditor.operation.RemotingCdmMergeOperation;
20
21 /**
22 * @author cmathew
23 * @date 21 Jul 2015
24 *
25 */
26 public class RemotingCreatePolytomousKeyNodeOperation extends RemotingCdmMergeOperation {
27
28 private final PolytomousKeyNode parentNode;
29
30 private final static String LABEL = "Create new polytomous key node";
31
32 public RemotingCreatePolytomousKeyNodeOperation(Object source,
33 boolean async,
34 PolytomousKeyNode parentNode){
35 super(LABEL, Action.Create, source, async);
36 this.parentNode = parentNode;
37 }
38 /* (non-Javadoc)
39 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmMergeOperation#doMergeExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
40 */
41 @Override
42 protected CdmBase doMergeExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
43 PolytomousKeyNode childNode = PolytomousKeyNode.NewInstance();
44 parentNode.addChild(childNode);
45 return CdmApplicationState.getCurrentAppConfig().getPolytomousKeyNodeService().merge(childNode);
46 }
47
48 }