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
.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
.model
.CdmSessionDataRepository
;
28 public class MoveTaxonOperation
extends AbstractEditorOperation
{
31 private static Logger logger
= Logger
.getLogger(MoveTaxonOperation
.class);
32 private Taxon newParentTaxon
;
33 private Taxon oldParentTaxon
;
35 public MoveTaxonOperation(String label
, IUndoContext undoContext
,
36 Taxon taxon
, Taxon newParentTaxon
) {
37 super(label
, undoContext
, taxon
);
39 this.newParentTaxon
= newParentTaxon
;
41 // Save old parent taxon for undo
42 this.oldParentTaxon
= taxon
.getTaxonomicParent();
46 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
49 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
50 throws ExecutionException
{
51 CdmSessionDataRepository
.getDefault().setTaxonomicParent(taxon
, newParentTaxon
);
52 CdmSessionDataRepository
.getDefault().saveTaxon(taxon
);
54 return Status
.OK_STATUS
;
58 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
61 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
62 throws ExecutionException
{
63 return execute(monitor
, info
);
67 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
70 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
71 throws ExecutionException
{
72 CdmSessionDataRepository
.getDefault().setTaxonomicParent(taxon
, oldParentTaxon
);
73 CdmSessionDataRepository
.getDefault().saveTaxon(taxon
);
75 return Status
.OK_STATUS
;