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
.derivate
.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
.api
.service
.DeleteResult
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
20 import eu
.etaxonomy
.cdm
.api
.service
.config
.SpecimenDeleteConfigurator
;
21 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
22 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
23 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
24 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 public class DeleteDerivateOperation
extends AbstractPostOperation
<CdmBase
> {
35 private final SpecimenDeleteConfigurator deleteConfigurator
;
37 public DeleteDerivateOperation(String label
, IUndoContext undoContext
, CdmBase element
,
38 IPostOperationEnabled postOperationEnabled
) {
39 this(label
, undoContext
, element
, postOperationEnabled
, new SpecimenDeleteConfigurator());
42 public DeleteDerivateOperation(String label
, IUndoContext undoContext
, CdmBase element
,
43 IPostOperationEnabled postOperationEnabled
, SpecimenDeleteConfigurator config
) {
44 super(label
, undoContext
, element
, postOperationEnabled
);
45 this.deleteConfigurator
= config
;
53 * org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
54 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
59 DeleteResult deleteResult
= CdmStore
.getService(IOccurrenceService
.class).deleteDerivateHierarchy(element
, deleteConfigurator
);
60 if(!deleteResult
.isOk()){
61 String exceptionMessage
= "";
62 for(Exception exception
:deleteResult
.getExceptions()){
63 exceptionMessage
+= exception
.getLocalizedMessage();
65 //TODO: add method to DeleteResult to sum up exceptions
66 MessagingUtils
.warningDialog("Deletion failed", this, exceptionMessage
);
67 return postExecute(null);
69 return postExecute(element
);
76 * org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
77 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
81 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
82 return execute(monitor
, info
);
89 * org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
90 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
94 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
95 return postExecute(element
);