2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
.operation
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.core
.runtime
.IAdaptable
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
20 import org
.eclipse
.core
.runtime
.Status
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
23 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
25 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
26 import eu
.etaxonomy
.taxeditor
.navigation
.l10n
.Messages
;
27 import eu
.etaxonomy
.taxeditor
.navigation
.navigator
.e4
.TreeNodeDropAdapterE4
.MovingType
;
28 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
29 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 * Change the taxonomic parent of a given taxon.
39 public class MoveTaxonOperation
extends AbstractPersistentPostOperation
{
42 * A reference to the new taxonomical parent.
44 private final ITaxonTreeNode newParentTreeNode
;
46 * A reference to the former taxonomical parents
48 //private Map<TaxonNode, ITaxonTreeNode> oldParentTreeNodes;
50 private final Set
<UUID
> taxonNodesUuid
;
51 private final MovingType moveToParentNode
;
52 public MoveTaxonOperation(String label
, IUndoContext undoContext
,
53 Set
<UUID
> taxonNodesUUIDToMove
, ITaxonTreeNode newParentTreeNode
,
54 IPostOperationEnabled postOperationEnabled
,
55 IConversationEnabled conversationEnabled
, MovingType moveToParentNode
) {
56 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
58 this.taxonNodesUuid
= taxonNodesUUIDToMove
;
59 /*for (TaxonNode node:taxonNodes){
60 this.taxonNodes.add(service.load(node.getUuid()));
63 this.newParentTreeNode
= newParentTreeNode
;
64 this.moveToParentNode
= moveToParentNode
;
65 // Save old parent ITaxonTreeNodes for undo
67 //this.parentNode = taxonNode.getParent();
72 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
73 throws ExecutionException
{
76 switch(this.moveToParentNode
){
78 CdmStore
.getService(ITaxonNodeService
.class).moveTaxonNodes(this.taxonNodesUuid
,newParentTreeNode
.getUuid(), 0);
81 CdmStore
.getService(ITaxonNodeService
.class).moveTaxonNodes(this.taxonNodesUuid
,newParentTreeNode
.getUuid(), 1);
84 CdmStore
.getService(ITaxonNodeService
.class).moveTaxonNodes(this.taxonNodesUuid
,newParentTreeNode
.getUuid(), 2);
89 // for (TaxonNode taxonNode : taxonNodes){
90 // TaxonNode newTaxonNode = newParentTreeNode.addChildNode(taxonNode,
91 // newParentTreeNode.getReference(), newParentTreeNode.getMicroReference());
92 // //taxonNodes.add(newTaxonNode);
96 // } catch(IllegalAncestryException e) {
97 // MessagingUtils.warningDialog("Illegal ancestry", this, e.getMessage());
101 return postExecute(null);
106 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
107 throws ExecutionException
{
108 return execute(monitor
, info
);
113 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
114 throws ExecutionException
{
115 MessagingUtils
.warn(this.getClass(), Messages
.MoveTaxonOperation_NOT_IMPLEMENTED
);
117 // iterate over oldParentTreeNodes, delete each TaxonNode from its actual parent and add to its former parent
119 return Status
.OK_STATUS
;