Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Synchronize file resource with memory resource
Synchronize file resource with memory resource [message #533191] Wed, 12 May 2010 14:19 Go to next message
zzett  is currently offline zzett Friend
Messages: 8
Registered: May 2010
Junior Member
I have a Resource in form of an Ecore file containing a certain model.

In my program, I load the contents of this resource with
Resource model = resourceSet.getResource(uri, true);
If I understand it right, a copy of the model is made in memory.

Now, when I open the Ecore file in an editor during the program is running, making changes and save it, the changes are not seen in the model until the file is loaded again in my program. How can i synchronize the model in the file with the model in memory?

Thanks
Re: Synchronize file resource with memory resource [message #533236 is a reply to message #533191] Wed, 12 May 2010 16:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Have a look at the generated editor. In particular at the
resourceChangeListener and how it processes deltas to unload and reload
resources.

zzett wrote:
> I have a Resource in form of an Ecore file containing a certain model.
> In my program, I load the contents of this resource with Resource
> model = resourceSet.getResource(uri, true); If I understand it right,
> a copy of the model is made in memory.
>
> Now, when I open the Ecore file in an editor during the program is
> running, making changes and save it, the changes are not seen in the
> model until the file is loaded again in my program. How can i
> synchronize the model in the file with the model in memory?
>
> Thanks


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Synchronize file resource with memory resource [message #533852 is a reply to message #533191] Mon, 17 May 2010 09:46 Go to previous messageGo to next message
zzett  is currently offline zzett Friend
Messages: 8
Registered: May 2010
Junior Member
I'm not sure if this helps me, but I found something similar.

If a change in the editor is processed a command is created and executed. Would it be possible to add a CommandStackListener to the editor, catch the commands and execute them on another resource instance?
Re: Synchronize file resource with memory resource [message #533864 is a reply to message #533852] Mon, 17 May 2010 10:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
The commands all refer to objects in the editor's clone/instance of the
model. It wouldn't be easy to map those to your version. You'd be
better off sharing the editor's version if you want a live copy.
Otherwise, you should wait until the user saves the changes because
until that point, they could close the editor without saving it...

zzett wrote:
> I'm not sure if this helps me, but I found something similar.
>
> If a change in the editor is processed a command is created and
> executed. Would it be possible to add a CommandStackListener to the
> editor, catch the commands and execute them on another resource instance?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Synchronize file resource with memory resource [message #533890 is a reply to message #533191] Mon, 17 May 2010 12:08 Go to previous messageGo to next message
zzett  is currently offline zzett Friend
Messages: 8
Registered: May 2010
Junior Member
Let's say I will wait until the user saves the changes. Would EMF Compare a possible solution for merging the differences of the resource from the editor with my resources in memory?
Re: Synchronize file resource with memory resource [message #533907 is a reply to message #533890] Mon, 17 May 2010 12:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
You could load a new instance and compare it against the one you have in
memory from earlier, yes.


zzett wrote:
> Let's say I will wait until the user saves the changes. Would EMF
> Compare a possible solution for merging the differences of the
> resource from the editor with my resources in memory?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:associate itemprovideradapter to domain element
Next Topic:ecore2ecore
Goto Forum:
  


Current Time: Wed Apr 24 20:07:31 GMT 2024

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

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

Back to the top