Revision 51188df7
Added by Katja Luther over 7 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java | ||
---|---|---|
25 | 25 |
import org.eclipse.ui.IEditorInput; |
26 | 26 |
import org.eclipse.ui.texteditor.AbstractDocumentProvider; |
27 | 27 |
|
28 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
28 | 29 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
29 | 30 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
30 | 31 |
|
... | ... | |
58 | 59 |
private ILineDisplayStrategy lineDisplayStrategy; |
59 | 60 |
|
60 | 61 |
private final IEditorInput input; |
62 |
private ConversationHolder conversation; |
|
63 |
|
|
64 |
/** |
|
65 |
* @return the conversation |
|
66 |
*/ |
|
67 |
public ConversationHolder getConversation() { |
|
68 |
return conversation; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* @param conversation the conversation to set |
|
73 |
*/ |
|
74 |
public void setConversation(ConversationHolder conversation) { |
|
75 |
this.conversation = conversation; |
|
76 |
} |
|
61 | 77 |
|
62 | 78 |
/** |
63 | 79 |
* <p>Constructor for AnnotatedLineDocumentProvider.</p> |
... | ... | |
66 | 82 |
*/ |
67 | 83 |
public AnnotatedLineDocumentProvider(IEditorInput input){ |
68 | 84 |
this.input = input; |
85 |
this.conversation = ((AbstractBulkEditorInput)input).getConversation(); |
|
69 | 86 |
} |
70 | 87 |
|
71 | 88 |
/** {@inheritDoc} */ |
... | ... | |
232 | 249 |
// Get new containers from annotation model |
233 | 250 |
LineAnnotationModel model = (LineAnnotationModel) getAnnotationModel(element); |
234 | 251 |
Iterator iterator = model.getAnnotationIterator(); |
252 |
if (!this.conversation.isBound()){ |
|
253 |
this.conversation.bind(); |
|
254 |
} |
|
255 |
|
|
235 | 256 |
while (iterator.hasNext()) { |
236 | 257 |
Annotation annotation = (Annotation) iterator.next(); |
237 | 258 |
if (annotation instanceof IEntityContainer<?>) { |
238 | 259 |
IEntityContainer<?> container = (IEntityContainer<?>) annotation; |
260 |
|
|
239 | 261 |
if (container.isMarkedAsNew() || container.isDirty()) { |
262 |
|
|
240 | 263 |
Object entity = persistenceService.save(container.getEntity()); // save |
241 | 264 |
container.setEntity(entity); |
242 | 265 |
container.setDirty(false); |
... | ... | |
244 | 267 |
} |
245 | 268 |
} |
246 | 269 |
} |
270 |
this.conversation.commit(true); |
|
247 | 271 |
for (LineAnnotation annotation : model.getDeletedAnnotations()) { |
248 | 272 |
if (annotation.isMarkedAsNew()) { |
249 | 273 |
continue; |
Also available in: Unified diff
add session to bulk editor