2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.navigation
.operation
;
11 import org
.eclipse
.core
.commands
.ExecutionException
;
12 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
13 import org
.eclipse
.core
.runtime
.IAdaptable
;
14 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.core
.runtime
.Status
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
19 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
23 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
24 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
25 import eu
.etaxonomy
.taxeditor
.navigation
.l10n
.Messages
;
26 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
27 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
28 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 * <p>CreateTaxonNodeOperation class.</p>
37 @Deprecated // we do not undo creation of elements
38 public class CreateTaxonNode
extends AbstractPersistentPostOperation
{
40 private final Taxon newTaxon
;
42 private TaxonNode childTaxonNode
;
45 * Add a name to a taxonomic tree
47 * @param label a {@link java.lang.String} object.
48 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
49 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
50 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
51 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
52 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
54 public CreateTaxonNode(String label
,
55 IUndoContext undoContext
,
56 TaxonNodeDto parentNode
, TaxonName name
,
57 IPostOperationEnabled postOperationEnabled
,
58 IConversationEnabled conversationEnabled
,
59 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
60 super(label
, undoContext
, parentNode
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
62 newTaxon
= Taxon
.NewInstance(name
, null);
66 * Add a taxon to a taxonomic tree
68 * @param label a {@link java.lang.String} object.
69 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
70 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
71 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
72 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
73 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
75 public CreateTaxonNode(String label
,
76 IUndoContext undoContext
,
77 TaxonNodeDto parentNode
,
79 IPostOperationEnabled postOperationEnabled
,
80 IConversationEnabled conversationEnabled
,
81 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
82 super(label
, undoContext
, parentNode
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
84 this.newTaxon
= taxon
;
88 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
89 throws ExecutionException
{
95 TaxonNode node
= CdmStore
.getService(ITaxonNodeService
.class).find(parentNode
.getUuid());
96 childTaxonNode
= node
.addChildTaxon(newTaxon
, node
.getReference(), node
.getMicroReference());
100 CdmStore
.getService(ITaxonNodeService
.class).saveOrUpdate(childTaxonNode
);
102 return postExecute(childTaxonNode
);
104 MessagingUtils
.messageDialog(Messages
.CreateTaxonNode_CREATE_FAILED
, getClass(), e
.getLocalizedMessage(), e
);
105 return Status
.CANCEL_STATUS
;
110 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
111 throws ExecutionException
{
112 return execute(monitor
, info
);
116 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
117 throws ExecutionException
{
119 MessagingUtils
.warn(this.getClass(), "Not yet implemented."); //$NON-NLS-1$