Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Unload / Load resource does not affect the command stack ?
Unload / Load resource does not affect the command stack ? [message #418361] Mon, 14 April 2008 16:35 Go to next message
Vincent Zurczak is currently offline Vincent ZurczakFriend
Messages: 149
Registered: July 2009
Senior Member

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello.<br>
<br>
My main question is in the title, but since I'm posting on this
mailing-list, I'd like to explain what I am doing and know what you
think about it.<br>
<br>
My goal is to provide a unified EMF-based framework for a tooling I am
contributing to.<br>
This framework includes a project builder (which relies on resource
modification, an EMF meta-model and EMF validation) and a way to share
EMF models between editors. In fact, I would like to synchronize
several editors used to edit the model files. This includes text
editors, the EMF-model editor, a form-editor using EMF and even a
GMF-based editor. <br>
<br>
I have already defined the builder, it works fine. I'm now working on
the model-sharing. It consists in providing some kind of API to
retrieve a model with its editing domain (and everything required).
Every editor will have to use this <i>facade</i> to be synchronized
with the others.<br>
<br>
When a file is modified, e.g. when you save a file, the builder is
called and refreshes the main resource by using the unload / load
methods. I was expecting that EMF-based editors, which have registered
a command stack listener, would be notified of this refreshment. But
they are not. Therefore, these editors are not refreshed when the
resource is modified by another one.<br>
<br>
<br>
So here are my questions.<br>
Is it normal if the command stack is not affected by resource unloading
/ loading ? <br>
If the answer is yes, I thought I could use a Command to replace the
root element of my model. But in this case, what is the owner of the
root element of the model ? I also have to anticipate one of the things
you might tell me. When I unload my model, I don't want to flush my
command stack, since I would like to keep the undo / redo operations
independently of the resources' updates. In this case, is the use of a
command mandatory ? And how can I replace the root element of my model
by another one ? Using a compound command (first removing the old one
and then&nbsp; adding the new one) ? Is there any other solution ? Or
keeping an history in this case is just insane ?<br>
<br>
Regards,<br>
<br>
Vincent.<br>
<br>
<br>
<br>
N.B. : also, I would like to know what you think of these things
(model-sharing and EMF-based builder), in particular about the
performances. Is it worth doing this according to you ? Or keeping
every editor with its own model is better ? I mean, in general, not in
my specific need context. :)<br>
<br>
<pre class="moz-signature" cols="72">--
Vincent Zurczak
EBM WebSourcing
+ 33 (0) 4 76 61 52 62
</pre>
</body>
</html>
Re: Unload / Load resource does not affect the command stack ? [message #418362 is a reply to message #418361] Mon, 14 April 2008 16:49 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020501010408080303010704
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Vincent,

Loading and unloading are not treated as state changing modifications
that could be undone or redone. More comments below.


Vincent Zurczak wrote:
> Hello.
>
> My main question is in the title, but since I'm posting on this
> mailing-list, I'd like to explain what I am doing and know what you
> think about it.
>
> My goal is to provide a unified EMF-based framework for a tooling I am
> contributing to.
> This framework includes a project builder (which relies on resource
> modification, an EMF meta-model and EMF validation) and a way to share
> EMF models between editors. In fact, I would like to synchronize
> several editors used to edit the model files. This includes text
> editors, the EMF-model editor, a form-editor using EMF and even a
> GMF-based editor.
Shared transactional editing domains could be used for something like that.
>
> I have already defined the builder, it works fine. I'm now working on
> the model-sharing. It consists in providing some kind of API to
> retrieve a model with its editing domain (and everything required).
> Every editor will have to use this /facade/ to be synchronized with
> the others.
A shared editing domain?
>
> When a file is modified, e.g. when you save a file, the builder is
> called and refreshes the main resource by using the unload / load
> methods. I was expecting that EMF-based editors, which have registered
> a command stack listener, would be notified of this refreshment. But
> they are not. Therefore, these editors are not refreshed when the
> resource is modified by another one.
The generated editor listens to the workspace for resource deltas and
does respond to those by unloading and reloading the affects resource(s).
>
>
> So here are my questions.
> Is it normal if the command stack is not affected by resource
> unloading / loading ?
Definitely. Any data access could cause a proxy to be resolved which
could cause a resource to be loaded. That's why transactional editing
domains make read access exclusive.
> If the answer is yes, I thought I could use a Command to replace the
> root element of my model. But in this case, what is the owner of the
> root element of the model ?
The Resource is the container and you can use commands to add and remove
things from the contents list of the resource.
> I also have to anticipate one of the things you might tell me. When I
> unload my model, I don't want to flush my command stack, since I would
> like to keep the undo / redo operations independently of the
> resources' updates.
You would need to use a command then to preserve the old state. But
this is a very tricky thing, because when the resource is unloaded, all
the objects are turned into proxies so that references holding them will
resolve to the new version from then newly loaded resources. You'd need
to be able to undo all that too... Sounds very challenging.
> In this case, is the use of a command mandatory ? And how can I
> replace the root element of my model by another one ?
/**
* This constructs a primitive command to replace a particular value
in the specified extent with the given replacement.
*/
public ReplaceCommand(EditingDomain domain, EList<?> list, Object
value, Object replacement)
{
this(domain, list, value, Collections.singleton(replacement));
}

> Using a compound command (first removing the old one and then adding
> the new one) ? Is there any other solution ? Or keeping an history in
> this case is just insane ?
I wouldn't call it insane, but it's definitely a very challenging
thing. You'll want to look closely at what unload all does and be sure
to undo those things. I imagine you could put the objects back and use
InternalEObject.eSetProxyURI(null) to unproxify them, but the other
models will be pointing at the new things so you'd have to turn them
into proxies...
>
> Regards,
>
> Vincent.
>
>
>
> N.B. : also, I would like to know what you think of these things
> (model-sharing and EMF-based builder), in particular about the
> performances. Is it worth doing this according to you ? Or keeping
> every editor with its own model is better ? I mean, in general, not in
> my specific need context. :)
>
> --
> Vincent Zurczak
> EBM WebSourcing
> + 33 (0) 4 76 61 52 62
>


--------------020501010408080303010704
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Vincent,<br>
<br>
Loading and unloading are not treated as state changing modifications
that could be undone or redone.&nbsp; More comments below.<br>
<br>
<br>
Vincent Zurczak wrote:
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Hello.<br>
<br>
My main question is in the title, but since I'm posting on this
mailing-list, I'd like to explain what I am doing and know what you
think about it.<br>
<br>
My goal is to provide a unified EMF-based framework for a tooling I am
contributing to.<br>
This framework includes a project builder (which relies on resource
modification, an EMF meta-model and EMF validation) and a way to share
EMF models between editors. In fact, I would like to synchronize
several editors used to edit the model files. This includes text
editors, the EMF-model editor, a form-editor using EMF and even a
GMF-based editor. <br>
</blockquote>
Shared transactional editing domains could be used for something like
that.<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite"><br>
I have already defined the builder, it works fine. I'm now working on
the model-sharing. It consists in providing some kind of API to
retrieve a model with its editing domain (and everything required).
Every editor will have to use this <i>facade</i> to be synchronized
with the others.<br>
</blockquote>
A shared editing domain?<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite"><br>
When a file is modified, e.g. when you save a file, the builder is
called and refreshes the main resource by using the unload / load
methods. I was expecting that EMF-based editors, which have registered
a command stack listener, would be notified of this refreshment. But
they are not. Therefore, these editors are not refreshed when the
resource is modified by another one.<br>
</blockquote>
The generated editor listens to the workspace for resource deltas and
does respond to those by unloading and reloading the affects
resource(s).<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite"><br>
<br>
So here are my questions.<br>
Is it normal if the command stack is not affected by resource unloading
/ loading ? <br>
</blockquote>
Definitely.&nbsp; Any data access could cause a proxy to be resolved which
could cause a resource to be loaded.&nbsp; That's why transactional editing
domains make read access exclusive.<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite">If
the answer is yes, I thought I could use a Command to replace the
root element of my model. But in this case, what is the owner of the
root element of the model ?</blockquote>
The Resource is the container and you can use commands to add and
remove things from the contents list of the resource.<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite"> I
also have to anticipate one of the things
you might tell me. When I unload my model, I don't want to flush my
command stack, since I would like to keep the undo / redo operations
independently of the resources' updates. </blockquote>
You would need to use a command then to preserve the old state.&nbsp; But
this is a very tricky thing, because when the resource is unloaded, all
the objects are turned into proxies so that references holding them
will resolve to the new version from then newly loaded resources.&nbsp;
You'd need to be able to undo all that too...&nbsp; Sounds very challenging.<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite">In
this case, is the use of a
command mandatory ? And how can I replace the root element of my model
by another one ? </blockquote>
&nbsp; /**<br>
&nbsp;&nbsp; * This constructs a primitive command to replace a particular value
in the specified extent with the given replacement.<br>
&nbsp;&nbsp; */<br>
&nbsp; public ReplaceCommand(EditingDomain domain, EList&lt;?&gt; list,
Object value, Object replacement) <br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; this(domain, list, value, Collections.singleton(replacement));<br>
&nbsp; }<br>
<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite">Using
a compound command (first removing the old one
and then&nbsp; adding the new one) ? Is there any other solution ? Or
keeping an history in this case is just insane ?<br>
</blockquote>
I wouldn't call it insane, but it's definitely a very challenging
thing.&nbsp; You'll want to look closely at what unload all does and be sure
to undo those things.&nbsp; I imagine you could put the objects back and use
InternalEObject.eSetProxyURI(null) to unproxify them, but the other
models will be pointing at the new things so you'd have to turn them
into proxies...<br>
<blockquote cite="mid:fu0142$arm$1@build.eclipse.org" type="cite"><br>
Regards,<br>
<br>
Vincent.<br>
<br>
<br>
<br>
N.B. : also, I would like to know what you think of these things
(model-sharing and EMF-based builder), in particular about the
performances. Is it worth doing this according to you ? Or keeping
every editor with its own model is better ? I mean, in general, not in
my specific need context. :)<br>
<br>
<pre class="moz-signature" cols="72">--
Vincent Zurczak
EBM WebSourcing
+ 33 (0) 4 76 61 52 62
</pre>
</blockquote>
<br>
</body>
</html>

--------------020501010408080303010704--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:XML serialization does not match my xsd schema, why ?
Next Topic:generated plugin providerName
Goto Forum:
  


Current Time: Thu Apr 25 00:48:03 GMT 2024

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

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

Back to the top