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
.api
.service
.UpdateResult
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
26 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
27 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
28 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 * Change the taxonomic parent of a given taxon.
38 public class MoveTaxonOperation
extends AbstractPersistentPostOperation
{
41 * A reference to the new taxonomical parent.
43 private final ITaxonTreeNode newParentTreeNode
;
45 * A reference to the former taxonomical parents
47 //private Map<TaxonNode, ITaxonTreeNode> oldParentTreeNodes;
49 private final Set
<UUID
> taxonNodesUuid
;
50 private final boolean moveToParentNode
;
52 * <p>Constructor for MoveTaxonOperation.</p>
54 * @param label a {@link java.lang.String} object.
55 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
56 * @param taxonNodes a {@link java.util.Set} object.
57 * @param newParentTreeNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
58 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
59 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
61 public MoveTaxonOperation(String label
, IUndoContext undoContext
,
62 Set
<UUID
> taxonNodesUUIDToMove
, ITaxonTreeNode newParentTreeNode
, IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
, boolean moveToParentNode
) {
63 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
65 this.taxonNodesUuid
= taxonNodesUUIDToMove
;
66 /*for (TaxonNode node:taxonNodes){
67 this.taxonNodes.add(service.load(node.getUuid()));
70 this.newParentTreeNode
= newParentTreeNode
;
71 this.moveToParentNode
= moveToParentNode
;
72 // Save old parent ITaxonTreeNodes for undo
74 //this.parentNode = taxonNode.getParent();
78 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
82 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
83 throws ExecutionException
{
87 UpdateResult result
= CdmStore
.getService(ITaxonNodeService
.class).moveTaxonNodes(this.taxonNodesUuid
,newParentTreeNode
.getUuid());
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);
105 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
109 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
110 throws ExecutionException
{
111 return execute(monitor
, info
);
115 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
119 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
120 throws ExecutionException
{
121 MessagingUtils
.warn(this.getClass(), "Not implemented yet.");
123 // iterate over oldParentTreeNodes, delete each TaxonNode from its actual parent and add to its former parent
125 return Status
.OK_STATUS
;