#5010 : Initial commit to fix duplicate entry issue when creating new key node
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / key / polytomous / operation / CreateNodeOperation.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.editor.key.polytomous.operation;
5
6 import org.eclipse.core.commands.ExecutionException;
7 import org.eclipse.core.commands.operations.IUndoContext;
8 import org.eclipse.core.runtime.IAdaptable;
9 import org.eclipse.core.runtime.IProgressMonitor;
10 import org.eclipse.core.runtime.IStatus;
11
12 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
13 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
14 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
15 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
16
17 /**
18 * @author n.hoffmann
19 *
20 */
21 public class CreateNodeOperation extends AbstractPostTaxonOperation {
22
23 PolytomousKeyNode parentNode;
24 private PolytomousKeyNode childNode;
25
26 public CreateNodeOperation(String label,
27 IUndoContext undoContext, PolytomousKeyNode parentNode, IPostOperationEnabled postOperationEnabled) {
28 super(label, undoContext, postOperationEnabled);
29 this.parentNode = parentNode;
30 }
31
32 /* (non-Javadoc)
33 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
34 */
35 @Override
36 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
37 throws ExecutionException {
38
39 childNode = PolytomousKeyNode.NewInstance();
40
41 parentNode.addChild(childNode);
42 childNode = CdmApplicationState.getCurrentAppConfig().getPolytomousKeyNodeService().merge(childNode);
43 return postExecute(childNode);
44 }
45
46 /* (non-Javadoc)
47 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
48 */
49 @Override
50 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
51 throws ExecutionException {
52 // TODO Auto-generated method stub
53 return null;
54 }
55
56 /* (non-Javadoc)
57 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 */
59 @Override
60 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
61 throws ExecutionException {
62 // TODO Auto-generated method stub
63 return null;
64 }
65
66 }