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
.editor
.name
.operation
;
12 import org
.eclipse
.core
.commands
.ExecutionException
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.IAdaptable
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
26 * <p>DeleteMisapplicationOperation class.</p>
32 public class DeleteMisapplicationOperation
extends AbstractPostTaxonOperation
{
34 private final Taxon misapplication
;
36 private Reference
<?
> citation
;
38 private String microcitation
;
41 * <p>Constructor for DeleteMisapplicationOperation.</p>
43 * @param label a {@link java.lang.String} object.
44 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
45 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
46 * @param misapplication a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
47 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
49 public DeleteMisapplicationOperation(String label
, IUndoContext undoContext
,
50 Taxon taxon
, Taxon misapplication
, IPostOperationEnabled postOperationEnabled
) {
51 super(label
, undoContext
, taxon
, postOperationEnabled
);
53 this.misapplication
= misapplication
;
57 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
61 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
62 throws ExecutionException
{
64 // Find misapplication relation, save citation information
65 for (TaxonRelationship relationship
: element
.getTaxonRelations()) {
66 if (relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR())
67 && relationship
.getFromTaxon().equals(misapplication
)) {
68 citation
= relationship
.getCitation();
69 microcitation
= relationship
.getCitationMicroReference();
74 // Remove misapplied name relation from taxon
75 element
.removeTaxon(misapplication
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
78 return postExecute(null);
82 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
86 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
87 throws ExecutionException
{
88 return execute(monitor
, info
);
92 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
96 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
97 throws ExecutionException
{
99 element
.addMisappliedName(misapplication
, citation
, microcitation
);
101 return postExecute(misapplication
);