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
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonomicTree
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 public class DeleteTaxonomicTreeOperation
extends AbstractPostOperation
{
33 private static final Logger logger
= Logger
34 .getLogger(DeleteTaxonomicTreeOperation
.class);
36 private TaxonomicTree taxonomicTree
;
43 * @param postOperationEnabled
45 public DeleteTaxonomicTreeOperation(String label
, IUndoContext undoContext
,
46 TaxonomicTree taxonomicTree
) {
47 super(label
, undoContext
, null);
49 this.taxonomicTree
= taxonomicTree
;
56 * @see org.eclipse.core.commands.operations.IUndoableOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
59 throws ExecutionException
{
61 deleteTaxonomicTreeIsolated(taxonomicTree
.getUuid());
63 return postExecute(null);
67 * @see org.eclipse.core.commands.operations.IUndoableOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
69 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
70 throws ExecutionException
{
71 // TODO Auto-generated method stub
77 * @see org.eclipse.core.commands.operations.IUndoableOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
79 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
80 throws ExecutionException
{
81 // TODO Auto-generated method stub
88 private boolean deleteTaxonomicTreeIsolated(UUID uuid
) {
89 // get a new conversation
90 ConversationHolder conversation
= CdmStore
.NewTransactionalConversation();
92 TaxonomicTree taxonomicTree
= CdmStore
.getTaxonService().getTaxonomicTreeByUuid(uuid
);
93 CdmStore
.getTaxonService().removeTaxonomicTree(taxonomicTree
);
95 // commit the conversation
96 conversation
.commit(true);