Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Handling saving/ dirty state over multiple files
Handling saving/ dirty state over multiple files [message #651797] Tue, 01 February 2011 16:08 Go to next message
philipp huebner is currently offline philipp huebnerFriend
Messages: 48
Registered: July 2009
Member
Hi folks,
we are working on a emf editor based on a relatively simply model. Now we have the requirement to expand the dirty state on another file.
This is because of we import data into our model and want to handle it transient, but when sth of the data is changed the data should be saved back into the formerly loaded file.
Is there sth build in in EMF to handle this use-case or do we have to realize this by our own ?

Thank you...
Re: Handling saving/ dirty state over multiple files [message #651800 is a reply to message #651797] Tue, 01 February 2011 16:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040700000303020801080909
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Philipp,

Does this option help?

/**
* A save option that can be used only with {@link #save(Map)}
* to specify that the resource is to be saved only if the new
contents
* are different from actual contents;
* this compares the bytes in the backing store against the new
bytes that would be saved.
* The value on this option can be either <code>null</code>,
* {@link #OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER},
* or {@link #OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER}.
* @since 2.3
*/
String OPTION_SAVE_ONLY_IF_CHANGED = "SAVE_ONLY_IF_CHANGED";

Resource.setTrackingModification might help too...


philipp huebner wrote:
> Hi folks,
> we are working on a emf editor based on a relatively simply model.
> Now we have the requirement to expand the dirty state on another file.
> This is because of we import data into our model and want to handle
> it transient, but when sth of the data is changed the data should be
> saved back into the formerly loaded file.
> Is there sth build in in EMF to handle this use-case or do we have to
> realize this by our own ?
>
> Thank you...

--------------040700000303020801080909
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Philipp,<br>
<br>
Does this option help?<br>
<blockquote><small>  /**</small><br>
<small>   * A save option that can be used only with {@link
#save(Map)}</small><br>
<small>   * to specify that the resource is to be saved only if the
new contents</small><br>
<small>   * are different from actual contents; </small><br>
<small>   * this compares the bytes in the backing store against the
new bytes that would be saved.</small><br>
<small>   * The value on this option can be either
&lt;code&gt;null&lt;/code&gt;, </small><br>
<small>   * {@link #OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER},</small><br>
<small>   * or {@link #OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER}.</small><br>
<small>   * @since 2.3</small><br>
<small>   */  </small><br>
<small>  String OPTION_SAVE_ONLY_IF_CHANGED = "SAVE_ONLY_IF_CHANGED";</small><br>
</blockquote>
Resource.setTrackingModification might help too...<br>
<br>
<br>
philipp huebner wrote:
<blockquote cite="mid:ii9aqt$d2i$1@news.eclipse.org" type="cite">Hi
folks,
<br>
we are working on a emf  editor based on a relatively simply model. 
Now we have the requirement to expand the dirty state on another file.
This is  because of we import data into our model and want to handle it
transient, but when sth of the data is changed the data should be saved
back into the formerly loaded file.
<br>
Is there sth build in in EMF to handle this use-case or do we have to
realize this by our own ?
<br>
<br>
Thank you...
<br>
</blockquote>
</body>
</html>

--------------040700000303020801080909--
Re: Handling saving/ dirty state over multiple files [message #651808 is a reply to message #651800] Tue, 01 February 2011 17:00 Go to previous messageGo to next message
philipp huebner is currently offline philipp huebnerFriend
Messages: 48
Registered: July 2009
Member
hmm...i don't understand this exactly.
It seems to me that these flags can be used for controlling the saving of models to multiple .ecore ressources. I have only the ressource of my base model into which i import the data from a non-emf file (for example a plain .txt file).
After modifing the data in my editor, i need a functionality to serialize my data with a specilized writer into that file back.
Perhaps there is a possibility to track which part of the model is dirty; so that i can overwrite the doSave method and handle the saving of the impported data by my own ....
Re: Handling saving/ dirty state over multiple files [message #651849 is a reply to message #651808] Tue, 01 February 2011 18:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Philipp,

Comments below.

philipp huebner wrote:
> hmm...i don't understand this exactly.
> It seems to me that these flags can be used for controlling the saving
> of models to multiple .ecore ressources.
They're general to all resources, not just to *.ecore ones...
> I have only the ressource of my base model into which i import the
> data from a non-emf file (for example a plain .txt file).
Import meaning? You specialized ResourceImpl.doLoad?
> After modifing the data in my editor, i need a functionality to
> serialize my data with a specilized writer into that file back.
You could specialize ResourceImpl.doSave.
> Perhaps there is a possibility to track which part of the model is
> dirty; so that i can overwrite the doSave method and handle the saving
> of the impported data by my own ....
It would seem better for there to be one resource per file so you can
specialize doLoad/doSave for each one...
Re: Handling saving/ dirty state over multiple files [message #651939 is a reply to message #651849] Wed, 02 February 2011 07:28 Go to previous messageGo to next message
philipp huebner is currently offline philipp huebnerFriend
Messages: 48
Registered: July 2009
Member
OK...I thought resource is just for ecore files....eh no; we haven't specialized ResourceImpl.doLoad; we traverse the data and build our emf structures.
So I have to find out how I can map these files as resources into our model and specialize the doSave/doLoad method .... Ok this gives me a hint; thx.
(It's amazing how you reply, Ed ... this is really great)
Re: Handling saving/ dirty state over multiple files [message #652042 is a reply to message #651939] Wed, 02 February 2011 13:59 Go to previous messageGo to next message
philipp huebner is currently offline philipp huebnerFriend
Messages: 48
Registered: July 2009
Member
So.... I've been googling around for the whole day and couldn't find anything.
I want to define sth like a custom ressource to overwrite doLoad and doSave but I could't find anything. How can I include a custom ressource into my model or anything....
Re: Handling saving/ dirty state over multiple files [message #652196 is a reply to message #652042] Thu, 03 February 2011 00:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Philipp,

You extend ResourceImpl, define an extended ResourceFactoryImpl for
creating it, register that in your plugin.xml, and then focus on
implementing doSave/doLoad. Setting the GenPackage's Resource Type
property to Basic will produce the scaffolding I just described.


philipp huebner wrote:
> So.... I've been googling around for the whole day and couldn't find
> anything.
> I want to define sth like a custom ressource to overwrite doLoad and
> doSave but I could't find anything. How can I include a custom
> ressource into my model or anything....
Re: Handling saving/ dirty state over multiple files [message #652280 is a reply to message #652196] Thu, 03 February 2011 12:55 Go to previous messageGo to next message
philipp huebner is currently offline philipp huebnerFriend
Messages: 48
Registered: July 2009
Member
Thanks for you reply . I love emf and hates its very frustrating lack of documentation...

You extend ResourceImpl, define an extended ResourceFactoryImpl for
creating it,

- Ok I extend my these types, and create my factory ...

register that in your plugin.xml,

- at which ep? factory_overwrite? But there i could read sth about .ecore models; It want a uri to a model def. i don't have ....

GenPackage's Resource Type?

What? Which flag in which node? Can I mix the models with that construction; so that the dirty state is handled automatically over the diferent resources?
Re: Handling saving/ dirty state over multiple files [message #652330 is a reply to message #652280] Thu, 03 February 2011 15:36 Go to previous messageGo to next message
philipp huebner is currently offline philipp huebnerFriend
Messages: 48
Registered: July 2009
Member
ok after many hours knopcking my head against the wall i got sth .... i implemented my resource and factory; but how can i create a model, add this model as a child to a node in my main model and seralize it by resource doLoad() .... Excuse my dump questiomns but this is really a hard struggle without examples or anything ...
Re: Handling saving/ dirty state over multiple files [message #652420 is a reply to message #652280] Thu, 03 February 2011 19:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Philipp,

Comments below.

philipp huebner wrote:
> Thanks for you reply . I love emf and hates its very frustrating lack
> of documentation...
Have you bought and read the book?
>
> You extend ResourceImpl, define an extended ResourceFactoryImpl for
> creating it,
> - Ok I extend my these types, and create my factory ...
> register that in your plugin.xml,
>
> - at which ep? factory_overwrite? But there i could read sth about
> .ecore models; It want a uri to a model def. i don't have ....
I don't get the sense you've read all that much of the documentation.
>
> GenPackage's Resource Type?
When you open your GenModel in the Generator, GenPackages are the
objects nested one level under the root GenModel.
>
> What? Which flag in which node? Can I mix the models with that
> construction; so that the dirty state is handled automatically over
> the diferent resources?
In the basic generated editors, dirty state is handled by the state of
the command stack. Dirtiness of individual resources isn't track.
That's why options like the one I mentioned exist.
Re: Handling saving/ dirty state over multiple files [message #652423 is a reply to message #652330] Thu, 03 February 2011 19:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Philipp,

Comments below.


philipp huebner wrote:
> ok after many hours knopcking my head against the wall i got sth ....
> i implemented my resource and factory; but how can i create a model,
How does the generated wizard do that?
> add this model as a child to a node in my main model
Is his a containment reference or a non-containment reference?
> and seralize it by resource doLoad() ....
I guess you mean deserialize.
> Excuse my dump questiomns but this is really a hard struggle without
> examples or anything ...
Previous Topic:[EMF Query 2]Issue to query in Xtext and Object format
Next Topic:none elements for CrossReferencer-Iterator
Goto Forum:
  


Current Time: Sat Oct 19 07:19:12 GMT 2019

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

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

Back to the top