Keeping external ecore files in Sync with Session [message #1743029] |
Fri, 09 September 2016 13:17  |
Eclipse User |
|
|
|
Hi,
for my Sirius application I want to use some external 'databases', which are ecore xmi files of previously created models stored somewhere in the classpath.
In order to use them in a current sirius model I need them to be loaded and kept in sync.
I kinda managed to do this, but I'm not sure wether this is an appropriate way, because I encountered some strange behaviour.
Here is what I did:
I added my external ecore file to the session of the current model with an org.eclipse.sirius.tools.api.command.semantic.AddSemanticResourceCommand and then set the root of this external semantic resource as reference to an model element of my sirius diagram.
To check wether my model is kept in sync with the external file I used the generated default emf Editor (treeviewer).
When I change some properties in the generated default emf Editor the ecore file gets updated as expected and vice versa , if I change some properties in the ecore file (text) and reopen the generated default emf Editor, the changes are updated aswell.
But for some reason sirius won't display the changes. For example, if I remove an element, the default editor won't display it anymore, but in the sirius tree viewer in the eclipse model explorer still shows it, even if I refresh it. The same applies for all sirius diagrams.
It seems I need to trigger a refresh somewhere, but I don't know where exactly.
How can I handle synchronization with external ecore files properly?
Thanks in advance
|
|
|
Re: Keeping external ecore files in Sync with Session [message #1743085 is a reply to message #1743029] |
Sun, 11 September 2016 17:20  |
Eclipse User |
|
|
|
I solved it by reloading the external semantic resource itself. But i don't know if it is the right approach.
In order to include changes made to the resource outside of sirius, the semantic resources need to be unloaded first and then reloaded afterwards.
SessionManager.INSTANCE.getSession(element).getSemanticResources().forEach(resource ->{
resource.unload();
resource.load(null);
});
The reason why the default emf editor takes external changes into account seems to be an IResourceChangeListener which it instantiates. I will add one myself, unless there is already a solution provided by sirius?
|
|
|
Powered by
FUDForum. Page generated in 0.02752 seconds