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
.name
;
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
.ui
.PartInitException
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.controller
.EditorController
;
23 import eu
.etaxonomy
.taxeditor
.model
.CdmSessionDataRepository
;
24 import eu
.etaxonomy
.taxeditor
.operations
.AbstractEditorOperation
;
31 public class ChangeSynonymToTaxonOperation
extends AbstractEditorOperation
{
32 private static final Logger logger
= Logger
33 .getLogger(ChangeSynonymToTaxonOperation
.class);
34 private Synonym synonym
;
36 public ChangeSynonymToTaxonOperation(String text
, IUndoContext undoContext
,
37 Taxon taxon
, Synonym synonym
) {
38 super(text
, undoContext
, taxon
);
40 this.synonym
= synonym
;
44 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
47 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
48 throws ExecutionException
{
50 // Remove synonym from taxon
51 taxon
.removeSynonym(synonym
);
53 // Create new taxon with synonym name
54 Taxon newTaxon
= Taxon
.NewInstance(synonym
.getName(), synonym
.getSec());
56 // Add new taxon to session data repository
57 taxon
.setTaxonomicParent(null, null, null);
58 CdmSessionDataRepository
.getDefault().addTaxon(newTaxon
);
60 // Open editor for new taxon
61 EditorController
.open(newTaxon
);
64 return redrawOpenEditor();
68 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
71 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
72 throws ExecutionException
{
73 // TODO Auto-generated method stub
78 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
81 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
82 throws ExecutionException
{
83 // TODO Auto-generated method stub