1 |
e8409423
|
n.hoffmann
|
// $Id$
|
2 |
|
|
/**
|
3 |
|
|
* Copyright (C) 2007 EDIT
|
4 |
f6a8dc56
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
5 |
e8409423
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
6 |
f6a8dc56
|
Patric Plitzner
|
*
|
7 |
e8409423
|
n.hoffmann
|
* 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.
|
9 |
|
|
*/
|
10 |
|
|
|
11 |
35861667
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.operation;
|
12 |
e8409423
|
n.hoffmann
|
|
13 |
|
|
import org.eclipse.core.commands.operations.IUndoContext;
|
14 |
3aa58b57
|
n.hoffmann
|
import org.eclipse.core.runtime.Assert;
|
15 |
e8409423
|
n.hoffmann
|
import org.eclipse.core.runtime.IStatus;
|
16 |
|
|
|
17 |
|
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
18 |
|
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
19 |
f6a8dc56
|
Patric Plitzner
|
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
20 |
78140a75
|
n.hoffmann
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
21 |
e8409423
|
n.hoffmann
|
|
22 |
|
|
/**
|
23 |
3aa58b57
|
n.hoffmann
|
* Superclass for all operation that have to be committed imediately after execution.
|
24 |
3be6ef3e
|
n.hoffmann
|
*
|
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 |
3aa58b57
|
n.hoffmann
|
* {@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.
|
28 |
3be6ef3e
|
n.hoffmann
|
*
|
29 |
e8409423
|
n.hoffmann
|
* @author n.hoffmann
|
30 |
|
|
* @created 08.05.2009
|
31 |
|
|
* @version 1.0
|
32 |
|
|
*/
|
33 |
343457b6
|
Patric Plitzner
|
public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonOperation {
|
34 |
e8409423
|
n.hoffmann
|
private IConversationEnabled conversationEnabled;
|
35 |
f6a8dc56
|
Patric Plitzner
|
|
36 |
|
|
protected ITaxonTreeNode parentNode;
|
37 |
|
|
|
38 |
78140a75
|
n.hoffmann
|
/**
|
39 |
3be6ef3e
|
n.hoffmann
|
* <p>Constructor for AbstractPersistentPostOperation.</p>
|
40 |
|
|
*
|
41 |
|
|
* @param label a {@link java.lang.String} object.
|
42 |
|
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
43 |
35861667
|
n.hoffmann
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
44 |
3be6ef3e
|
n.hoffmann
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
45 |
78140a75
|
n.hoffmann
|
*/
|
46 |
|
|
protected AbstractPersistentPostOperation(String label, IUndoContext undoContext,
|
47 |
|
|
IPostOperationEnabled postOperationEnabled,
|
48 |
|
|
IConversationEnabled conversationEnabled) {
|
49 |
|
|
super(label, undoContext, postOperationEnabled);
|
50 |
|
|
this.conversationEnabled = conversationEnabled;
|
51 |
|
|
}
|
52 |
f6a8dc56
|
Patric Plitzner
|
|
53 |
e8409423
|
n.hoffmann
|
/**
|
54 |
3be6ef3e
|
n.hoffmann
|
* <p>Constructor for AbstractPersistentPostOperation.</p>
|
55 |
|
|
*
|
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 |
35861667
|
n.hoffmann
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
60 |
3be6ef3e
|
n.hoffmann
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
61 |
e8409423
|
n.hoffmann
|
*/
|
62 |
|
|
public AbstractPersistentPostOperation(String label,
|
63 |
78140a75
|
n.hoffmann
|
IUndoContext undoContext, TaxonNode taxonNode,
|
64 |
|
|
IPostOperationEnabled postOperationEnabled,
|
65 |
|
|
IConversationEnabled conversationEnabled) {
|
66 |
|
|
super(label, undoContext, taxonNode, postOperationEnabled);
|
67 |
|
|
this.conversationEnabled = conversationEnabled;
|
68 |
e8409423
|
n.hoffmann
|
}
|
69 |
f6a8dc56
|
Patric Plitzner
|
|
70 |
78140a75
|
n.hoffmann
|
/**
|
71 |
3be6ef3e
|
n.hoffmann
|
* <p>Constructor for AbstractPersistentPostOperation.</p>
|
72 |
|
|
*
|
73 |
|
|
* @param label a {@link java.lang.String} object.
|
74 |
|
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
75 |
35861667
|
n.hoffmann
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
76 |
3be6ef3e
|
n.hoffmann
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
77 |
f6a8dc56
|
Patric Plitzner
|
* @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
|
78 |
78140a75
|
n.hoffmann
|
*/
|
79 |
e8409423
|
n.hoffmann
|
public AbstractPersistentPostOperation(String label,
|
80 |
f6a8dc56
|
Patric Plitzner
|
IUndoContext undoContext, ITaxonTreeNode parentNode,
|
81 |
78140a75
|
n.hoffmann
|
IPostOperationEnabled postOperationEnabled,
|
82 |
e8409423
|
n.hoffmann
|
IConversationEnabled conversationEnabled) {
|
83 |
78140a75
|
n.hoffmann
|
super(label, undoContext, postOperationEnabled);
|
84 |
|
|
this.parentNode = parentNode;
|
85 |
e8409423
|
n.hoffmann
|
this.conversationEnabled = conversationEnabled;
|
86 |
|
|
}
|
87 |
|
|
|
88 |
78140a75
|
n.hoffmann
|
/* (non-Javadoc)
|
89 |
|
|
* @see eu.etaxonomy.taxeditor.operations.AbstractPostOperation#postExecute(eu.etaxonomy.cdm.model.common.CdmBase)
|
90 |
|
|
*/
|
91 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
92 |
f6a8dc56
|
Patric Plitzner
|
@Override
|
93 |
|
|
protected IStatus postExecute(CdmBase objectAffectedByOperation) {
|
94 |
3aa58b57
|
n.hoffmann
|
Assert.isNotNull(conversationEnabled, "Operation has to have a valid conversation attached.");
|
95 |
f6a8dc56
|
Patric Plitzner
|
|
96 |
d43de9c0
|
Katja Luther
|
|
97 |
|
|
if (!conversationEnabled.getConversationHolder().isClosed()){
|
98 |
83117514
|
Katja Luther
|
conversationEnabled.getConversationHolder().bind();
|
99 |
d43de9c0
|
Katja Luther
|
conversationEnabled.getConversationHolder().commit(true);
|
100 |
|
|
}
|
101 |
b455bf12
|
n.hoffmann
|
IStatus status = super.postExecute(objectAffectedByOperation);
|
102 |
f6a8dc56
|
Patric Plitzner
|
|
103 |
e8409423
|
n.hoffmann
|
return status;
|
104 |
|
|
}
|
105 |
f6a8dc56
|
Patric Plitzner
|
|
106 |
3aa58b57
|
n.hoffmann
|
/**
|
107 |
|
|
* Binds the conversation that was attached to this operation.
|
108 |
|
|
*/
|
109 |
|
|
public void bind(){
|
110 |
f6a8dc56
|
Patric Plitzner
|
conversationEnabled.getConversationHolder().bind();
|
111 |
3aa58b57
|
n.hoffmann
|
}
|
112 |
e8409423
|
n.hoffmann
|
|
113 |
|
|
}
|