Home » Modeling » EMF » Sharing EMF instances across an application?
| | | |
Re: Sharing EMF instances across an application? [message #418743 is a reply to message #418727] |
Fri, 25 April 2008 16:18 |
Sébastien Gandon Messages: 184 Registered: July 2009 |
Senior Member |
|
|
Ed, my comments below,
Ed Merks wrote:
> SeB,
> Comments below.
> SeB.fr wrote:
>> Hello,
>>
>> I have pb with refresh an editor depending on resources edited in
>> another editor.
>>
>> Here is the structure.
>> I have 2 static instances of Resource representing 2 models: resource1
>> and resource2.
> I'm not sure what you mean by "static"
Ok I should have said singleton (sorry), as in there is only 1 instance of
resource1 and 2 during my rcp execution.
>> resource2 has elements referencing resource1 elements.
>> I created 2 editors for each of these resources: editor1 and editor2.
>> So editor1 has a EditingDomain with a ResourceSet holding resource1
>> and editor2 has another EditingDomain with a ResourceSet holding
>> resource2 and resource1 set as read-only (using the
>> EditingDomain.setResourceToReadOnlyMap()) because I do not want
>> editor2 to modify resource1.
>>
>> Ok, now I modify resource1 via editor1, the editor2 showing references
>> on resource1 is correctly updated and on all is fine.
> Don't they each have their own copy. I guess this is the static thing
> you were were getting at earlier?
the editingDomain2 shares the instance of resource1 with editingDomain1
>> Now the user closes editor1 and refuse to save resource1. I looked for
>> a way to revert resource1 to the previously saved data and used
>> resource1.unload().
>> My problem is that the editor2 is not notified of the changes of
>> resource1 ???
> Yet three sentences up you said it responds to changes?
Yes that is why I do not understand.
>Maybe the other
> editor, when it closes without saving, needs to do the unload (assuming
> the second editor is sharing the instance from the first one).
This is done by the editor1, when closing it does resource1.unload()
>> How can I notify that the resource as changed to all viewers ???
> If you're sharing resources across editors, I think you'd need to be
> more explicit about reverting all the changes when the editor is closed
> without saving...
I do not get your sentence here ???
>>
>> Thank you.
>>
>> SeB.
>>
|
|
|
Re: Sharing EMF instances across an application? [message #418744 is a reply to message #418743] |
Fri, 25 April 2008 16:41 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
SeB,
Have you also tried forcing the unloaded resource to load again too?
Keep in mind that unload turns all the objects into proxies and that any
references to the old objects your editor might be holding on to need to
be update. How can you tell the second editor is still referring to the
modified version of resource1?.
SeB.fr wrote:
> Ed, my comments below,
>
> Ed Merks wrote:
>
>> SeB,
>
>> Comments below.
>
>> SeB.fr wrote:
>>> Hello,
>>>
>>> I have pb with refresh an editor depending on resources edited in
>>> another editor.
>>>
>>> Here is the structure.
>>> I have 2 static instances of Resource representing 2 models:
>>> resource1 and resource2.
>> I'm not sure what you mean by "static"
> Ok I should have said singleton (sorry), as in there is only 1
> instance of resource1 and 2 during my rcp execution.
>
>>> resource2 has elements referencing resource1 elements.
>>> I created 2 editors for each of these resources: editor1 and editor2.
>>> So editor1 has a EditingDomain with a ResourceSet holding resource1
>>> and editor2 has another EditingDomain with a ResourceSet holding
>>> resource2 and resource1 set as read-only (using the
>>> EditingDomain.setResourceToReadOnlyMap()) because I do not want
>>> editor2 to modify resource1.
>>>
>>> Ok, now I modify resource1 via editor1, the editor2 showing
>>> references on resource1 is correctly updated and on all is fine.
>> Don't they each have their own copy. I guess this is the static
>> thing you were were getting at earlier?
> the editingDomain2 shares the instance of resource1 with editingDomain1
>
>>> Now the user closes editor1 and refuse to save resource1. I looked
>>> for a way to revert resource1 to the previously saved data and used
>>> resource1.unload().
>>> My problem is that the editor2 is not notified of the changes of
>>> resource1 ???
>> Yet three sentences up you said it responds to changes?
> Yes that is why I do not understand.
>
>> Maybe the other editor, when it closes without saving, needs to do
>> the unload (assuming the second editor is sharing the instance from
>> the first one).
> This is done by the editor1, when closing it does resource1.unload()
>
>
>>> How can I notify that the resource as changed to all viewers ???
>> If you're sharing resources across editors, I think you'd need to be
>> more explicit about reverting all the changes when the editor is
>> closed without saving...
> I do not get your sentence here ???
>
>>>
>>> Thank you.
>>>
>>> SeB.
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Sharing EMF instances across an application? [message #419045 is a reply to message #418744] |
Thu, 08 May 2008 21:33 |
Eclipse User |
|
|
|
Originally posted by: eclipse.gandon.name
Hello,
Yes I do a load eveytime the editor1 is initialized and an unload
everytime it is disposed and still dirty (this means the user did not want
to save it).
I can tell the editor2 is still holding previously unsaved data because
there is a viewer in the editor2 showing instances of elements from model1.
If a new element was created in model1 then the tableviewer show the new
element in editor2 but when doing the unload and load again, the
tableviewer still show the newly created instance that was not saved.
Shall I write explicit code to update the editor2 that model1 as been
reloaded?
SeB.
Ed Merks wrote:
> SeB,
> Have you also tried forcing the unloaded resource to load again too?
> Keep in mind that unload turns all the objects into proxies and that any
> references to the old objects your editor might be holding on to need to
> be update. How can you tell the second editor is still referring to the
> modified version of resource1?.
> SeB.fr wrote:
>> Ed, my comments below,
>>
>> Ed Merks wrote:
>>
>>> SeB,
>>
>>> Comments below.
>>
>>> SeB.fr wrote:
>>>> Hello,
>>>>
>>>> I have pb with refresh an editor depending on resources edited in
>>>> another editor.
>>>>
>>>> Here is the structure.
>>>> I have 2 static instances of Resource representing 2 models:
>>>> resource1 and resource2.
>>> I'm not sure what you mean by "static"
>> Ok I should have said singleton (sorry), as in there is only 1
>> instance of resource1 and 2 during my rcp execution.
>>
>>>> resource2 has elements referencing resource1 elements.
>>>> I created 2 editors for each of these resources: editor1 and editor2.
>>>> So editor1 has a EditingDomain with a ResourceSet holding resource1
>>>> and editor2 has another EditingDomain with a ResourceSet holding
>>>> resource2 and resource1 set as read-only (using the
>>>> EditingDomain.setResourceToReadOnlyMap()) because I do not want
>>>> editor2 to modify resource1.
>>>>
>>>> Ok, now I modify resource1 via editor1, the editor2 showing
>>>> references on resource1 is correctly updated and on all is fine.
>>> Don't they each have their own copy. I guess this is the static
>>> thing you were were getting at earlier?
>> the editingDomain2 shares the instance of resource1 with editingDomain1
>>
>>>> Now the user closes editor1 and refuse to save resource1. I looked
>>>> for a way to revert resource1 to the previously saved data and used
>>>> resource1.unload().
>>>> My problem is that the editor2 is not notified of the changes of
>>>> resource1 ???
>>> Yet three sentences up you said it responds to changes?
>> Yes that is why I do not understand.
>>
>>> Maybe the other editor, when it closes without saving, needs to do
>>> the unload (assuming the second editor is sharing the instance from
>>> the first one).
>> This is done by the editor1, when closing it does resource1.unload()
>>
>>
>>>> How can I notify that the resource as changed to all viewers ???
>>> If you're sharing resources across editors, I think you'd need to be
>>> more explicit about reverting all the changes when the editor is
>>> closed without saving...
>> I do not get your sentence here ???
>>
>>>>
>>>> Thank you.
>>>>
>>>> SeB.
>>>>
>>
>>
|
|
|
Re: Sharing EMF instances across an application? [message #419047 is a reply to message #419045] |
Thu, 08 May 2008 23:16 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
SeB,
I wonder if it might be related to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=230908.
ekaii wrote:
> Hello,
> Yes I do a load eveytime the editor1 is initialized and an unload
> everytime it is disposed and still dirty (this means the user did not
> want to save it).
> I can tell the editor2 is still holding previously unsaved data
> because there is a viewer in the editor2 showing instances of elements
> from model1.
> If a new element was created in model1 then the tableviewer show the
> new element in editor2 but when doing the unload and load again, the
> tableviewer still show the newly created instance that was not saved.
If any views have old objects as inputs it's important that their inputs
be set again.
If you care to create a test case you can share that reproduces the
problem it would be a lot easier to understand...
>
> Shall I write explicit code to update the editor2 that model1 as been
> reloaded?
>
> SeB.
>
>
> Ed Merks wrote:
>
>> SeB,
>
>> Have you also tried forcing the unloaded resource to load again too?
>> Keep in mind that unload turns all the objects into proxies and that
>> any references to the old objects your editor might be holding on to
>> need to be update. How can you tell the second editor is still
>> referring to the modified version of resource1?.
>
>
>> SeB.fr wrote:
>>> Ed, my comments below,
>>>
>>> Ed Merks wrote:
>>>
>>>> SeB,
>>>
>>>> Comments below.
>>>
>>>> SeB.fr wrote:
>>>>> Hello,
>>>>>
>>>>> I have pb with refresh an editor depending on resources edited in
>>>>> another editor.
>>>>>
>>>>> Here is the structure.
>>>>> I have 2 static instances of Resource representing 2 models:
>>>>> resource1 and resource2.
>>>> I'm not sure what you mean by "static"
>>> Ok I should have said singleton (sorry), as in there is only 1
>>> instance of resource1 and 2 during my rcp execution.
>>>
>>>>> resource2 has elements referencing resource1 elements.
>>>>> I created 2 editors for each of these resources: editor1 and editor2.
>>>>> So editor1 has a EditingDomain with a ResourceSet holding
>>>>> resource1 and editor2 has another EditingDomain with a ResourceSet
>>>>> holding resource2 and resource1 set as read-only (using the
>>>>> EditingDomain.setResourceToReadOnlyMap()) because I do not want
>>>>> editor2 to modify resource1.
>>>>>
>>>>> Ok, now I modify resource1 via editor1, the editor2 showing
>>>>> references on resource1 is correctly updated and on all is fine.
>>>> Don't they each have their own copy. I guess this is the static
>>>> thing you were were getting at earlier?
>>> the editingDomain2 shares the instance of resource1 with editingDomain1
>>>
>>>>> Now the user closes editor1 and refuse to save resource1. I looked
>>>>> for a way to revert resource1 to the previously saved data and
>>>>> used resource1.unload().
>>>>> My problem is that the editor2 is not notified of the changes of
>>>>> resource1 ???
>>>> Yet three sentences up you said it responds to changes?
>>> Yes that is why I do not understand.
>>>
>>>> Maybe the other editor, when it closes without saving, needs to do
>>>> the unload (assuming the second editor is sharing the instance from
>>>> the first one).
>>> This is done by the editor1, when closing it does resource1.unload()
>>>
>>>
>>>>> How can I notify that the resource as changed to all viewers ???
>>>> If you're sharing resources across editors, I think you'd need to
>>>> be more explicit about reverting all the changes when the editor is
>>>> closed without saving...
>>> I do not get your sentence here ???
>>>
>>>>>
>>>>> Thank you.
>>>>>
>>>>> SeB.
>>>>>
>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Sharing EMF instances across an application? [message #419215 is a reply to message #419047] |
Tue, 13 May 2008 11:10 |
Sébastien Gandon Messages: 184 Registered: July 2009 |
Senior Member |
|
|
I am not sure is related because my 2 editors work on the singleton
resources and not on the files themself.
Both editors share the same Resource instance all the time, on editor to
edit the resource and the other to be able to reference it.
Since you said unload creates proxies, I have tried to resolve all proxies
after unload and re-load using the EcoreUtil.resolveAll(Resource resource)
on the re-loaded resource but nothing changes on the table viewer in the
editor 2.
I do not know what to do?
Is there a way to be notified that a resource as been unload and loaded
again?
Is there a way to be notified that an EObject becomes a proxy or not?
Thank Ed for your effort helping out lost people such as myself.
SeB.
Ed Merks wrote:
> SeB,
> I wonder if it might be related to
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=230908.
> ekaii wrote:
>> Hello,
>> Yes I do a load eveytime the editor1 is initialized and an unload
>> everytime it is disposed and still dirty (this means the user did not
>> want to save it).
>> I can tell the editor2 is still holding previously unsaved data
>> because there is a viewer in the editor2 showing instances of elements
>> from model1.
>> If a new element was created in model1 then the tableviewer show the
>> new element in editor2 but when doing the unload and load again, the
>> tableviewer still show the newly created instance that was not saved.
> If any views have old objects as inputs it's important that their inputs
> be set again.
> If you care to create a test case you can share that reproduces the
> problem it would be a lot easier to understand...
>>
>> Shall I write explicit code to update the editor2 that model1 as been
>> reloaded?
>>
>> SeB.
>>
>>
>> Ed Merks wrote:
>>
>>> SeB,
>>
>>> Have you also tried forcing the unloaded resource to load again too?
>>> Keep in mind that unload turns all the objects into proxies and that
>>> any references to the old objects your editor might be holding on to
>>> need to be update. How can you tell the second editor is still
>>> referring to the modified version of resource1?.
>>
>>
>>> SeB.fr wrote:
>>>> Ed, my comments below,
>>>>
>>>> Ed Merks wrote:
>>>>
>>>>> SeB,
>>>>
>>>>> Comments below.
>>>>
>>>>> SeB.fr wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I have pb with refresh an editor depending on resources edited in
>>>>>> another editor.
>>>>>>
>>>>>> Here is the structure.
>>>>>> I have 2 static instances of Resource representing 2 models:
>>>>>> resource1 and resource2.
>>>>> I'm not sure what you mean by "static"
>>>> Ok I should have said singleton (sorry), as in there is only 1
>>>> instance of resource1 and 2 during my rcp execution.
>>>>
>>>>>> resource2 has elements referencing resource1 elements.
>>>>>> I created 2 editors for each of these resources: editor1 and editor2.
>>>>>> So editor1 has a EditingDomain with a ResourceSet holding
>>>>>> resource1 and editor2 has another EditingDomain with a ResourceSet
>>>>>> holding resource2 and resource1 set as read-only (using the
>>>>>> EditingDomain.setResourceToReadOnlyMap()) because I do not want
>>>>>> editor2 to modify resource1.
>>>>>>
>>>>>> Ok, now I modify resource1 via editor1, the editor2 showing
>>>>>> references on resource1 is correctly updated and on all is fine.
>>>>> Don't they each have their own copy. I guess this is the static
>>>>> thing you were were getting at earlier?
>>>> the editingDomain2 shares the instance of resource1 with editingDomain1
>>>>
>>>>>> Now the user closes editor1 and refuse to save resource1. I looked
>>>>>> for a way to revert resource1 to the previously saved data and
>>>>>> used resource1.unload().
>>>>>> My problem is that the editor2 is not notified of the changes of
>>>>>> resource1 ???
>>>>> Yet three sentences up you said it responds to changes?
>>>> Yes that is why I do not understand.
>>>>
>>>>> Maybe the other editor, when it closes without saving, needs to do
>>>>> the unload (assuming the second editor is sharing the instance from
>>>>> the first one).
>>>> This is done by the editor1, when closing it does resource1.unload()
>>>>
>>>>
>>>>>> How can I notify that the resource as changed to all viewers ???
>>>>> If you're sharing resources across editors, I think you'd need to
>>>>> be more explicit about reverting all the changes when the editor is
>>>>> closed without saving...
>>>> I do not get your sentence here ???
>>>>
>>>>>>
>>>>>> Thank you.
>>>>>>
>>>>>> SeB.
>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Re: Sharing EMF instances across an application? [message #419221 is a reply to message #419215] |
Tue, 13 May 2008 14:27 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
SeB,
Comments below.
SeB.fr wrote:
> I am not sure is related because my 2 editors work on the singleton
> resources and not on the files themself.
> Both editors share the same Resource instance all the time, on editor
> to edit the resource and the other to be able to reference it.
>
> Since you said unload creates proxies, I have tried to resolve all
> proxies after unload and re-load using the
> EcoreUtil.resolveAll(Resource resource) on the re-loaded resource but
> nothing changes on the table viewer in the editor 2.
Do you know if the input object to the viewer is a proxy?
> I do not know what to do?
> Is there a way to be notified that a resource as been unload and
> loaded again?
Resources produce notification like any other Notifier, e.g.,
Resource.RESOURCE__IS_LOADED.
> Is there a way to be notified that an EObject becomes a proxy or not?
No, the proxy URI is not a reflective feature and doesn't produce
notification.
>
> Thank Ed for your effort helping out lost people such as myself.
>
> SeB.
>
> Ed Merks wrote:
>
>> SeB,
>
>> I wonder if it might be related to
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=230908.
>
>> ekaii wrote:
>>> Hello,
>>> Yes I do a load eveytime the editor1 is initialized and an unload
>>> everytime it is disposed and still dirty (this means the user did
>>> not want to save it).
>>> I can tell the editor2 is still holding previously unsaved data
>>> because there is a viewer in the editor2 showing instances of
>>> elements from model1.
>>> If a new element was created in model1 then the tableviewer show the
>>> new element in editor2 but when doing the unload and load again, the
>>> tableviewer still show the newly created instance that was not saved.
>> If any views have old objects as inputs it's important that their
>> inputs be set again.
>
>> If you care to create a test case you can share that reproduces the
>> problem it would be a lot easier to understand...
>>>
>>> Shall I write explicit code to update the editor2 that model1 as
>>> been reloaded?
>>>
>>> SeB.
>>>
>>>
>>> Ed Merks wrote:
>>>
>>>> SeB,
>>>
>>>> Have you also tried forcing the unloaded resource to load again
>>>> too? Keep in mind that unload turns all the objects into proxies
>>>> and that any references to the old objects your editor might be
>>>> holding on to need to be update. How can you tell the second
>>>> editor is still referring to the modified version of resource1?.
>>>
>>>
>>>> SeB.fr wrote:
>>>>> Ed, my comments below,
>>>>>
>>>>> Ed Merks wrote:
>>>>>
>>>>>> SeB,
>>>>>
>>>>>> Comments below.
>>>>>
>>>>>> SeB.fr wrote:
>>>>>>> Hello,
>>>>>>>
>>>>>>> I have pb with refresh an editor depending on resources edited
>>>>>>> in another editor.
>>>>>>>
>>>>>>> Here is the structure.
>>>>>>> I have 2 static instances of Resource representing 2 models:
>>>>>>> resource1 and resource2.
>>>>>> I'm not sure what you mean by "static"
>>>>> Ok I should have said singleton (sorry), as in there is only 1
>>>>> instance of resource1 and 2 during my rcp execution.
>>>>>
>>>>>>> resource2 has elements referencing resource1 elements.
>>>>>>> I created 2 editors for each of these resources: editor1 and
>>>>>>> editor2.
>>>>>>> So editor1 has a EditingDomain with a ResourceSet holding
>>>>>>> resource1 and editor2 has another EditingDomain with a
>>>>>>> ResourceSet holding resource2 and resource1 set as read-only
>>>>>>> (using the EditingDomain.setResourceToReadOnlyMap()) because I
>>>>>>> do not want editor2 to modify resource1.
>>>>>>>
>>>>>>> Ok, now I modify resource1 via editor1, the editor2 showing
>>>>>>> references on resource1 is correctly updated and on all is fine.
>>>>>> Don't they each have their own copy. I guess this is the static
>>>>>> thing you were were getting at earlier?
>>>>> the editingDomain2 shares the instance of resource1 with
>>>>> editingDomain1
>>>>>
>>>>>>> Now the user closes editor1 and refuse to save resource1. I
>>>>>>> looked for a way to revert resource1 to the previously saved
>>>>>>> data and used resource1.unload().
>>>>>>> My problem is that the editor2 is not notified of the changes of
>>>>>>> resource1 ???
>>>>>> Yet three sentences up you said it responds to changes?
>>>>> Yes that is why I do not understand.
>>>>>
>>>>>> Maybe the other editor, when it closes without saving, needs to
>>>>>> do the unload (assuming the second editor is sharing the instance
>>>>>> from the first one).
>>>>> This is done by the editor1, when closing it does resource1.unload()
>>>>>
>>>>>
>>>>>>> How can I notify that the resource as changed to all viewers ???
>>>>>> If you're sharing resources across editors, I think you'd need to
>>>>>> be more explicit about reverting all the changes when the editor
>>>>>> is closed without saving...
>>>>> I do not get your sentence here ???
>>>>>
>>>>>>>
>>>>>>> Thank you.
>>>>>>>
>>>>>>> SeB.
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Sharing EMF instances across an application? [message #419309 is a reply to message #419221] |
Sat, 17 May 2008 21:57 |
Eclipse User |
|
|
|
Originally posted by: eclipse.gandon.name
Hi Ed,
The input object of my viewer is not a proxy, why would it be ?
During a debug session I have realized that doing unload and then load
again recreates the model objects, this means the viewer input instance
does not exists anymore after the unload-load.
This is surely why me viewer does not get notified anymore.
Would there be any attribute during the load that would tell the resource
not to create new items if not necessary ?
I there a way to revert to previously saved values without doing a
unload-load ?
Thanks Ed.
Ed Merks wrote:
> SeB,
> Comments below.
> SeB.fr wrote:
>> I am not sure is related because my 2 editors work on the singleton
>> resources and not on the files themself.
>> Both editors share the same Resource instance all the time, on editor
>> to edit the resource and the other to be able to reference it.
>>
>> Since you said unload creates proxies, I have tried to resolve all
>> proxies after unload and re-load using the
>> EcoreUtil.resolveAll(Resource resource) on the re-loaded resource but
>> nothing changes on the table viewer in the editor 2.
> Do you know if the input object to the viewer is a proxy?
>> I do not know what to do?
>> Is there a way to be notified that a resource as been unload and
>> loaded again?
> Resources produce notification like any other Notifier, e.g.,
> Resource.RESOURCE__IS_LOADED.
>> Is there a way to be notified that an EObject becomes a proxy or not?
> No, the proxy URI is not a reflective feature and doesn't produce
> notification.
>>
>> Thank Ed for your effort helping out lost people such as myself.
>>
>> SeB.
>>
>> Ed Merks wrote:
>>
>>> SeB,
>>
>>> I wonder if it might be related to
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=230908.
>>
>>> ekaii wrote:
>>>> Hello,
>>>> Yes I do a load eveytime the editor1 is initialized and an unload
>>>> everytime it is disposed and still dirty (this means the user did
>>>> not want to save it).
>>>> I can tell the editor2 is still holding previously unsaved data
>>>> because there is a viewer in the editor2 showing instances of
>>>> elements from model1.
>>>> If a new element was created in model1 then the tableviewer show the
>>>> new element in editor2 but when doing the unload and load again, the
>>>> tableviewer still show the newly created instance that was not saved.
>>> If any views have old objects as inputs it's important that their
>>> inputs be set again.
>>
>>> If you care to create a test case you can share that reproduces the
>>> problem it would be a lot easier to understand...
>>>>
>>>> Shall I write explicit code to update the editor2 that model1 as
>>>> been reloaded?
>>>>
>>>> SeB.
>>>>
>>>>
>>>> Ed Merks wrote:
>>>>
>>>>> SeB,
>>>>
>>>>> Have you also tried forcing the unloaded resource to load again
>>>>> too? Keep in mind that unload turns all the objects into proxies
>>>>> and that any references to the old objects your editor might be
>>>>> holding on to need to be update. How can you tell the second
>>>>> editor is still referring to the modified version of resource1?.
>>>>
>>>>
>>>>> SeB.fr wrote:
>>>>>> Ed, my comments below,
>>>>>>
>>>>>> Ed Merks wrote:
>>>>>>
>>>>>>> SeB,
>>>>>>
>>>>>>> Comments below.
>>>>>>
>>>>>>> SeB.fr wrote:
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> I have pb with refresh an editor depending on resources edited
>>>>>>>> in another editor.
>>>>>>>>
>>>>>>>> Here is the structure.
>>>>>>>> I have 2 static instances of Resource representing 2 models:
>>>>>>>> resource1 and resource2.
>>>>>>> I'm not sure what you mean by "static"
>>>>>> Ok I should have said singleton (sorry), as in there is only 1
>>>>>> instance of resource1 and 2 during my rcp execution.
>>>>>>
>>>>>>>> resource2 has elements referencing resource1 elements.
>>>>>>>> I created 2 editors for each of these resources: editor1 and
>>>>>>>> editor2.
>>>>>>>> So editor1 has a EditingDomain with a ResourceSet holding
>>>>>>>> resource1 and editor2 has another EditingDomain with a
>>>>>>>> ResourceSet holding resource2 and resource1 set as read-only
>>>>>>>> (using the EditingDomain.setResourceToReadOnlyMap()) because I
>>>>>>>> do not want editor2 to modify resource1.
>>>>>>>>
>>>>>>>> Ok, now I modify resource1 via editor1, the editor2 showing
>>>>>>>> references on resource1 is correctly updated and on all is fine.
>>>>>>> Don't they each have their own copy. I guess this is the static
>>>>>>> thing you were were getting at earlier?
>>>>>> the editingDomain2 shares the instance of resource1 with
>>>>>> editingDomain1
>>>>>>
>>>>>>>> Now the user closes editor1 and refuse to save resource1. I
>>>>>>>> looked for a way to revert resource1 to the previously saved
>>>>>>>> data and used resource1.unload().
>>>>>>>> My problem is that the editor2 is not notified of the changes of
>>>>>>>> resource1 ???
>>>>>>> Yet three sentences up you said it responds to changes?
>>>>>> Yes that is why I do not understand.
>>>>>>
>>>>>>> Maybe the other editor, when it closes without saving, needs to
>>>>>>> do the unload (assuming the second editor is sharing the instance
>>>>>>> from the first one).
>>>>>> This is done by the editor1, when closing it does resource1.unload()
>>>>>>
>>>>>>
>>>>>>>> How can I notify that the resource as changed to all viewers ???
>>>>>>> If you're sharing resources across editors, I think you'd need to
>>>>>>> be more explicit about reverting all the changes when the editor
>>>>>>> is closed without saving...
>>>>>> I do not get your sentence here ???
>>>>>>
>>>>>>>>
>>>>>>>> Thank you.
>>>>>>>>
>>>>>>>> SeB.
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Re: Sharing EMF instances across an application? [message #419311 is a reply to message #419309] |
Sat, 17 May 2008 23:25 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
SeB,
I'm having a hard time following this endless thread with many days of
silence. I don't really care to read the whole history again each time...
ekaii wrote:
> Hi Ed,
> The input object of my viewer is not a proxy, why would it be ?
No, I believe I was asking if it is...
> During a debug session I have realized that doing unload and then load
> again recreates the model objects, this means the viewer input
> instance does not exists anymore after the unload-load.
The input instance might well be turned into a proxy and they you'll
want to get the new replacement instance instead. EcoreUtil.resolve can
be used for that.
> This is surely why me viewer does not get notified anymore.
Yes.
> Would there be any attribute during the load that would tell the
> resource not to create new items if not necessary ?
No, that's just what unloading and reloading does...
> I there a way to revert to previously saved values without doing a
> unload-load ?
Not really. A ChangeRecorder could be used to record all the changes
and roll them back, I suppose, but if you're having trouble with the
current details, I hate to think about trying to get a change recorder
to work...
>
> Thanks Ed.
>
> Ed Merks wrote:
>
>> SeB,
>
>> Comments below.
>
>> SeB.fr wrote:
>>> I am not sure is related because my 2 editors work on the singleton
>>> resources and not on the files themself.
>>> Both editors share the same Resource instance all the time, on
>>> editor to edit the resource and the other to be able to reference it.
>>>
>>> Since you said unload creates proxies, I have tried to resolve all
>>> proxies after unload and re-load using the
>>> EcoreUtil.resolveAll(Resource resource) on the re-loaded resource
>>> but nothing changes on the table viewer in the editor 2.
>> Do you know if the input object to the viewer is a proxy?
>>> I do not know what to do?
>>> Is there a way to be notified that a resource as been unload and
>>> loaded again?
>> Resources produce notification like any other Notifier, e.g.,
>> Resource.RESOURCE__IS_LOADED.
>>> Is there a way to be notified that an EObject becomes a proxy or not?
>> No, the proxy URI is not a reflective feature and doesn't produce
>> notification.
>>>
>>> Thank Ed for your effort helping out lost people such as myself.
>>>
>>> SeB.
>>>
>>> Ed Merks wrote:
>>>
>>>> SeB,
>>>
>>>> I wonder if it might be related to
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=230908.
>>>
>>>> ekaii wrote:
>>>>> Hello,
>>>>> Yes I do a load eveytime the editor1 is initialized and an unload
>>>>> everytime it is disposed and still dirty (this means the user did
>>>>> not want to save it).
>>>>> I can tell the editor2 is still holding previously unsaved data
>>>>> because there is a viewer in the editor2 showing instances of
>>>>> elements from model1.
>>>>> If a new element was created in model1 then the tableviewer show
>>>>> the new element in editor2 but when doing the unload and load
>>>>> again, the tableviewer still show the newly created instance that
>>>>> was not saved.
>>>> If any views have old objects as inputs it's important that their
>>>> inputs be set again.
>>>
>>>> If you care to create a test case you can share that reproduces the
>>>> problem it would be a lot easier to understand...
>>>>>
>>>>> Shall I write explicit code to update the editor2 that model1 as
>>>>> been reloaded?
>>>>>
>>>>> SeB.
>>>>>
>>>>>
>>>>> Ed Merks wrote:
>>>>>
>>>>>> SeB,
>>>>>
>>>>>> Have you also tried forcing the unloaded resource to load again
>>>>>> too? Keep in mind that unload turns all the objects into proxies
>>>>>> and that any references to the old objects your editor might be
>>>>>> holding on to need to be update. How can you tell the second
>>>>>> editor is still referring to the modified version of resource1?.
>>>>>
>>>>>
>>>>>> SeB.fr wrote:
>>>>>>> Ed, my comments below,
>>>>>>>
>>>>>>> Ed Merks wrote:
>>>>>>>
>>>>>>>> SeB,
>>>>>>>
>>>>>>>> Comments below.
>>>>>>>
>>>>>>>> SeB.fr wrote:
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> I have pb with refresh an editor depending on resources edited
>>>>>>>>> in another editor.
>>>>>>>>>
>>>>>>>>> Here is the structure.
>>>>>>>>> I have 2 static instances of Resource representing 2 models:
>>>>>>>>> resource1 and resource2.
>>>>>>>> I'm not sure what you mean by "static"
>>>>>>> Ok I should have said singleton (sorry), as in there is only 1
>>>>>>> instance of resource1 and 2 during my rcp execution.
>>>>>>>
>>>>>>>>> resource2 has elements referencing resource1 elements.
>>>>>>>>> I created 2 editors for each of these resources: editor1 and
>>>>>>>>> editor2.
>>>>>>>>> So editor1 has a EditingDomain with a ResourceSet holding
>>>>>>>>> resource1 and editor2 has another EditingDomain with a
>>>>>>>>> ResourceSet holding resource2 and resource1 set as read-only
>>>>>>>>> (using the EditingDomain.setResourceToReadOnlyMap()) because I
>>>>>>>>> do not want editor2 to modify resource1.
>>>>>>>>>
>>>>>>>>> Ok, now I modify resource1 via editor1, the editor2 showing
>>>>>>>>> references on resource1 is correctly updated and on all is fine.
>>>>>>>> Don't they each have their own copy. I guess this is the
>>>>>>>> static thing you were were getting at earlier?
>>>>>>> the editingDomain2 shares the instance of resource1 with
>>>>>>> editingDomain1
>>>>>>>
>>>>>>>>> Now the user closes editor1 and refuse to save resource1. I
>>>>>>>>> looked for a way to revert resource1 to the previously saved
>>>>>>>>> data and used resource1.unload().
>>>>>>>>> My problem is that the editor2 is not notified of the changes
>>>>>>>>> of resource1 ???
>>>>>>>> Yet three sentences up you said it responds to changes?
>>>>>>> Yes that is why I do not understand.
>>>>>>>
>>>>>>>> Maybe the other editor, when it closes without saving, needs to
>>>>>>>> do the unload (assuming the second editor is sharing the
>>>>>>>> instance from the first one).
>>>>>>> This is done by the editor1, when closing it does
>>>>>>> resource1.unload()
>>>>>>>
>>>>>>>
>>>>>>>>> How can I notify that the resource as changed to all viewers ???
>>>>>>>> If you're sharing resources across editors, I think you'd need
>>>>>>>> to be more explicit about reverting all the changes when the
>>>>>>>> editor is closed without saving...
>>>>>>> I do not get your sentence here ???
>>>>>>>
>>>>>>>>>
>>>>>>>>> Thank you.
>>>>>>>>>
>>>>>>>>> SeB.
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Sharing EMF instances across an application? [message #419359 is a reply to message #419311] |
Tue, 20 May 2008 11:56 |
Sébastien Gandon Messages: 184 Registered: July 2009 |
Senior Member |
|
|
Hi Ed and sorry for this endless post,
I did not realize that it would be hard to follow with all the other
thread you care to answer. You do a great job helping us out and I really
appreaciate it. I will now be more carefull.
A few questions though.
Is it possible to share the same Resource instance between two
EditingDomains ? It seems that the ResourceSet.add(Resource) removes the
resource from previous ResourceSet, so I do not see how to do it?
I Then thought about sharing ResourceSet betwwen editing domain but could
not find how ?
My problem is that I have an editor1 to edit model1 and editor2 to edit
model2 referencing model1.
is it possible to share resources or do I have to create new resources
that means observe that the underliyng file has changed to update model2
references?
Thanks SeB.
Ed Merks wrote:
> SeB,
> I'm having a hard time following this endless thread with many days of
> silence. I don't really care to read the whole history again each time...
> ekaii wrote:
>> Hi Ed,
>> The input object of my viewer is not a proxy, why would it be ?
> No, I believe I was asking if it is...
>> During a debug session I have realized that doing unload and then load
>> again recreates the model objects, this means the viewer input
>> instance does not exists anymore after the unload-load.
> The input instance might well be turned into a proxy and they you'll
> want to get the new replacement instance instead. EcoreUtil.resolve can
> be used for that.
>> This is surely why me viewer does not get notified anymore.
> Yes.
>> Would there be any attribute during the load that would tell the
>> resource not to create new items if not necessary ?
> No, that's just what unloading and reloading does...
>> I there a way to revert to previously saved values without doing a
>> unload-load ?
> Not really. A ChangeRecorder could be used to record all the changes
> and roll them back, I suppose, but if you're having trouble with the
> current details, I hate to think about trying to get a change recorder
> to work...
>>
>> Thanks Ed.
>>
|
|
|
Re: Sharing EMF instances across an application? [message #419360 is a reply to message #419359] |
Tue, 20 May 2008 12:24 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
SeB,
Comments below.
SeB.fr wrote:
> Hi Ed and sorry for this endless post,
> I did not realize that it would be hard to follow with all the other
> thread you care to answer. You do a great job helping us out and I
> really appreaciate it. I will now be more carefull.
Sometimes I get a bit cranky when the thread is really long and I know
I'm starting to lose track of it...
>
> A few questions though.
> Is it possible to share the same Resource instance between two
> EditingDomains ?
It's generally a bit problematic because things like
AdapterFactoryEditingDomain.getEditingDomainFor wants to be able to
determine the editing domain for a given object and a resource shared
between editing domains can't give multiple answers for this...
> It seems that the ResourceSet.add(Resource) removes the resource from
> previous ResourceSet, so I do not see how to do it?
Yes. ResourceSet.getResources and Resource.getResourceSet are like
bidirectional containment references. I.e., a resource be contained by
at most one resource set.
> I Then thought about sharing ResourceSet betwwen editing domain but
> could not find how ?
The same kind of problem arises for those. Once you get to this level,
it's really better to share the editing domain themselves.
> My problem is that I have an editor1 to edit model1 and editor2 to
> edit model2 referencing model1.
That's a common issue.
> is it possible to share resources or do I have to create new resources
> that means observe that the underliyng file has changed to update
> model2 references?
You can share editing domains and the transactional frameworks can help
with that. Or you can go with the more basic generated editor where
each edit has it's own copy of the model and is updated only when the
underlying workspace version is changed.
>
> Thanks SeB.
>
> Ed Merks wrote:
>
>> SeB,
>
>> I'm having a hard time following this endless thread with many days
>> of silence. I don't really care to read the whole history again each
>> time...
>
>> ekaii wrote:
>>> Hi Ed,
>>> The input object of my viewer is not a proxy, why would it be ?
>> No, I believe I was asking if it is...
>>> During a debug session I have realized that doing unload and then
>>> load again recreates the model objects, this means the viewer input
>>> instance does not exists anymore after the unload-load.
>> The input instance might well be turned into a proxy and they you'll
>> want to get the new replacement instance instead. EcoreUtil.resolve
>> can be used for that.
>>> This is surely why me viewer does not get notified anymore.
>> Yes.
>>> Would there be any attribute during the load that would tell the
>>> resource not to create new items if not necessary ?
>> No, that's just what unloading and reloading does...
>>> I there a way to revert to previously saved values without doing a
>>> unload-load ?
>> Not really. A ChangeRecorder could be used to record all the changes
>> and roll them back, I suppose, but if you're having trouble with the
>> current details, I hate to think about trying to get a change
>> recorder to work...
>>>
>>> Thanks Ed.
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Sharing EMF instances across an application? [message #419419 is a reply to message #419360] |
Thu, 22 May 2008 09:15 |
Sébastien Gandon Messages: 184 Registered: July 2009 |
Senior Member |
|
|
Hi Ed,
You mentionned sharing EditingDomain for my 2 editors problem that is an
editor1 to edit model1 and editor2 to edit model2 referencing model1.
But if you do so, that means sharing the same Command Stack and therefor
the same dirty state (usually based on the command Stack state) that means
you modify model1 and then you see editor2 as dirty.
What is the point? I'd rather merge both model into one. Or do you forsee
a way around?
Do you think transactional would solve this problem ? I had a look at the
doc and I am not sure this would solve my problem.
Another point is if my problem is a common issue, why not modfy the
framework to accomodate this issue.
What do you think of enhancing an EditingDomain with another ResourceSet
that would only be used for referenced elements that would only be
read-only and not a container of the Resources. ie not modify the
containement of a resource if it is referenced in another Resource Set?
Today the read only state is handle by a map but this might be interesting
to enforce it with different special ResourceSet?
These are my thoughts for now and hope to find an anwer to my isssue soon.
SeB.
Ed Merks wrote:
> SeB,
> Comments below.
> SeB.fr wrote:
>> Hi Ed and sorry for this endless post,
>> I did not realize that it would be hard to follow with all the other
>> thread you care to answer. You do a great job helping us out and I
>> really appreaciate it. I will now be more carefull.
> Sometimes I get a bit cranky when the thread is really long and I know
> I'm starting to lose track of it...
>>
>> A few questions though.
>> Is it possible to share the same Resource instance between two
>> EditingDomains ?
> It's generally a bit problematic because things like
> AdapterFactoryEditingDomain.getEditingDomainFor wants to be able to
> determine the editing domain for a given object and a resource shared
> between editing domains can't give multiple answers for this...
>> It seems that the ResourceSet.add(Resource) removes the resource from
>> previous ResourceSet, so I do not see how to do it?
> Yes. ResourceSet.getResources and Resource.getResourceSet are like
> bidirectional containment references. I.e., a resource be contained by
> at most one resource set.
>> I Then thought about sharing ResourceSet betwwen editing domain but
>> could not find how ?
> The same kind of problem arises for those. Once you get to this level,
> it's really better to share the editing domain themselves.
>> My problem is that I have an editor1 to edit model1 and editor2 to
>> edit model2 referencing model1.
> That's a common issue.
>> is it possible to share resources or do I have to create new resources
>> that means observe that the underliyng file has changed to update
>> model2 references?
> You can share editing domains and the transactional frameworks can help
> with that. Or you can go with the more basic generated editor where
> each edit has it's own copy of the model and is updated only when the
> underlying workspace version is changed.
>>
>> Thanks SeB.
>>
>> Ed Merks wrote:
>>
>>> SeB,
>>
>>> I'm having a hard time following this endless thread with many days
>>> of silence. I don't really care to read the whole history again each
>>> time...
>>
>>> ekaii wrote:
>>>> Hi Ed,
>>>> The input object of my viewer is not a proxy, why would it be ?
>>> No, I believe I was asking if it is...
>>>> During a debug session I have realized that doing unload and then
>>>> load again recreates the model objects, this means the viewer input
>>>> instance does not exists anymore after the unload-load.
>>> The input instance might well be turned into a proxy and they you'll
>>> want to get the new replacement instance instead. EcoreUtil.resolve
>>> can be used for that.
>>>> This is surely why me viewer does not get notified anymore.
>>> Yes.
>>>> Would there be any attribute during the load that would tell the
>>>> resource not to create new items if not necessary ?
>>> No, that's just what unloading and reloading does...
>>>> I there a way to revert to previously saved values without doing a
>>>> unload-load ?
>>> Not really. A ChangeRecorder could be used to record all the changes
>>> and roll them back, I suppose, but if you're having trouble with the
>>> current details, I hate to think about trying to get a change
>>> recorder to work...
>>>>
>>>> Thanks Ed.
>>>>
>>
>>
|
|
|
Re: Sharing EMF instances across an application? [message #419429 is a reply to message #419419] |
Thu, 22 May 2008 11:36 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
SeB,
Yes, I think the transactional framework has APIs for dealing with all
these kinds of issue. Maybe Christian will comment on that..
SeB.fr wrote:
> Hi Ed,
>
> You mentionned sharing EditingDomain for my 2 editors problem that is
> an editor1 to edit model1 and editor2 to edit model2 referencing model1.
> But if you do so, that means sharing the same Command Stack and
> therefor the same dirty state (usually based on the command Stack
> state) that means you modify model1 and then you see editor2 as dirty.
> What is the point? I'd rather merge both model into one. Or do you
> forsee a way around?
> Do you think transactional would solve this problem ? I had a look at
> the doc and I am not sure this would solve my problem.
>
> Another point is if my problem is a common issue, why not modfy the
> framework to accomodate this issue.
> What do you think of enhancing an EditingDomain with another
> ResourceSet that would only be used for referenced elements that would
> only be read-only and not a container of the Resources. ie not modify
> the containement of a resource if it is referenced in another Resource
> Set?
> Today the read only state is handle by a map but this might be
> interesting to enforce it with different special ResourceSet?
>
> These are my thoughts for now and hope to find an anwer to my isssue
> soon.
>
> SeB.
>
> Ed Merks wrote:
>
>> SeB,
>
>> Comments below.
>
>> SeB.fr wrote:
>>> Hi Ed and sorry for this endless post,
>>> I did not realize that it would be hard to follow with all the other
>>> thread you care to answer. You do a great job helping us out and I
>>> really appreaciate it. I will now be more carefull.
>> Sometimes I get a bit cranky when the thread is really long and I
>> know I'm starting to lose track of it...
>>>
>>> A few questions though.
>>> Is it possible to share the same Resource instance between two
>>> EditingDomains ?
>> It's generally a bit problematic because things like
>> AdapterFactoryEditingDomain.getEditingDomainFor wants to be able to
>> determine the editing domain for a given object and a resource shared
>> between editing domains can't give multiple answers for this...
>>> It seems that the ResourceSet.add(Resource) removes the resource
>>> from previous ResourceSet, so I do not see how to do it?
>> Yes. ResourceSet.getResources and Resource.getResourceSet are like
>> bidirectional containment references. I.e., a resource be contained
>> by at most one resource set.
>>> I Then thought about sharing ResourceSet betwwen editing domain but
>>> could not find how ?
>> The same kind of problem arises for those. Once you get to this
>> level, it's really better to share the editing domain themselves.
>>> My problem is that I have an editor1 to edit model1 and editor2 to
>>> edit model2 referencing model1.
>> That's a common issue.
>>> is it possible to share resources or do I have to create new
>>> resources that means observe that the underliyng file has changed to
>>> update model2 references?
>> You can share editing domains and the transactional frameworks can
>> help with that. Or you can go with the more basic generated editor
>> where each edit has it's own copy of the model and is updated only
>> when the underlying workspace version is changed.
>>>
>>> Thanks SeB.
>>>
>>> Ed Merks wrote:
>>>
>>>> SeB,
>>>
>>>> I'm having a hard time following this endless thread with many days
>>>> of silence. I don't really care to read the whole history again
>>>> each time...
>>>
>>>> ekaii wrote:
>>>>> Hi Ed,
>>>>> The input object of my viewer is not a proxy, why would it be ?
>>>> No, I believe I was asking if it is...
>>>>> During a debug session I have realized that doing unload and then
>>>>> load again recreates the model objects, this means the viewer
>>>>> input instance does not exists anymore after the unload-load.
>>>> The input instance might well be turned into a proxy and they
>>>> you'll want to get the new replacement instance instead.
>>>> EcoreUtil.resolve can be used for that.
>>>>> This is surely why me viewer does not get notified anymore.
>>>> Yes.
>>>>> Would there be any attribute during the load that would tell the
>>>>> resource not to create new items if not necessary ?
>>>> No, that's just what unloading and reloading does...
>>>>> I there a way to revert to previously saved values without doing a
>>>>> unload-load ?
>>>> Not really. A ChangeRecorder could be used to record all the
>>>> changes and roll them back, I suppose, but if you're having trouble
>>>> with the current details, I hate to think about trying to get a
>>>> change recorder to work...
>>>>>
>>>>> Thanks Ed.
>>>>>
>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Wed Apr 24 17:51:12 GMT 2024
Powered by FUDForum. Page generated in 0.04729 seconds
|