Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Automatic Modification Tracking does not work
Automatic Modification Tracking does not work [message #416249] Wed, 23 January 2008 14:48 Go to next message
Tobias Langner is currently offline Tobias LangnerFriend
Messages: 17
Registered: July 2009
Junior Member
Hey,
I'd like to be able to display a dialog, that shows users which resources
(ecore-files) they have modified since the last save action. To do this, I
overrode the method createModel in EcoreEditor and added the following statement
at the end

for (Resource resource : editingDomain.getResourceSet().getResources())
resource.setTrackingModification(true);

in order to enable automatic modification tracking for all resources.

However, when I change something in the model (e.g. deleting an EClass in a
package) and iterate over all resources again in doSave, none of the respective
resources isModified().

What is the problem with my approach? How can I find out which resources have
been modified?

Thanks in advance, cheers,

Tobias
Re: Automatic Modification Tracking does not work [message #416252 is a reply to message #416249] Wed, 23 January 2008 15:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Tobias,

Comments below.


Tobias Langner wrote:
> Hey,
> I'd like to be able to display a dialog, that shows users which resources
> (ecore-files) they have modified since the last save action. To do this, I
> overrode the method createModel in EcoreEditor and added the following statement
> at the end
>
> for (Resource resource : editingDomain.getResourceSet().getResources())
> resource.setTrackingModification(true);
>
> in order to enable automatic modification tracking for all resources.
>
Resources are loaded on demand and this will set the flag only for the
already loaded resource, which might only be the first one. You might
add an adapter to the resource set that listens for resources being
added and sets this flag for any added resource.
> However, when I change something in the model (e.g. deleting an EClass in a
> package) and iterate over all resources again in doSave, none of the respective
> resources isModified().
>
Maybe there are more resources this time around?
> What is the problem with my approach? How can I find out which resources have
> been modified?
>
One thing this will miss is the fact that a resource might be changed
(at least in terms of how it's serialized) if, for example, you move a
class it references from one resource to another.
> Thanks in advance, cheers,
>
> Tobias
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Automatic Modification Tracking does not work [message #416260 is a reply to message #416252] Wed, 23 January 2008 18:43 Go to previous messageGo to next message
Tobias Langner is currently offline Tobias LangnerFriend
Messages: 17
Registered: July 2009
Junior Member
Ed,

>> I'd like to be able to display a dialog, that shows users which resources
>> (ecore-files) they have modified since the last save action. [...]
> Resources are loaded on demand and this will set the flag only for the
> already loaded resource, which might only be the first one. You might
> add an adapter to the resource set that listens for resources being
> added and sets this flag for any added resource.
That sounds like a much better solution.

> One thing this will miss is the fact that a resource might be changed
> (at least in terms of how it's serialized) if, for example, you move a
> class it references from one resource to another.
Do you see any way how I can track such modifications as well? This is very
critical for us to know, since the resource files being edited are read-only and
are only made writeable during saving. So it would be nice to know which files
have been modified at all in order to present this information to the user
before saving to let the user make the files writeable.
Re: Automatic Modification Tracking does not work [message #416261 is a reply to message #416260] Wed, 23 January 2008 19:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050605050006030402020704
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Tobias,

It's very expensive to determine in a general way whether a reference to
something has changed the URI of that reference. You can look at how
ResourceImpl.saveOnlyIfChanged works. You might just save each resource
to a byte array or to a temporary file and compare the contents of that
to the read-only contents in a byte-by-byte way and use that to know
which need saving...


Tobias Langner wrote:
> Ed,
>
>
>>> I'd like to be able to display a dialog, that shows users which resources
>>> (ecore-files) they have modified since the last save action. [...]
>>>
>> Resources are loaded on demand and this will set the flag only for the
>> already loaded resource, which might only be the first one. You might
>> add an adapter to the resource set that listens for resources being
>> added and sets this flag for any added resource.
>>
> That sounds like a much better solution.
>
>
>> One thing this will miss is the fact that a resource might be changed
>> (at least in terms of how it's serialized) if, for example, you move a
>> class it references from one resource to another.
>>
> Do you see any way how I can track such modifications as well? This is very
> critical for us to know, since the resource files being edited are read-only and
> are only made writeable during saving. So it would be nice to know which files
> have been modified at all in order to present this information to the user
> before saving to let the user make the files writeable.
>


--------------050605050006030402020704
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Tobias,<br>
<br>
It's very expensive to determine in a general way whether a reference
to something has changed the URI of that reference.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:RemoveCommand multiple executions
Next Topic:How to retrieve a shiny model element icon from its meta element ?
Goto Forum:
  


Current Time: Thu Apr 18 00:51:17 GMT 2024

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

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

Back to the top