Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Labels including properties of different objects
Labels including properties of different objects [message #430123] Mon, 11 May 2009 16:14 Go to next message
Eclipse UserFriend
Originally posted by: Tim.Baumgartner.innovations.de

Hi!

Suppose that labels for instances of an EClass A include an attribute of
a referenced EClass B. Then AItemProviderAdapter does not refresh if the
attribute of b changes (example: Ecore Editor with A=B=EClass and
eSuperTypes as the reference).
I see a few possibilities how to deal with this, but I wonder if someone
knows a somehow optimal solution, i.e. nice code that doesn't perform
too slow. The solution might of course vary depending on additional
requirements like memory consumption.

As an example, one could add AItemProviderAdapter as an
INotifyChangedListener to the AdapterFactory and then examine every
notification for every target. As a variation, AItemProviderAdapter
could be made stateful.

Has anybody some experience with this stuff?

Regards,
Tim
Re: Labels including properties of different objects [message #430128 is a reply to message #430123] Mon, 11 May 2009 22:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tim,

The posting two up from this deals with a similar issue, though simpler
since the container provides the additional information for the label.
Is the reference a containment reference or bidirectional such that the
item provider for B would easily know which A needs to be updated?


Tim Baumgartner wrote:
> Hi!
>
> Suppose that labels for instances of an EClass A include an attribute
> of a referenced EClass B. Then AItemProviderAdapter does not refresh
> if the attribute of b changes (example: Ecore Editor with A=B=EClass
> and eSuperTypes as the reference).
> I see a few possibilities how to deal with this, but I wonder if
> someone knows a somehow optimal solution, i.e. nice code that doesn't
> perform too slow. The solution might of course vary depending on
> additional requirements like memory consumption.
>
> As an example, one could add AItemProviderAdapter as an
> INotifyChangedListener to the AdapterFactory and then examine every
> notification for every target. As a variation, AItemProviderAdapter
> could be made stateful.
>
> Has anybody some experience with this stuff?
>
> Regards,
> Tim
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Labels including properties of different objects [message #430170 is a reply to message #430128] Tue, 12 May 2009 18:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tim.baumgartner.gmx.de

Ed Merks wrote:
> The posting two up from this deals with a similar issue, though simpler
> since the container provides the additional information for the label.

Oops, I didn't read that. But now I posted another suggestion/question
for it.

> Is the reference a containment reference or bidirectional such that the
> item provider for B would easily know which A needs to be updated?

No, it's neither (but an answer for those cases might still be
interesting). But since I use AdapterFactory.adapt(referencedElement,
IItemLabelProvider.class), at least I know that there is an adapter for
the referenced b.

what's better style
1) having B-ItemProviderAdapter fire notifications for instances of A
2) in A-ItemProviderAdapter: b.eAdapters().add(<some member variable>)
3) in A-ItemProviderAdapter: ((IChangeNotifier)
adapterFactory).addNotifyChangedListener(<some member variable>)
4) another possibility?

Regards,
Tim
Re: Labels including properties of different objects [message #430181 is a reply to message #430170] Wed, 13 May 2009 02:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tim,

Comments below.

Tim Baumgartner wrote:
> Ed Merks wrote:
>> The posting two up from this deals with a similar issue, though
>> simpler since the container provides the additional information for
>> the label.
>
> Oops, I didn't read that. But now I posted another suggestion/question
> for it.
>
>> Is the reference a containment reference or bidirectional such that
>> the item provider for B would easily know which A needs to be updated?
>
> No, it's neither (but an answer for those cases might still be
> interesting). But since I use AdapterFactory.adapt(referencedElement,
> IItemLabelProvider.class), at least I know that there is an adapter
> for the referenced b.
>
> what's better style
> 1) having B-ItemProviderAdapter fire notifications for instances of A
That's probably easiest, if it knows the A for which to fire.
> 2) in A-ItemProviderAdapter: b.eAdapters().add(<some member variable>)
This is perhaps more elegant in that B isn't intimately tied to and
aware of A's label needs.
> 3) in A-ItemProviderAdapter: ((IChangeNotifier)
> adapterFactory).addNotifyChangedListener(<some member variable>)
Listen to everything. I'd not considered that. I'm still not sure how
a given B will know the right A or even As.
> 4) another possibility?
>
> Regards,
> Tim


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Labels including properties of different objects [message #430207 is a reply to message #430181] Wed, 13 May 2009 12:50 Go to previous message
Eclipse UserFriend
Originally posted by: Tim.Baumgartner.innovations.de

Thanks, Ed

>> what's better style
>> 1) having B-ItemProviderAdapter fire notifications for instances of A
> That's probably easiest, if it knows the A for which to fire.
>> 2) in A-ItemProviderAdapter: b.eAdapters().add(<some member variable>)
> This is perhaps more elegant in that B isn't intimately tied to and
> aware of A's label needs.
>> 3) in A-ItemProviderAdapter: ((IChangeNotifier)
>> adapterFactory).addNotifyChangedListener(<some member variable>)
> Listen to everything. I'd not considered that. I'm still not sure how
> a given B will know the right A or even As.

OK, that's true. In the general case, 2) seems to be the best solution.
1) would really have difficulties to be sure it gets all As.


Tim
Previous Topic:[CDO] Problem commiting transaction with ESupertypes
Next Topic:Placing the same object twice in an EList?
Goto Forum:
  


Current Time: Thu Apr 25 07:03:04 GMT 2024

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

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

Back to the top