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
.view
.descriptive
.operation
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.core
.runtime
.IAdaptable
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
22 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
23 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
24 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
25 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * <p>DeleteTaxonDescriptionOperation class.</p>
36 public class DeleteTaxonDescriptionOperation
extends AbstractPostTaxonOperation
{
38 private final TaxonDescription description
;
41 * <p>Constructor for DeleteTaxonDescriptionOperation.</p>
43 * @param label a {@link java.lang.String} object.
44 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
45 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
46 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
48 public DeleteTaxonDescriptionOperation(String label
,
49 IUndoContext undoContext
,
50 TaxonDescription description
,
51 IPostOperationEnabled postOperationEnabled
,
52 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
53 super(label
, undoContext
, postOperationEnabled
, cdmEntitySessionEnabled
);
55 this.description
= description
;
56 element
= description
.getTaxon();
60 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
65 throws ExecutionException
{
68 if (description
!= null){
69 List
<String
> propertyPaths
= new ArrayList
<String
>();
70 propertyPaths
.add("taxon");
71 TaxonDescription loadedDescription
= (TaxonDescription
) CdmStore
.getService(IDescriptionService
.class).load(description
.getUuid(), propertyPaths
);
72 CdmStore
.getService(IDescriptionService
.class).deleteDescription(loadedDescription
);
73 return postExecute(description
);
80 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
84 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{
86 return execute(monitor
, info
);
90 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
94 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
95 throws ExecutionException
{
97 element
.addDescription(description
);
99 return postExecute(null);