Labels including properties of different objects [message #430123] |
Mon, 11 May 2009 16:14 |
Eclipse User |
|
|
|
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 #430170 is a reply to message #430128] |
Tue, 12 May 2009 18:32 |
Eclipse User |
|
|
|
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 #430207 is a reply to message #430181] |
Wed, 13 May 2009 12:50 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03632 seconds