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
.store
.operations
;
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
.name
.TaxonNameBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
21 import eu
.etaxonomy
.taxeditor
.store
.parser
.CdmParserUtil
;
29 public class CreateMisapplicationOperation
extends AbstractPostOperation
{
31 private Taxon misapplication
;
33 public CreateMisapplicationOperation(String label
, IUndoContext undoContext
,
34 Taxon taxon
, IPostOperationEnabled editor
) {
35 super(label
, undoContext
, taxon
, editor
);
39 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
42 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
43 throws ExecutionException
{
45 // Create empty new name
46 TaxonNameBase
<?
, ?
> misapplicationName
=
47 CdmParserUtil
.parseFullReference("", null, null);
49 // make misapplication name with misapplication name
50 misapplication
= Taxon
.NewInstance(misapplicationName
, null);
52 // add misapplied name to taxon
53 // TODO add microcitation for misapplied name to property sheet
54 taxon
.addMisappliedName(misapplication
, null, null);
56 // redraw editor if exists
57 return postExecute(misapplication
);
61 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
65 throws ExecutionException
{
66 return execute(monitor
, info
);
70 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
76 // Remove misapplied name from taxon
77 taxon
.removeTaxon(misapplication
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
79 // Redraw editor if exists
80 return postExecute(null);