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
.navigation
.operation
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.core
.runtime
.Status
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
22 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
26 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
27 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
28 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 * <p>CreateTaxonNodeOperation class.</p>
38 @Deprecated // we do not undo creation of elements
39 public class CreateTaxonNode
extends AbstractPersistentPostOperation
{
41 private Taxon newTaxon
;
43 private TaxonNode childTaxonNode
;
46 * Add a name to a taxonomic tree
48 * @param label a {@link java.lang.String} object.
49 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
50 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
51 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
52 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
53 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
55 public CreateTaxonNode(String label
, IUndoContext undoContext
,
56 ITaxonTreeNode 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
66 * @param label a {@link java.lang.String} object.
67 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
68 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
69 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
70 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
71 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
73 public CreateTaxonNode(String label
, IUndoContext undoContext
,
74 ITaxonTreeNode parentNode
, Taxon taxon
, IPostOperationEnabled postOperationEnabled
,
75 IConversationEnabled conversationEnabled
) {
76 super(label
, undoContext
, parentNode
, postOperationEnabled
, conversationEnabled
);
78 this.newTaxon
= taxon
;
83 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
88 throws ExecutionException
{
94 childTaxonNode
= parentNode
.addChildTaxon(newTaxon
, parentNode
.getReference(), parentNode
.getMicroReference());
98 CdmStore
.getService(ITaxonNodeService
.class).saveOrUpdate(childTaxonNode
);
100 return postExecute(childTaxonNode
);
102 MessagingUtils
.messageDialog("Could not create taxon node", getClass(), e
.getLocalizedMessage(), e
);
103 return Status
.CANCEL_STATUS
;
108 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
112 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
113 throws ExecutionException
{
114 return execute(monitor
, info
);
118 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
122 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
123 throws ExecutionException
{
125 MessagingUtils
.warn(this.getClass(), "Not yet implemented.");