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
;
19 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
23 import eu
.etaxonomy
.taxeditor
.editor
.name
.CdmParserController
;
24 import eu
.etaxonomy
.taxeditor
.operations
.AbstractEditorOperation
;
31 public class CreateMisappliedNameOperation
extends AbstractEditorOperation
{
32 private static final Logger logger
= Logger
33 .getLogger(CreateMisappliedNameOperation
.class);
35 private Taxon misapplication
;
37 public CreateMisappliedNameOperation(String label
, IUndoContext undoContext
,
39 super(label
, undoContext
, taxon
);
43 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
46 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
47 throws ExecutionException
{
49 // Create empty new name
50 TaxonNameBase misapplicationName
=
51 CdmParserController
.parseFullReference("", null, null);
53 // make misapplication name with misapplication name
54 misapplication
= Taxon
.NewInstance(misapplicationName
, null);
56 // add misapplied name to taxon
57 // TODO add microcitation for misapplied name to property sheet
58 taxon
.addMisappliedName(misapplication
, null, null);
60 // redraw editor if exists
61 return redrawOpenEditor();
65 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
68 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
69 throws ExecutionException
{
70 return execute(monitor
, info
);
74 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
77 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
78 throws ExecutionException
{
80 // Remove misapplied name from taxon
81 taxon
.removeTaxon(misapplication
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
83 // Redraw editor if exists
84 return redrawOpenEditor();