removed unused config and added comments
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / key / polytomous / operation / DeleteOperation.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.navigation.key.polytomous.operation;
12
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;
19
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.model.description.PolytomousKey;
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;
28
29 /**
30 * @author n.hoffmann
31 * @created Dec 2, 2010
32 * @version 1.0
33 */
34 public class DeleteOperation extends AbstractPersistentPostOperation {
35
36 private final PolytomousKey key;
37 private final ICdmEntitySessionEnabled cdmEntitySessionEnabled;
38
39 /**
40 * @param label
41 * @param undoContext
42 * @param postOperationEnabled
43 */
44 public DeleteOperation(String label, IUndoContext undoContext,
45 PolytomousKey key,
46 IPostOperationEnabled postOperationEnabled,
47 IConversationEnabled conversationEnabled,
48 ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
49 super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
50 this.key = key;
51 this.cdmEntitySessionEnabled = cdmEntitySessionEnabled;
52 }
53
54 /* (non-Javadoc)
55 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 */
57 @Override
58 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
59 throws ExecutionException {
60 bind();
61
62 DeleteResult result = CdmStore.getService(IPolytomousKeyService.class).delete(key);
63
64 if (result.isError()){
65 MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());
66
67 } else if(result.isAbort()){
68 MessageDialog.openWarning(null, "Delete abort", "The object could not be deleted, maybe there was no object selected.");
69 }
70
71 return postExecute(null);
72 }
73
74 /* (non-Javadoc)
75 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
76 */
77 @Override
78 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
79 throws ExecutionException {
80 return null;
81 }
82
83 /* (non-Javadoc)
84 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85 */
86 @Override
87 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
88 throws ExecutionException {
89 return null;
90 }
91
92 }