Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Transaction] How to correctly handle changes on the file level in EMF?
[EMF Transaction] How to correctly handle changes on the file level in EMF? [message #1756269] Tue, 14 March 2017 18:19 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Suppose I have a simple model like this (Xcore syntax):

class A {
  // several attributes
  refers B[] bs

class B {
  // several attributes

Suppose I have 100 objects of type B and one object of type A. All objects are persisted via default XMI, nothing fancy.

What I now want, is:

  1. When I move the A to another folder (only inside the same project), all references to the Bs should update
  2. When I move a B to another folder inside the same project, the reference in the A should update
  3. Any "dirty" changes (only reflecting the attributes I omitted here for simplicity) the dirty state should stay, but the references in the corresponding A should update

My editors are custom, no generated EMF Edit or Xtext stuff, but they do use a global editing domain as pointed out in this tutorial.

My naive thought is the following:
- Use a listener on the editing domain that tracks when a resource is loaded / unloaded
- Use another listener that fires when a file in the workspace changes (is moved, removed etc.)
- Have that listener figure out the dependent, affected objects
- update the URIs to the new values

Is this the way to go? If yes, I have two issues about that:
1. When affected objects are not currently loaded in the editing domain, loading them when the referenced object was moved will cause errors resolving it - how to adjust the URI? Can I also have a listener fired before a resource changes in the workspace?
2. If any of the changed or affected objects is currently open in an editor and the editor is dirty, how do I handle saving the "old" state before edits and keeping the edits?

If I am completely wrong, please tell me about some more tutorials like the one I found (and posted here) I can use to figure it out.
Re: [EMF Transaction] How to correctly handle changes on the file level in EMF? [message #1756302 is a reply to message #1756269] Wed, 15 March 2017 08:54 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 32342
Registered: July 2009
Senior Member
This is definitely a complex and tricky problem. There is the possibility to register so call refactoring participants, but I don't know much about that; I'd have to Google. I don't think there are tutorials to cover this subject. And of course the underlying file system could be changed while the IDE is not running, and then the problem is even harder.

I'm not sure why you'd need a listener to know when resources are loaded and unloaded. The generated editor listens to the workspace for resource deltas and unloads and reloads resources based on processing those deltas. You could have a look at how that works. I'm not sure if EMF transaction is already automatically doing similar things. If someone changes the underlying resource in the file system/workspace will the editor is open it's not clear which change is more important to preserve.

Ed Merks
Professional Support:
Previous Topic:[EMF Forms] : EEnum ComboCellEditor in TableControl?
Next Topic:[EMF Forms]Unusual Model element creation
Goto Forum:

Current Time: Thu May 26 11:33:13 GMT 2022

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

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

Back to the top