Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Resource from the EObject is empty after unload and load.
Resource from the EObject is empty after unload and load. [message #421172] Tue, 29 July 2008 17:21 Go to next message
Suresh Subramanian is currently offline Suresh SubramanianFriend
Messages: 61
Registered: July 2009
Member
This is a multi-part message in MIME format.

------=_NextPart_000_000E_01C8F164.CD648640
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

=20

I have a model in which the model elements are arranged in containment =
hierarchy. I am implementing IResourceChangelistener to support the =
changes done in the model file out side my tool are recognized and =
update the editor and tree viewer accordingly. When the =
IResourceChangelistener detects the modification I am unloading the =
resource and loading the resource again. I do see the changes are loaded =
after Resource.load() but there is a tree viewer which see those =
objects as proxy, when they are as proxy and I use EcoreUtil to resolve =
them. After that the EObject.eResource() is null. I am not sure how to =
resolve the issue. The same behavior is noticed in the generated editor =
also. I don't know how to make sure the EObject.eResource() returns the =
proper resource. I also saw there was a related bug in the bugzilla =
which was resolved in EMF 2.4. In the generated editor if =
AdapterFactoryEditingDomain.isStale() true the selection is set to =
empty. Is this related?

=20

Regards,

Suresh Subramanian

------=_NextPart_000_000E_01C8F164.CD648640
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.3354" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2>Hi,<?xml:namespace prefix =3D o ns =3D=20
"urn:schemas-microsoft-com:office:office" =
/><o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2>&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt; TEXT-ALIGN: =
justify"><FONT=20
face=3DArial><FONT size=3D2>I have a model in which the model elements =
are arranged=20
in containment <SPAN lang=3DEN=20
style=3D"mso-ansi-language: EN; mso-bidi-font-weight: =
bold">hierarchy</SPAN>. I am=20
implementing IResourceChangelistener to support the changes done in the =
model=20
file out side my tool are recognized and update the editor and tree =
viewer=20
accordingly. When the IResourceChangelistener detects the modification I =
am=20
unloading the resource and loading the resource again. I do see the =
changes are=20
loaded after Resource.load() but&nbsp;&nbsp;there is a tree viewer which =
see=20
those objects as proxy, when they are as proxy and I use EcoreUtil to =
resolve=20
them. After that the EObject.eResource() is null. I am not sure how to =
resolve=20
the issue. The same behavior is noticed in the generated editor also. I =
don't=20
know how to make sure the EObject.eResource()&nbsp; returns the proper =
resource.=20
I also saw there was a related bug in the bugzilla which was resolved in =
EMF=20
2.4. In the generated editor if AdapterFactoryEditingDomain.isStale()=20
true&nbsp;the selection is set to empty. Is this=20
related?<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt; tab-stops: =
74.25pt"><FONT=20
face=3DArial><FONT size=3D2>&nbsp;<SPAN=20
style=3D"mso-tab-count: =
1"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</SPAN><o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2>Regards,<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2>Suresh =
Subramanian<o:p></o:p></FONT></FONT></P></DIV></BODY> </HTML>

------=_NextPart_000_000E_01C8F164.CD648640--
Re: Resource from the EObject is empty after unload and load. [message #421173 is a reply to message #421172] Tue, 29 July 2008 17:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Suresh,

Once a resource has been unloaded, it forgets about its former contents.
Loading it again will not restore the objects to it that are now
proxies. Once an object has become a proxy, it cannot return from that
state. The EcoreUtil::resolve(...) API will always return a different
object than the proxy, if it can resolve it. The proxy's eResource will
always remain null.

Your viewer and any other component of your application that has
references to the objects that were unloaded, will have to replace these
with references to the newly loaded objects after you re-load the resource.

HTH,

Christian


Suresh Subramanian wrote:
> Hi,
>
>
>
> I have a model in which the model elements are arranged in containment
> hierarchy. I am implementing IResourceChangelistener to support the
> changes done in the model file out side my tool are recognized and
> update the editor and tree viewer accordingly. When the
> IResourceChangelistener detects the modification I am unloading the
> resource and loading the resource again. I do see the changes are loaded
> after Resource.load() but there is a tree viewer which see those
> objects as proxy, when they are as proxy and I use EcoreUtil to resolve
> them. After that the EObject.eResource() is null. I am not sure how to
> resolve the issue. The same behavior is noticed in the generated editor
> also. I don't know how to make sure the EObject.eResource() returns the
> proper resource. I also saw there was a related bug in the bugzilla
> which was resolved in EMF 2.4. In the generated editor if
> AdapterFactoryEditingDomain.isStale() true the selection is set to
> empty. Is this related?
>
>
>
> Regards,
>
> Suresh Subramanian
>
Re: Resource from the EObject is empty after unload and load. [message #421177 is a reply to message #421173] Tue, 29 July 2008 17:38 Go to previous messageGo to next message
Suresh Subramanian is currently offline Suresh SubramanianFriend
Messages: 61
Registered: July 2009
Member
Thanks for your quick response Christain,

In that case is there a way to update the resource other than unload and
load. I know GMF is doing that manipulating the DocumentProvider but i am
not sure how to implement for EMF.

Regards,
Suresh Subramanian

"Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
news:g6njsn$6me$1@build.eclipse.org...
> Hi, Suresh,
>
> Once a resource has been unloaded, it forgets about its former contents.
> Loading it again will not restore the objects to it that are now proxies.
> Once an object has become a proxy, it cannot return from that state. The
> EcoreUtil::resolve(...) API will always return a different object than the
> proxy, if it can resolve it. The proxy's eResource will always remain
> null.
>
> Your viewer and any other component of your application that has
> references to the objects that were unloaded, will have to replace these
> with references to the newly loaded objects after you re-load the
> resource.
>
> HTH,
>
> Christian
>
>
> Suresh Subramanian wrote:
>> Hi,
>>
>> I have a model in which the model elements are arranged in containment
>> hierarchy. I am implementing IResourceChangelistener to support the
>> changes done in the model file out side my tool are recognized and update
>> the editor and tree viewer accordingly. When the IResourceChangelistener
>> detects the modification I am unloading the resource and loading the
>> resource again. I do see the changes are loaded after Resource.load() but
>> there is a tree viewer which see those objects as proxy, when they are as
>> proxy and I use EcoreUtil to resolve them. After that the
>> EObject.eResource() is null. I am not sure how to resolve the issue. The
>> same behavior is noticed in the generated editor also. I don't know how
>> to make sure the EObject.eResource() returns the proper resource. I also
>> saw there was a related bug in the bugzilla which was resolved in EMF
>> 2.4. In the generated editor if AdapterFactoryEditingDomain.isStale()
>> true the selection is set to empty. Is this related?
>>
>> Regards,
>>
>> Suresh Subramanian
>>
Re: Resource from the EObject is empty after unload and load. [message #421183 is a reply to message #421177] Tue, 29 July 2008 19:43 Go to previous message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Hi Suresh,

There's no mechanism for reloading into existing objects in EMF. I'd
imagine that would be quite a tricky undertaking, but I don't know if
GMF provides anything that does that.

Unloading the resource ensures that if there are any cross-resource
references pointing at it, they will turn into proxies, so that their
getters will resolve them, automatically updating the value to use the
newly loaded object.

You just need to make sure that you're not caching things externally or,
if you are, that you clear the cache when you do the unload and load, so
that they'll be retrieved from the resource set again.

Cheers,
Dave


Suresh Subramanian wrote:
> Thanks for your quick response Christain,
>
> In that case is there a way to update the resource other than unload and
> load. I know GMF is doing that manipulating the DocumentProvider but i am
> not sure how to implement for EMF.
>
> Regards,
> Suresh Subramanian
>
> "Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
> news:g6njsn$6me$1@build.eclipse.org...
>> Hi, Suresh,
>>
>> Once a resource has been unloaded, it forgets about its former contents.
>> Loading it again will not restore the objects to it that are now proxies.
>> Once an object has become a proxy, it cannot return from that state. The
>> EcoreUtil::resolve(...) API will always return a different object than the
>> proxy, if it can resolve it. The proxy's eResource will always remain
>> null.
>>
>> Your viewer and any other component of your application that has
>> references to the objects that were unloaded, will have to replace these
>> with references to the newly loaded objects after you re-load the
>> resource.
>>
>> HTH,
>>
>> Christian
>>
>>
>> Suresh Subramanian wrote:
>>> Hi,
>>>
>>> I have a model in which the model elements are arranged in containment
>>> hierarchy. I am implementing IResourceChangelistener to support the
>>> changes done in the model file out side my tool are recognized and update
>>> the editor and tree viewer accordingly. When the IResourceChangelistener
>>> detects the modification I am unloading the resource and loading the
>>> resource again. I do see the changes are loaded after Resource.load() but
>>> there is a tree viewer which see those objects as proxy, when they are as
>>> proxy and I use EcoreUtil to resolve them. After that the
>>> EObject.eResource() is null. I am not sure how to resolve the issue. The
>>> same behavior is noticed in the generated editor also. I don't know how
>>> to make sure the EObject.eResource() returns the proper resource. I also
>>> saw there was a related bug in the bugzilla which was resolved in EMF
>>> 2.4. In the generated editor if AdapterFactoryEditingDomain.isStale()
>>> true the selection is set to empty. Is this related?
>>>
>>> Regards,
>>>
>>> Suresh Subramanian
>>>
>
>
Previous Topic:Some values not updated in Properties view when selection changes
Next Topic:suppress DocumentRoot serialization
Goto Forum:
  


Current Time: Thu Sep 26 02:23:24 GMT 2024

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

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

Back to the top