3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.operation
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
22 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyService
;
23 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
24 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
25 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
26 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 * @created Dec 2, 2010
34 public class DeleteOperation
extends AbstractPersistentPostOperation
{
36 private PolytomousKey key
;
41 * @param postOperationEnabled
43 public DeleteOperation(String label
, IUndoContext undoContext
,
45 IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
) {
46 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
51 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
54 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
55 throws ExecutionException
{
58 DeleteResult result
= CdmStore
.getService(IPolytomousKeyService
.class).delete(key
);
59 if (result
.isError()){
60 MessageDialog
.openError(null, "Delete failed", result
.getExceptions().get(0).getMessage());
62 }else if(!result
.getExceptions().isEmpty()){
66 return postExecute(null);
70 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
79 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
82 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
83 throws ExecutionException
{