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
;
23 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
24 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
25 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.ITreeNode
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
31 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
38 public class CreateTaxonNodeOperation
extends AbstractPersistentPostOperation
{
40 private static final Logger logger
= Logger
.getLogger(CreateTaxonNodeOperation
.class);
42 private Taxon newTaxon
;
44 private TaxonNode childTaxonNode
;
47 * Add a name to a taxonomic tree
51 * @param parentNodeUuid
53 * @param postOperationEnabled
55 public CreateTaxonNodeOperation(String label
, IUndoContext undoContext
,
56 ITreeNode parentNode
, TaxonNameBase
<?
, ?
> name
, IPostOperationEnabled postOperationEnabled
,
57 IConversationEnabled conversationEnabled
) {
58 super(label
, undoContext
, parentNode
, postOperationEnabled
, conversationEnabled
);
60 newTaxon
= Taxon
.NewInstance(name
, null);
64 * Add a taxon to a taxonomic tree
68 * @param parentNodeUuid
70 * @param postOperationEnabled
72 public CreateTaxonNodeOperation(String label
, IUndoContext undoContext
,
73 ITreeNode parentNode
, Taxon taxon
, IPostOperationEnabled postOperationEnabled
,
74 IConversationEnabled conversationEnabled
) {
75 super(label
, undoContext
, parentNode
, postOperationEnabled
, conversationEnabled
);
77 this.newTaxon
= taxon
;
82 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
86 throws ExecutionException
{
88 // Start the main progress monitor.
89 IProgressMonitor newMonitor
= StoreUtil
.startMainMonitor(monitor
,"Creating Taxon Node", 3);
97 newTaxon
.setSec(parentNode
.getReference());
98 StoreUtil
.isCanceled(newMonitor
, 1);
101 childTaxonNode
= parentNode
.addChildTaxon(newTaxon
, parentNode
.getReference(), parentNode
.getMicroReference(), null);
102 StoreUtil
.isCanceled(newMonitor
, 1);
106 // Stop the progress monitor.
110 return postExecute(childTaxonNode
);
114 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
117 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
118 throws ExecutionException
{
119 return execute(monitor
, info
);
123 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
126 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
127 throws ExecutionException
{
129 logger
.warn("Not yet implemented.");