Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319002

Summary: [backbone service] EditorUtils.getTransactionalEditingDomain() can return null
Product: [Modeling] Papyrus Reporter: Patrick Tessier <Patrick.Tessier>
Component: CoreAssignee: Cedric Dumoulin <cedric.dumoulin>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: tatiana.fesenko
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 319267    
Bug Blocks:    

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