Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319002 - [backbone service] EditorUtils.getTransactionalEditingDomain() can return null
Summary: [backbone service] EditorUtils.getTransactionalEditingDomain() can return null
Status: CLOSED INVALID
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Cedric Dumoulin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 319267
Blocks:
  Show dependency tree
 
Reported: 2010-07-06 08:55 EDT by Patrick Tessier CLA
Modified: 2013-04-10 13:45 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Tessier CLA 2010-07-06 08:55:59 EDT
Hi Cédric,
I m back with a problem about  this method:

EditorUtils.getTransactionalEditingDomain()

When the editor is not active ( during initialization ) this method returns null. It looks for thanks to the active editor.

We have had this problem it the case of model explorer or in other class like this:

org.eclipse.papyrus.diagram.common.helper.PreferenceInitializerForElementHelper

I wonder if there is no means to avoid that his method return no null during the initialization of Papyrus. Because I think that backbone is already alive.
Comment 1 Cedric Dumoulin CLA 2010-07-06 09:14:41 EDT
This method return null because it rely on Workbench.getActiveEditor(), and there is no active editor :-(. The active editor is set after the initialization phase, so you can't get it during the initialization phase.

The solution is to provide ourself the ServiceRegistry whenever it is possible.

I have improve the documentation around this method, that is designed to be used in ui actions interacting on the currently opened editor and not in initialization phase.
Comment 2 Cedric Dumoulin CLA 2010-07-07 09:56:03 EDT
Class /org.eclipse.papyrus.diagram.common/src/org/eclipse/papyrus/diagram/common/util/DiagramCoreServiceUtils.java
has been added.
It provides methods to get the ServiceRegistry and the TransactionalEditingDomain from a GMF EditPart and EditPolicy.
This method should be used instead of the method from EditorUtils.
Comment 3 Camille Letavernier CLA 2013-04-10 13:45:48 EDT
I close this task