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 org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.core
.runtime
.IAdaptable
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
20 import org
.eclipse
.core
.runtime
.Status
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonomicTree
;
24 import eu
.etaxonomy
.taxeditor
.model
.TaxonUtil
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 public class CreateTaxonomicTreeOperation
extends AbstractOperation
{
34 private static final Logger logger
= Logger
35 .getLogger(CreateTaxonomicTreeOperation
.class);
36 private String treeLabel
;
42 public CreateTaxonomicTreeOperation(String label
, IUndoContext undoContext
, String treeLabel
) {
44 addContext(undoContext
);
46 this.treeLabel
= treeLabel
;
50 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
53 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
54 throws ExecutionException
{
56 if(treeLabel
.trim().length() == 0){
57 return Status
.CANCEL_STATUS
;
60 // get a new conversation
61 ConversationHolder conversation
= CdmStore
.NewTransactionalConversation();
63 TaxonomicTree tree
= TaxonomicTree
.NewInstance(treeLabel
);
65 CdmStore
.getTaxonService().saveTaxonomicTree(tree
);
67 conversation
.commit(true);
69 return Status
.OK_STATUS
;
73 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
76 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
77 throws ExecutionException
{
78 // TODO Auto-generated method stub
83 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
86 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
87 throws ExecutionException
{
88 // TODO Auto-generated method stub