Home » Modeling » EMF » How to best display child object attributes via ITableItemLabelProvider
|
Re: How to best display child object attributes via ITableItemLabelProvider [message #403866 is a reply to message #403865] |
Tue, 26 September 2006 18:21 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Mario,
One way another you need to produce a ViewerNotification with Person as
the object and with a boolean indicating that the label is affected.
You could do this by specializing the AddressItemProvider to produce
such notifications (and then be sure the adapter has actually been
created, which normally happens because the object is adapted to ask it
for a label or children) or you could have the PersonItemProvider attach
an adapter to the Address to filter its notifications, much like
AddressItemProvider.notifyChanged would do; probably you'll need to make
the item provider stateful in this case and you'll probably want to be
sure to remove the adapter when the item provider is disposed.
Mario Winterer wrote:
> Hi!
>
> I've a question concerning my ITableItemLabelProvider implementation.
> In short: I want to have a JFace table with several columns
> visualizing object attributes mixed with attributes of their child
> object(s).
>
> Therefore imagine the following (simplified) (emf)model:
>
> class Person {
> String name;
> Address address; // containment
> }
>
> class Address {
> String street;
> String city;
> String zip;
> }
>
> Now I want to "enhance" the generated PersonItemLabelProvider to
> implement ITableItemLabelProvider.
>
> Concrete I want PersonItemLabelProvider to provide labels for four
> columns where column zero should be the person's name, and columns one
> to three should be the person's address fields.
>
> The straight-forward implementation (direct model access via getters)
> works fine, but when I change some attributes of the Address
> object(s), those changes are not reflected in my JFace table because
> no label refresh occures.
>
> I can see clearly why this does not work, but so far I've found no
> satisfying solution to this problem (All solutions seem to be some
> kind of "hack" or workaround).
>
> What's the best way to implement the method getColumnText(Object, int)
> with full viewer-update/refresh support?
>
> Thanks in advance,
> Mario
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to best display child object attributes via ITableItemLabelProvider [message #403869 is a reply to message #403866] |
Tue, 26 September 2006 18:40 |
Mario Winterer Messages: 136 Registered: July 2009 |
Senior Member |
|
|
Hi Ed,
thanks for your quick response.
Specializing AddressItemProvider is no good solution for my purpose,
because I want to use it in several other situations in which that
specialization is not desired.
My final conclusion - and this seems to be one of your suggestions - was
to access the person's address via its AddressItemProvider and to
register an INotifyChangeListener on it that converts
Address-ViewerNotifications to Person-ViewerNotifications.
The disadvantage of this solution is that - as you wrote - I have to
make both, the PersonItemProvider as well as the AddressItemProvider
stateful. This is a little bit annoying because now an adaption of the
gen.model is required to make some internal implementation work.
But I think I can live with that...
Thanks,
Mario
Ed Merks wrote:
> Mario,
>
> One way another you need to produce a ViewerNotification with Person as
> the object and with a boolean indicating that the label is affected.
> You could do this by specializing the AddressItemProvider to produce
> such notifications (and then be sure the adapter has actually been
> created, which normally happens because the object is adapted to ask it
> for a label or children) or you could have the PersonItemProvider attach
> an adapter to the Address to filter its notifications, much like
> AddressItemProvider.notifyChanged would do; probably you'll need to make
> the item provider stateful in this case and you'll probably want to be
> sure to remove the adapter when the item provider is disposed.
>
>
> Mario Winterer wrote:
>> Hi!
>>
>> I've a question concerning my ITableItemLabelProvider implementation.
>> In short: I want to have a JFace table with several columns
>> visualizing object attributes mixed with attributes of their child
>> object(s).
>>
>> Therefore imagine the following (simplified) (emf)model:
>>
>> class Person {
>> String name;
>> Address address; // containment
>> }
>>
>> class Address {
>> String street;
>> String city;
>> String zip;
>> }
>>
>> Now I want to "enhance" the generated PersonItemLabelProvider to
>> implement ITableItemLabelProvider.
>>
>> Concrete I want PersonItemLabelProvider to provide labels for four
>> columns where column zero should be the person's name, and columns one
>> to three should be the person's address fields.
>>
>> The straight-forward implementation (direct model access via getters)
>> works fine, but when I change some attributes of the Address
>> object(s), those changes are not reflected in my JFace table because
>> no label refresh occures.
>>
>> I can see clearly why this does not work, but so far I've found no
>> satisfying solution to this problem (All solutions seem to be some
>> kind of "hack" or workaround).
>>
>> What's the best way to implement the method getColumnText(Object, int)
>> with full viewer-update/refresh support?
>>
>> Thanks in advance,
>> Mario
|
|
|
Re: How to best display child object attributes via ITableItemLabelProvider [message #403874 is a reply to message #403869] |
Tue, 26 September 2006 19:28 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Mario,
You could still create a specialized override that's used only in the
context of the table. This is similar to what I did with
XSDSemanticItemProviderAdapterFactory which has local classes for all
the overrides so that the basic generated item providers and the basic
factory are not modified at all. Probably this pattern would be best
for your scenario. That way the basic things can still be stateless,
but the override factory will make the appropriate things stateful or do
overrides that are appropriate only for that context.
Mario Winterer wrote:
> Hi Ed,
>
> thanks for your quick response.
> Specializing AddressItemProvider is no good solution for my purpose,
> because I want to use it in several other situations in which that
> specialization is not desired.
>
> My final conclusion - and this seems to be one of your suggestions -
> was to access the person's address via its AddressItemProvider and to
> register an INotifyChangeListener on it that converts
> Address-ViewerNotifications to Person-ViewerNotifications.
>
> The disadvantage of this solution is that - as you wrote - I have to
> make both, the PersonItemProvider as well as the AddressItemProvider
> stateful. This is a little bit annoying because now an adaption of the
> gen.model is required to make some internal implementation work.
> But I think I can live with that...
>
> Thanks,
> Mario
>
>
> Ed Merks wrote:
>> Mario,
>>
>> One way another you need to produce a ViewerNotification with Person
>> as the object and with a boolean indicating that the label is
>> affected. You could do this by specializing the AddressItemProvider
>> to produce such notifications (and then be sure the adapter has
>> actually been created, which normally happens because the object is
>> adapted to ask it for a label or children) or you could have the
>> PersonItemProvider attach an adapter to the Address to filter its
>> notifications, much like AddressItemProvider.notifyChanged would do;
>> probably you'll need to make the item provider stateful in this case
>> and you'll probably want to be sure to remove the adapter when the
>> item provider is disposed.
>>
>>
>> Mario Winterer wrote:
>>> Hi!
>>>
>>> I've a question concerning my ITableItemLabelProvider implementation.
>>> In short: I want to have a JFace table with several columns
>>> visualizing object attributes mixed with attributes of their child
>>> object(s).
>>>
>>> Therefore imagine the following (simplified) (emf)model:
>>>
>>> class Person {
>>> String name;
>>> Address address; // containment
>>> }
>>>
>>> class Address {
>>> String street;
>>> String city;
>>> String zip;
>>> }
>>>
>>> Now I want to "enhance" the generated PersonItemLabelProvider to
>>> implement ITableItemLabelProvider.
>>>
>>> Concrete I want PersonItemLabelProvider to provide labels for four
>>> columns where column zero should be the person's name, and columns
>>> one to three should be the person's address fields.
>>>
>>> The straight-forward implementation (direct model access via
>>> getters) works fine, but when I change some attributes of the
>>> Address object(s), those changes are not reflected in my JFace table
>>> because no label refresh occures.
>>>
>>> I can see clearly why this does not work, but so far I've found no
>>> satisfying solution to this problem (All solutions seem to be some
>>> kind of "hack" or workaround).
>>>
>>> What's the best way to implement the method getColumnText(Object,
>>> int) with full viewer-update/refresh support?
>>>
>>> Thanks in advance,
>>> Mario
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to best display child object attributes via ITableItemLabelProvider [message #403876 is a reply to message #403874] |
Tue, 26 September 2006 19:40 |
Mario Winterer Messages: 136 Registered: July 2009 |
Senior Member |
|
|
Sounds interesting; maybe this is what I'm searching for.
I'll make a code investigation. :-)
Thanks,
Mario
Ed Merks wrote:
> Mario,
>
> You could still create a specialized override that's used only in the
> context of the table. This is similar to what I did with
> XSDSemanticItemProviderAdapterFactory which has local classes for all
> the overrides so that the basic generated item providers and the basic
> factory are not modified at all. Probably this pattern would be best
> for your scenario. That way the basic things can still be stateless,
> but the override factory will make the appropriate things stateful or do
> overrides that are appropriate only for that context.
>
>
> Mario Winterer wrote:
>> Hi Ed,
>>
>> thanks for your quick response.
>> Specializing AddressItemProvider is no good solution for my purpose,
>> because I want to use it in several other situations in which that
>> specialization is not desired.
>>
>> My final conclusion - and this seems to be one of your suggestions -
>> was to access the person's address via its AddressItemProvider and to
>> register an INotifyChangeListener on it that converts
>> Address-ViewerNotifications to Person-ViewerNotifications.
>>
>> The disadvantage of this solution is that - as you wrote - I have to
>> make both, the PersonItemProvider as well as the AddressItemProvider
>> stateful. This is a little bit annoying because now an adaption of the
>> gen.model is required to make some internal implementation work.
>> But I think I can live with that...
>>
>> Thanks,
>> Mario
>>
>>
>> Ed Merks wrote:
>>> Mario,
>>>
>>> One way another you need to produce a ViewerNotification with Person
>>> as the object and with a boolean indicating that the label is
>>> affected. You could do this by specializing the AddressItemProvider
>>> to produce such notifications (and then be sure the adapter has
>>> actually been created, which normally happens because the object is
>>> adapted to ask it for a label or children) or you could have the
>>> PersonItemProvider attach an adapter to the Address to filter its
>>> notifications, much like AddressItemProvider.notifyChanged would do;
>>> probably you'll need to make the item provider stateful in this case
>>> and you'll probably want to be sure to remove the adapter when the
>>> item provider is disposed.
>>>
>>>
>>> Mario Winterer wrote:
>>>> Hi!
>>>>
>>>> I've a question concerning my ITableItemLabelProvider implementation.
>>>> In short: I want to have a JFace table with several columns
>>>> visualizing object attributes mixed with attributes of their child
>>>> object(s).
>>>>
>>>> Therefore imagine the following (simplified) (emf)model:
>>>>
>>>> class Person {
>>>> String name;
>>>> Address address; // containment
>>>> }
>>>>
>>>> class Address {
>>>> String street;
>>>> String city;
>>>> String zip;
>>>> }
>>>>
>>>> Now I want to "enhance" the generated PersonItemLabelProvider to
>>>> implement ITableItemLabelProvider.
>>>>
>>>> Concrete I want PersonItemLabelProvider to provide labels for four
>>>> columns where column zero should be the person's name, and columns
>>>> one to three should be the person's address fields.
>>>>
>>>> The straight-forward implementation (direct model access via
>>>> getters) works fine, but when I change some attributes of the
>>>> Address object(s), those changes are not reflected in my JFace table
>>>> because no label refresh occures.
>>>>
>>>> I can see clearly why this does not work, but so far I've found no
>>>> satisfying solution to this problem (All solutions seem to be some
>>>> kind of "hack" or workaround).
>>>>
>>>> What's the best way to implement the method getColumnText(Object,
>>>> int) with full viewer-update/refresh support?
>>>>
>>>> Thanks in advance,
>>>> Mario
|
|
|
Goto Forum:
Current Time: Tue Sep 24 17:32:24 GMT 2024
Powered by FUDForum. Page generated in 0.04529 seconds
|