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
.reference
.ReferenceBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
23 import eu
.etaxonomy
.taxeditor
.operations
.AbstractEditorOperation
;
30 public class RemoveMisappliedNameOperation
extends AbstractEditorOperation
{
31 private static final Logger logger
= Logger
32 .getLogger(RemoveMisappliedNameOperation
.class);
34 private Taxon misappliedName
;
36 private ReferenceBase citation
;
38 private String microcitation
;
40 public RemoveMisappliedNameOperation(String label
, IUndoContext undoContext
,
41 Taxon taxon
, Taxon misappliedName
) {
42 super(label
, undoContext
, taxon
);
44 this.misappliedName
= misappliedName
;
48 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
51 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
52 throws ExecutionException
{
54 // Find misapplication relation, save citation information
55 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
56 if (relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR())
57 && relationship
.getFromTaxon().equals(misappliedName
)) {
58 citation
= relationship
.getCitation();
59 microcitation
= relationship
.getCitationMicroReference();
63 // Remove misapplied name relation from taxon
64 taxon
.removeTaxon(misappliedName
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
66 return redrawOpenEditor();
70 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
75 return execute(monitor
, info
);
79 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
82 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
83 throws ExecutionException
{
85 taxon
.addMisappliedName(misappliedName
, citation
, microcitation
);
87 return redrawOpenEditor();