2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.operation
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
14 import org
.eclipse
.core
.runtime
.IAdaptable
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import eu
.etaxonomy
.cdm
.api
.application
.CdmChangeEvent
.Action
;
18 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
20 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
21 import eu
.etaxonomy
.taxeditor
.operation
.RemotingCdmDefaultOperation
;
28 public class InsertPolytomousKeyNodeOperation
extends RemotingCdmDefaultOperation
{
30 private final PolytomousKeyNode parentNode
;
32 private final static String LABEL
= "Insert new polytomous key node";
37 protected IPostOperationEnabled postOperationEnabled
;
45 public InsertPolytomousKeyNodeOperation(Object source
,
47 PolytomousKeyNode parentNode
, IPostOperationEnabled postOperationEnabled
) {
48 super(LABEL
, Action
.Create
, source
, async
);
49 this.parentNode
= parentNode
;
50 this.postOperationEnabled
= postOperationEnabled
;
57 protected CdmBase
doSimpleExecute(IProgressMonitor monitor
, IAdaptable info
) throws Exception
{
58 PolytomousKeyNode childNode
= PolytomousKeyNode
.NewInstance();
59 List
<PolytomousKeyNode
> newChildren
= parentNode
.getChildren();
60 List
<PolytomousKeyNode
> copy
= new ArrayList
<PolytomousKeyNode
>();
61 for (PolytomousKeyNode node
: newChildren
) {
64 parentNode
.addChild(childNode
, 0);
65 for (PolytomousKeyNode node
: copy
){
66 childNode
.addChild(node
);
68 this.postOperationEnabled
.postOperation(childNode
);