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
.operations
;
13 import java
.util
.UUID
;
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
;
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
;
36 public class DeleteTaxonomicTreeOperation
extends AbstractPersistentPostOperation
{
38 private static final Logger logger
= Logger
39 .getLogger(DeleteTaxonomicTreeOperation
.class);
41 private TaxonomicTree taxonomicTree
;
48 * @param postOperationEnabled
50 public DeleteTaxonomicTreeOperation(String label
, IUndoContext undoContext
,
51 TaxonomicTree taxonomicTree
, IPostOperationEnabled postOperationEnabled
,
52 IConversationEnabled conversationEnabled
) {
53 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
55 this.taxonomicTree
= taxonomicTree
;
59 * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
61 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
62 throws ExecutionException
{
64 String childWarning
= taxonomicTree
.getRootNodes().size() > 0 ?
"and all included nodes" : "";
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
+ "?")){
69 return Status
.CANCEL_STATUS
;
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.");
79 // return Status.CANCEL_STATUS;
82 CdmStore
.getTaxonTreeService().delete(taxonomicTree
);
84 return postExecute(null);
88 * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
92 // TODO Auto-generated method stub
98 * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
100 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
101 throws ExecutionException
{
102 // TODO Auto-generated method stub