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
.store
.operations
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.core
.runtime
.Status
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.taxeditor
.store
.model
.TaxonUtil
;
24 * Change the taxonomic parent of a given taxon.
30 public class MoveTaxonOperation
extends AbstractPostOperation
{
32 @SuppressWarnings("unused")
33 private static final Logger logger
= Logger
.getLogger(MoveTaxonOperation
.class);
35 * A reference to the new taxonomical parent.
37 private Taxon newParentTaxon
;
39 * A reference to the former taxonomical parent
41 private Taxon oldParentTaxon
;
43 public MoveTaxonOperation(String label
, IUndoContext undoContext
,
44 Taxon taxon
, Taxon newParentTaxon
) {
45 super(label
, undoContext
, taxon
);
47 this.newParentTaxon
= newParentTaxon
;
49 // Save old parent taxon for undo
50 this.oldParentTaxon
= taxon
.getTaxonomicParent();
54 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
57 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
58 throws ExecutionException
{
60 TaxonUtil
.moveTaxonBaseIsolated(taxon
.getUuid(), newParentTaxon
.getUuid());
62 return Status
.OK_STATUS
;
66 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
69 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
70 throws ExecutionException
{
71 return execute(monitor
, info
);
75 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
79 throws ExecutionException
{
81 TaxonUtil
.moveTaxonBaseIsolated(taxon
.getUuid(), oldParentTaxon
.getUuid());
83 return Status
.OK_STATUS
;