Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] Change-Notifications in ItemProviders
[EMF] Change-Notifications in ItemProviders [message #1393992] Fri, 04 July 2014 15:48 Go to next message
Samuel Leisering is currently offline Samuel LeiseringFriend
Messages: 34
Registered: July 2014
Member
Hi

Is there a documentation about how notifications in ItemProviders are
handled? I am currently using the item providers generated by the CDO
generator, and notifications are working just fine. After modifying some
of those Item Providers i noticed that there is no obvious way to
subscribe item providers to events happening on other items.
I created a tree where some nodes display content of other items, and
therefore should be changed when this content changes. Is there a
predefined way to do this?


Greetings
Samuel
Re: [EMF] Change-Notifications in ItemProviders [message #1394372 is a reply to message #1393992] Sat, 05 July 2014 06:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30353
Registered: July 2009
Senior Member
Samuel,

No, there's no prescribed way. If it's affected by the labels of
contained children, one can often write the child item provider so it
generates notifications for the parent, e.g.,
org.eclipse.emf.ecore.provider.EGenericTypeItemProvider.notifyChanged(Notification).

On 04/07/2014 5:48 PM, Samuel Leisering wrote:
> Hi
>
> Is there a documentation about how notifications in ItemProviders are
> handled? I am currently using the item providers generated by the CDO
> generator, and notifications are working just fine. After modifying some
> of those Item Providers i noticed that there is no obvious way to
> subscribe item providers to events happening on other items.
> I created a tree where some nodes display content of other items, and
> therefore should be changed when this content changes. Is there a
> predefined way to do this?
>
>
> Greetings
> Samuel
Re: [EMF] Change-Notifications in ItemProviders [message #1395321 is a reply to message #1394372] Sun, 06 July 2014 19:10 Go to previous messageGo to next message
Samuel Leisering is currently offline Samuel LeiseringFriend
Messages: 34
Registered: July 2014
Member
Hi,

thats too bad. Some of those affected objects are unrelated in regards
to the model hierarchy (or at least more complicated than
parent/children relations). How are the notifications generated, and
where is decided which itemprovider gets notified? Because the generated
notifyChanged(Notification) method you mentioned contains a switch-case
to decide if the notification applies to the node. But after further
inspection i saw that only notifications about the particular objects
this ItemProvider adapts come through anyway (which is basically the
problem here).

Greetings
Samuel

On 05.07.2014 08:45, Ed Merks wrote:
> Samuel,
>
> No, there's no prescribed way. If it's affected by the labels of
> contained children, one can often write the child item provider so it
> generates notifications for the parent, e.g.,
> org.eclipse.emf.ecore.provider.EGenericTypeItemProvider.notifyChanged(Notification).
>
>
> On 04/07/2014 5:48 PM, Samuel Leisering wrote:
>> Hi
>>
>> Is there a documentation about how notifications in ItemProviders are
>> handled? I am currently using the item providers generated by the CDO
>> generator, and notifications are working just fine. After modifying some
>> of those Item Providers i noticed that there is no obvious way to
>> subscribe item providers to events happening on other items.
>> I created a tree where some nodes display content of other items, and
>> therefore should be changed when this content changes. Is there a
>> predefined way to do this?
>>
>>
>> Greetings
>> Samuel
>
Re: [EMF] Change-Notifications in ItemProviders [message #1395607 is a reply to message #1395321] Mon, 07 July 2014 06:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30353
Registered: July 2009
Senior Member
Samuel,

Comments below.

On 06/07/2014 9:10 PM, Samuel Leisering wrote:
> Hi,
>
> thats too bad. Some of those affected objects are unrelated in regards
> to the model hierarchy (or at least more complicated than
> parent/children relations).
Yes, that makes things more complicated. Even Ecore has such issues
where the labels classifiers are used where those types themselves are
referenced; and even those do not properly refresh the tree when the
classifier is renamed.
> How are the notifications generated,
By the model when you change it.
> and
> where is decided which itemprovider gets notified?
An item provider is an adapter and is notified.
> Because the generated
> notifyChanged(Notification) method you mentioned contains a switch-case
> to decide if the notification applies to the node.
Yes.
> But after further
> inspection i saw that only notifications about the particular objects
> this ItemProvider adapts come through anyway (which is basically the
> problem here).
Yes. An item provider computing a label that involves visiting other
objects would generally need to add adapters to those objects and listen
for changes to any of the features it's using for computing the label.
It's a significantly challenging problem.
>
> Greetings
> Samuel
>
> On 05.07.2014 08:45, Ed Merks wrote:
>> Samuel,
>>
>> No, there's no prescribed way. If it's affected by the labels of
>> contained children, one can often write the child item provider so it
>> generates notifications for the parent, e.g.,
>> org.eclipse.emf.ecore.provider.EGenericTypeItemProvider.notifyChanged(Notification).
>>
>>
>> On 04/07/2014 5:48 PM, Samuel Leisering wrote:
>>> Hi
>>>
>>> Is there a documentation about how notifications in ItemProviders are
>>> handled? I am currently using the item providers generated by the CDO
>>> generator, and notifications are working just fine. After modifying some
>>> of those Item Providers i noticed that there is no obvious way to
>>> subscribe item providers to events happening on other items.
>>> I created a tree where some nodes display content of other items, and
>>> therefore should be changed when this content changes. Is there a
>>> predefined way to do this?
>>>
>>>
>>> Greetings
>>> Samuel
Re: [EMF] Change-Notifications in ItemProviders [message #1395802 is a reply to message #1395321] Mon, 07 July 2014 12:18 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 06-07-14 21:10, Samuel Leisering wrote:
> Hi,
>
> thats too bad. Some of those affected objects are unrelated in regards
> to the model hierarchy (or at least more complicated than
> parent/children relations).
This is the reason I moved away from ItemProviders and use EMF
Databinding. Most model changes can be reflected in the UI as wished.
There is excellent documentation, and if you have an odd use case,
please ask here. (i.e. a case where multiple model changes would
aggregate to a single UI change or the other way around).


How are the notifications generated, and
> where is decided which itemprovider gets notified? Because the generated
> notifyChanged(Notification) method you mentioned contains a switch-case
> to decide if the notification applies to the node. But after further
> inspection i saw that only notifications about the particular objects
> this ItemProvider adapts come through anyway (which is basically the
> problem here).
>
> Greetings
> Samuel
>
> On 05.07.2014 08:45, Ed Merks wrote:
>> Samuel,
>>
>> No, there's no prescribed way. If it's affected by the labels of
>> contained children, one can often write the child item provider so it
>> generates notifications for the parent, e.g.,
>> org.eclipse.emf.ecore.provider.EGenericTypeItemProvider.notifyChanged(Notification).
>>
>>
>> On 04/07/2014 5:48 PM, Samuel Leisering wrote:
>>> Hi
>>>
>>> Is there a documentation about how notifications in ItemProviders are
>>> handled? I am currently using the item providers generated by the CDO
>>> generator, and notifications are working just fine. After modifying some
>>> of those Item Providers i noticed that there is no obvious way to
>>> subscribe item providers to events happening on other items.
>>> I created a tree where some nodes display content of other items, and
>>> therefore should be changed when this content changes. Is there a
>>> predefined way to do this?
>>>
>>>
>>> Greetings
>>> Samuel
>>
>
Re: [EMF] Change-Notifications in ItemProviders [message #1395852 is a reply to message #1395802] Mon, 07 July 2014 13:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30353
Registered: July 2009
Senior Member
Christophe,

Is it easy to build a fully functional tree this way? I.e., one that
has a properties view, supports creation of new children (extensibly),
drag-and-drop, and so on?


On 07/07/2014 2:18 PM, Christophe Bouhier wrote:
> On 06-07-14 21:10, Samuel Leisering wrote:
>> Hi,
>>
>> thats too bad. Some of those affected objects are unrelated in regards
>> to the model hierarchy (or at least more complicated than
>> parent/children relations).
> This is the reason I moved away from ItemProviders and use EMF
> Databinding. Most model changes can be reflected in the UI as wished.
> There is excellent documentation, and if you have an odd use case,
> please ask here. (i.e. a case where multiple model changes would
> aggregate to a single UI change or the other way around).
>
>
> How are the notifications generated, and
>> where is decided which itemprovider gets notified? Because the generated
>> notifyChanged(Notification) method you mentioned contains a switch-case
>> to decide if the notification applies to the node. But after further
>> inspection i saw that only notifications about the particular objects
>> this ItemProvider adapts come through anyway (which is basically the
>> problem here).
>>
>> Greetings
>> Samuel
>>
>> On 05.07.2014 08:45, Ed Merks wrote:
>>> Samuel,
>>>
>>> No, there's no prescribed way. If it's affected by the labels of
>>> contained children, one can often write the child item provider so it
>>> generates notifications for the parent, e.g.,
>>> org.eclipse.emf.ecore.provider.EGenericTypeItemProvider.notifyChanged(Notification).
>>>
>>>
>>>
>>> On 04/07/2014 5:48 PM, Samuel Leisering wrote:
>>>> Hi
>>>>
>>>> Is there a documentation about how notifications in ItemProviders are
>>>> handled? I am currently using the item providers generated by the CDO
>>>> generator, and notifications are working just fine. After modifying
>>>> some
>>>> of those Item Providers i noticed that there is no obvious way to
>>>> subscribe item providers to events happening on other items.
>>>> I created a tree where some nodes display content of other items, and
>>>> therefore should be changed when this content changes. Is there a
>>>> predefined way to do this?
>>>>
>>>>
>>>> Greetings
>>>> Samuel
>>>
>>
>
Re: [EMF] Change-Notifications in ItemProviders [message #1395881 is a reply to message #1395802] Mon, 07 July 2014 14:31 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 07/07/2014 14:18, Christophe Bouhier wrote:
> On 06-07-14 21:10, Samuel Leisering wrote:
>> Hi,
>>
>> thats too bad. Some of those affected objects are unrelated in regards
>> to the model hierarchy (or at least more complicated than
>> parent/children relations).
> This is the reason I moved away from ItemProviders and use EMF
> Databinding. Most model changes can be reflected in the UI as wished.
> There is excellent documentation, and if you have an odd use case,
> please ask here. (i.e. a case where multiple model changes would
> aggregate to a single UI change or the other way around).

Excellent documentation? Where? Thanks for sharing. I only ever found
blog posts and the like with warnings that this and that changed and
will change in the future.. and felt I'm the only one using it and other
people at work look at me like I'm crazy to use that even for the
simplest things.

Felix
Re: [EMF] Change-Notifications in ItemProviders [message #1396514 is a reply to message #1395852] Tue, 08 July 2014 12:04 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 07-07-14 15:40, Ed Merks wrote:
> Christophe,
>
> Is it easy to build a fully functional tree this way? I.e., one that
> has a properties view, supports creation of new children (extensibly),
> drag-and-drop, and so on?

Hi Ed, My statement is in the context of the question, which is
how to reflect ui <--> model changes in an arbitrary object structure
(Through contained/non-contained relationships or whatever else). The
question is also about notifications and CDO. Here a CDO invalidation
event can be caught and the Tree refreshed, which is how I handle it.

For this EMF Databinding has (Amongst much more) two powerfull concepts
for trees,

TreeStructureAdvisor => Define the structure of the tree.

IObservableFactory => Create observables.


Feeding the tree, is possible with a ComputedList which is a concept I
like very much in Databinding. I use for example to aggregate the
content from multiple EMF resources.

Of course, I use the EMF.Edit framework for other functionality you
mention (Command framework, PropertySource etc..). It is for sure that
Databinding doesn't offer this functionality.

>
>
> On 07/07/2014 2:18 PM, Christophe Bouhier wrote:
>> On 06-07-14 21:10, Samuel Leisering wrote:
>>> Hi,
>>>
>>> thats too bad. Some of those affected objects are unrelated in regards
>>> to the model hierarchy (or at least more complicated than
>>> parent/children relations).
>> This is the reason I moved away from ItemProviders and use EMF
>> Databinding. Most model changes can be reflected in the UI as wished.
>> There is excellent documentation, and if you have an odd use case,
>> please ask here. (i.e. a case where multiple model changes would
>> aggregate to a single UI change or the other way around).
>>
>>
>> How are the notifications generated, and
>>> where is decided which itemprovider gets notified? Because the generated
>>> notifyChanged(Notification) method you mentioned contains a switch-case
>>> to decide if the notification applies to the node. But after further
>>> inspection i saw that only notifications about the particular objects
>>> this ItemProvider adapts come through anyway (which is basically the
>>> problem here).
>>>
>>> Greetings
>>> Samuel
>>>
>>> On 05.07.2014 08:45, Ed Merks wrote:
>>>> Samuel,
>>>>
>>>> No, there's no prescribed way. If it's affected by the labels of
>>>> contained children, one can often write the child item provider so it
>>>> generates notifications for the parent, e.g.,
>>>> org.eclipse.emf.ecore.provider.EGenericTypeItemProvider.notifyChanged(Notification).
>>>>
>>>>
>>>>
>>>> On 04/07/2014 5:48 PM, Samuel Leisering wrote:
>>>>> Hi
>>>>>
>>>>> Is there a documentation about how notifications in ItemProviders are
>>>>> handled? I am currently using the item providers generated by the CDO
>>>>> generator, and notifications are working just fine. After modifying
>>>>> some
>>>>> of those Item Providers i noticed that there is no obvious way to
>>>>> subscribe item providers to events happening on other items.
>>>>> I created a tree where some nodes display content of other items, and
>>>>> therefore should be changed when this content changes. Is there a
>>>>> predefined way to do this?
>>>>>
>>>>>
>>>>> Greetings
>>>>> Samuel
>>>>
>>>
>>
>
Re: [EMF] Change-Notifications in ItemProviders [message #1396518 is a reply to message #1395881] Tue, 08 July 2014 12:07 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 07-07-14 16:31, Felix Dorner wrote:
> On 07/07/2014 14:18, Christophe Bouhier wrote:
>> On 06-07-14 21:10, Samuel Leisering wrote:
>>> Hi,
>>>
>>> thats too bad. Some of those affected objects are unrelated in regards
>>> to the model hierarchy (or at least more complicated than
>>> parent/children relations).
>> This is the reason I moved away from ItemProviders and use EMF
>> Databinding. Most model changes can be reflected in the UI as wished.
>> There is excellent documentation, and if you have an odd use case,
>> please ask here. (i.e. a case where multiple model changes would
>> aggregate to a single UI change or the other way around).
>
> Excellent documentation? Where? Thanks for sharing. I only ever found
> blog posts
Yes, that's what I meant. Perhaps I should rephrase excellent to
satisfying, at least for me.

Tom's been through great length to share what he did, with a series of
blogs.

http://tomsondev.bestsolution.at/category/databinding/emf//


and the like with warnings that this and that changed and
> will change in the future.. and felt I'm the only one using it and other
> people at work look at me like I'm crazy to use that even for the
> simplest things.

>
> Felix
>
Previous Topic:[CDO] Microsoft SQL does not create Tables
Next Topic:[EMF / CDO] Unexpected "Class not found exception"
Goto Forum:
  


Current Time: Wed Aug 21 01:10:41 GMT 2019

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

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

Back to the top