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
.navigation
.key
.polytomous
.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
;
17 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
20 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyService
;
22 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
23 import eu
.etaxonomy
.taxeditor
.navigation
.l10n
.Messages
;
24 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
25 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
26 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 * @created Dec 2, 2010
34 public class DeleteOperation
extends AbstractPersistentPostOperation
{
36 private final PolytomousKey key
;
37 private final ICdmEntitySessionEnabled cdmEntitySessionEnabled
;
43 * @param postOperationEnabled
45 public DeleteOperation(String label
, IUndoContext undoContext
,
47 IPostOperationEnabled postOperationEnabled
,
48 IConversationEnabled conversationEnabled
,
49 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
50 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
52 this.cdmEntitySessionEnabled
= cdmEntitySessionEnabled
;
56 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
57 throws ExecutionException
{
60 DeleteResult result
= CdmStore
.getService(IPolytomousKeyService
.class).delete(key
);
62 if (result
.isError() && !result
.getExceptions().isEmpty()){
63 MessageDialog
.openError(null, Messages
.DeleteOperation_FAILED
, result
.getExceptions().iterator().next().getMessage());
65 }else if(result
.isAbort()){
66 MessageDialog
.openWarning(null, Messages
.DeleteOperation_ABORT
, Messages
.DeleteOperation_ABORT_MESSAGE
);
69 return postExecute(null);
73 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
79 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
80 throws ExecutionException
{