Getting a ServiceRegistry for an EMF Resource [message #1455873] |
Wed, 29 October 2014 17:11  |
Eclipse User |
|
|
|
My objective is to attach a ResourceSetListener to Papyrus TransactionalEditDomain. I read the available documentation on the topic.
I concluded that I needed a ServiceRegistry to get a TransactionalEditDomain.
I try to get a ServiceRegistry for an EMF resource using a ServiceUtilsForResource:
Here is the code:
ServiceUtilsForResource serviceUtils = ServiceUtilsForResource.getInstance();
serviceUtils.getServiceRegistry(emfResource());
I got the following exception message (ServiceNotFoundException):
The resource set was not initialized as a service.
I guess the ResourceSet attached to the EMF Resource was not built the proper way.
I have two problems here:
- How to create properly a ResourceSet (recognized by Papyrus) ?
- Is my approach correct for getting the TransactionalEditDomain of a Papyrus editor from an external plugin ?
|
|
|
|
|
Re: Getting a ServiceRegistry for an EMF Resource [message #1464032 is a reply to message #1457975] |
Fri, 07 November 2014 00:30  |
Eclipse User |
|
|
|
Hi,
A ResourceSetListener is intended for reacting to changes in the UML
model, but it seems that you want to change the model according to
refactorings of Java code. So ResourceSetListener doesn't really enter
the picture.
If you know which are the UML model resource that needs to be updated
for the Java refactoring, then you can (a) check whether there is
currently a Papyrus editor open on that resource and (b) if so, access
its service registry (the editor provides an adapter of type
ServicesRegistry via the IAdaptable protocol) or (c) if an editor is
not open, just load the resource in a simple ResourceSet and modify it.
No need for any TransactionalEditingDomains or editors in that case.
HTH,
Christian
On 2014-10-31 22:54:26 +0000, Bérenger Bérenger said:
> Thank you for your answer.
>
> I have an UML model which elements are linked to Java elements. I try
> to propagate change applied on the model with JDT refactorings (mainly
> renaming). Initially the project used Eclipse UML2Tools which seems to
> be discontinued for years (I have been quite busy lately and my plugin
> needs to be refactored).
>
> I adapt my plugin to work with other editors. Papyrus by the way it the
> new editor supported by the Eclipse foundation. The best approach
> seems to be a ResourceSetListener. At first glance it seems to remove a
> direct dependency on the editor used on the model. For that I need the
> TransactionalEditDomain. Following
> http://download.eclipse.org/modeling/emf/transaction/javadoc/1.1.1/org/eclipse/emf/transaction/TransactionalEditingDomain.html,
> I first thought that the TransactionalEditDomain should be available
> via the Registry (this seems to be the preferred web for sharing the
> edit domain with other applications).
>
> I noticed that modifications on the UML model in the UML2 tree editor
> propagates changes in the Papyrus class diagram editor, and vice-versa.
> I thought that changes where propagated by such a listener.
>
> But as I understand, this is not possible to get the
> TransactionalEditDomain without an access on the editor. The
> ServiceRegistry holds the TransactionalEditDomain and it is linked with
> the Papyrus editor.
>
> So I should generate programmatically the Papyrus diagram file from my
> UML model, open an editor and retrieve the TransactionalEditingDomain
> from that editor ? Is there no simpler way for getting it ? The process
> for generating the diagram file seems to be rather complex...
|
|
|
Powered by
FUDForum. Page generated in 0.03735 seconds