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
;
35 public class DeleteTaxonomicTreeOperation
extends AbstractPersistentPostOperation
{
37 private static final Logger logger
= Logger
38 .getLogger(DeleteTaxonomicTreeOperation
.class);
40 private TaxonomicTree taxonomicTree
;
47 * @param postOperationEnabled
49 public DeleteTaxonomicTreeOperation(String label
, IUndoContext undoContext
,
50 TaxonomicTree taxonomicTree
, IPostOperationEnabled postOperationEnabled
,
51 IConversationEnabled conversationEnabled
) {
52 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
54 this.taxonomicTree
= taxonomicTree
;
58 * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
61 throws ExecutionException
{
63 // Prompt user for confirmation
64 if(! MessageDialog
.openConfirm((Shell
) info
.getAdapter(Shell
.class), "Confirm Deletion", "Are you sure you want to delete the taxonomic view '" + taxonomicTree
.getTitleCache() + "'?")){
66 return Status
.CANCEL_STATUS
;
69 // If the taxonomic tree has child nodes, cancel operation
70 // TODO add option to continue, and delete children
71 if (taxonomicTree
.getRootNodes().size() > 0) {
72 MessageDialog
.openInformation((Shell
) info
.getAdapter(Shell
.class), "Cannot delete taxon",
73 "'" + taxonomicTree
.getTitleCache() + "' has taxonomic children. " +
74 "These must be manually deleted before their parent.");
76 return Status
.CANCEL_STATUS
;
79 CdmStore
.getTaxonTreeService().delete(taxonomicTree
);
81 return postExecute(null);
85 * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
88 throws ExecutionException
{
89 // TODO Auto-generated method stub
95 * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
97 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
98 throws ExecutionException
{
99 // TODO Auto-generated method stub