Home » Modeling » EMF » Resource from the EObject is empty after unload and load.
|
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 |
Eclipse User |
|
|
|
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 |
Suresh Subramanian 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 |
David Steinberg 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
>>>
>
>
|
|
|
Goto Forum:
Current Time: Thu Sep 26 02:23:24 GMT 2024
Powered by FUDForum. Page generated in 0.03267 seconds
|