(no commit message)
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / DeleteTaxonomicTreeOperation.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.operations;
12
13 import java.util.UUID;
14
15 import org.apache.log4j.Logger;
16 import org.eclipse.core.commands.ExecutionException;
17 import org.eclipse.core.commands.operations.IUndoContext;
18 import org.eclipse.core.runtime.IAdaptable;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.core.runtime.IStatus;
21 import org.eclipse.core.runtime.Status;
22 import org.eclipse.jface.dialogs.MessageDialog;
23 import org.eclipse.swt.widgets.Shell;
24
25 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
26 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
27 import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
28 import eu.etaxonomy.taxeditor.store.CdmStore;
29
30 /**
31 * @author n.hoffmann
32 * @created 23.06.2009
33 * @version 1.0
34 */
35 @Deprecated
36 public class DeleteTaxonomicTreeOperation extends AbstractPersistentPostOperation {
37
38 private static final Logger logger = Logger
39 .getLogger(DeleteTaxonomicTreeOperation.class);
40
41 private TaxonomicTree taxonomicTree;
42
43
44 /**
45 * @param label
46 * @param undoContext
47 * @param taxonNode
48 * @param postOperationEnabled
49 */
50 public DeleteTaxonomicTreeOperation(String label, IUndoContext undoContext,
51 TaxonomicTree taxonomicTree, IPostOperationEnabled postOperationEnabled,
52 IConversationEnabled conversationEnabled) {
53 super(label, undoContext, postOperationEnabled, conversationEnabled);
54
55 this.taxonomicTree = taxonomicTree;
56 }
57
58 /* (non-Javadoc)
59 * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 */
61 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
62 throws ExecutionException {
63
64 String childWarning = taxonomicTree.getRootNodes().size() > 0 ? "and all included nodes" : "";
65
66 // Prompt user for confirmation
67 if(! MessageDialog.openConfirm((Shell) info.getAdapter(Shell.class), "Confirm Deletion", "Are you sure you want to delete the taxonomic view '" + taxonomicTree.getTitleCache() + "' " + childWarning + "?")){
68 monitor.done();
69 return Status.CANCEL_STATUS;
70 }
71
72 // If the taxonomic tree has child nodes, cancel operation
73 // TODO add option to continue, and delete children
74 // if (taxonomicTree.getRootNodes().size() > 0) {
75 // MessageDialog.openInformation((Shell) info.getAdapter(Shell.class), "Cannot delete taxon",
76 // "'" + taxonomicTree.getTitleCache() + "' has taxonomic children. " +
77 // "These must be manually deleted before their parent.");
78 // monitor.done();
79 // return Status.CANCEL_STATUS;
80 // }
81
82 CdmStore.getTaxonTreeService().delete(taxonomicTree);
83
84 return postExecute(null);
85 }
86
87 /* (non-Javadoc)
88 * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
89 */
90 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
91 throws ExecutionException {
92 // TODO Auto-generated method stub
93 return null;
94 }
95
96
97 /* (non-Javadoc)
98 * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
99 */
100 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
101 throws ExecutionException {
102 // TODO Auto-generated method stub
103 return null;
104 }
105 }