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
.session
.ICdmEntitySessionEnabled
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 * <p>CreateTaxonNodeOperation class.</p>
39 @Deprecated // we do not undo creation of elements
40 public class CreateTaxonNode
extends AbstractPersistentPostOperation
{
42 private final Taxon newTaxon
;
44 private TaxonNode childTaxonNode
;
47 * Add a name to a taxonomic tree
49 * @param label a {@link java.lang.String} object.
50 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
51 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
52 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
53 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
54 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
56 public CreateTaxonNode(String label
,
57 IUndoContext undoContext
,
58 ITaxonTreeNode parentNode
, TaxonNameBase
<?
, ?
> name
,
59 IPostOperationEnabled postOperationEnabled
,
60 IConversationEnabled conversationEnabled
,
61 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
62 super(label
, undoContext
, parentNode
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
64 newTaxon
= Taxon
.NewInstance(name
, null);
68 * Add a taxon to a taxonomic tree
70 * @param label a {@link java.lang.String} object.
71 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
72 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
73 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
74 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
75 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
77 public CreateTaxonNode(String label
,
78 IUndoContext undoContext
,
79 ITaxonTreeNode parentNode
,
81 IPostOperationEnabled postOperationEnabled
,
82 IConversationEnabled conversationEnabled
,
83 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
84 super(label
, undoContext
, parentNode
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
86 this.newTaxon
= taxon
;
91 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
95 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
96 throws ExecutionException
{
102 childTaxonNode
= parentNode
.addChildTaxon(newTaxon
, parentNode
.getReference(), parentNode
.getMicroReference());
106 CdmStore
.getService(ITaxonNodeService
.class).saveOrUpdate(childTaxonNode
);
108 return postExecute(childTaxonNode
);
110 MessagingUtils
.messageDialog("Could not create taxon node", getClass(), e
.getLocalizedMessage(), e
);
111 return Status
.CANCEL_STATUS
;
116 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
120 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
121 throws ExecutionException
{
122 return execute(monitor
, info
);
126 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
130 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
131 throws ExecutionException
{
133 MessagingUtils
.warn(this.getClass(), "Not yet implemented.");