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
.store
.CdmStore
;
28 * <p>DeleteTaxonDescriptionOperation class.</p>
35 public class DeleteTaxonDescriptionOperation
extends AbstractPostTaxonOperation
{
37 private final TaxonDescription description
;
40 * <p>Constructor for DeleteTaxonDescriptionOperation.</p>
42 * @param label a {@link java.lang.String} object.
43 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
44 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
45 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47 public DeleteTaxonDescriptionOperation(String label
, IUndoContext undoContext
,
48 TaxonDescription description
, IPostOperationEnabled postOperationEnabled
) {
49 super(label
, undoContext
, postOperationEnabled
);
51 this.description
= description
;
52 element
= description
.getTaxon();
56 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
61 throws ExecutionException
{
64 if (description
!= null){
65 List
<String
> propertyPaths
= new ArrayList
<String
>();
66 propertyPaths
.add("taxon");
67 TaxonDescription loadedDescription
= (TaxonDescription
) CdmStore
.getService(IDescriptionService
.class).load(description
.getUuid(), propertyPaths
);
68 CdmStore
.getService(IDescriptionService
.class).deleteDescription(loadedDescription
);
69 return postExecute(description
);
76 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
80 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
81 throws ExecutionException
{
82 return execute(monitor
, info
);
86 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
93 element
.addDescription(description
);
95 return postExecute(null);