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
.operation
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.Assert
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
18 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.ITreeNode
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
23 * Superclass for all operation that have to be committed imediately after execution.
25 * Note: You have to call the {@link #bind()} method in the {@link #execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)},
26 * {@link #undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)} and {@link #redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}
27 * methods so the correct persistence context gets bound.
33 public abstract class AbstractPersistentPostOperation
extends AbstractPostOperation
{
34 private IConversationEnabled conversationEnabled
;
36 protected ITreeNode parentNode
;
39 * <p>Constructor for AbstractPersistentPostOperation.</p>
41 * @param label a {@link java.lang.String} object.
42 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
43 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
44 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
46 protected AbstractPersistentPostOperation(String label
, IUndoContext undoContext
,
47 IPostOperationEnabled postOperationEnabled
,
48 IConversationEnabled conversationEnabled
) {
49 super(label
, undoContext
, postOperationEnabled
);
50 this.conversationEnabled
= conversationEnabled
;
54 * <p>Constructor for AbstractPersistentPostOperation.</p>
56 * @param label a {@link java.lang.String} object.
57 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
58 * @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
59 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
60 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
62 public AbstractPersistentPostOperation(String label
,
63 IUndoContext undoContext
, TaxonNode taxonNode
,
64 IPostOperationEnabled postOperationEnabled
,
65 IConversationEnabled conversationEnabled
) {
66 super(label
, undoContext
, taxonNode
, postOperationEnabled
);
67 this.conversationEnabled
= conversationEnabled
;
71 * <p>Constructor for AbstractPersistentPostOperation.</p>
73 * @param label a {@link java.lang.String} object.
74 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
75 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
76 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
77 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
79 public AbstractPersistentPostOperation(String label
,
80 IUndoContext undoContext
, ITreeNode parentNode
,
81 IPostOperationEnabled postOperationEnabled
,
82 IConversationEnabled conversationEnabled
) {
83 super(label
, undoContext
, postOperationEnabled
);
84 this.parentNode
= parentNode
;
85 this.conversationEnabled
= conversationEnabled
;
89 * @see eu.etaxonomy.taxeditor.operations.AbstractPostOperation#postExecute(eu.etaxonomy.cdm.model.common.CdmBase)
92 protected IStatus
postExecute(CdmBase objectAffectedByOperation
) {
93 Assert
.isNotNull(conversationEnabled
, "Operation has to have a valid conversation attached.");
95 conversationEnabled
.getConversationHolder().commit(true);
97 IStatus status
= super.postExecute(objectAffectedByOperation
);
103 * Binds the conversation that was attached to this operation.
106 conversationEnabled
.getConversationHolder().bind();