Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Keeping external ecore files in Sync with Session
Keeping external ecore files in Sync with Session [message #1743029] Fri, 09 September 2016 17:17 Go to next message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
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 21:20 Go to previous message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
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?
Previous Topic:Change Context silently fails when navigating to EObject in different resource
Next Topic:The protective zone around the node when inserting
Goto Forum:
  


Current Time: Thu Apr 25 15:02:20 GMT 2024

Powered by FUDForum. Page generated in 0.02755 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top