Multiple EMF models in one TreeViewer [message #637354] |
Fri, 05 November 2010 08:09 |
Eclipse User |
|
|
|
Originally posted by: andre.loerchner.david-bs.de
Hi,
in our application we defined a couple of quite complex ecore models.
There are connections between those models but we decided to seperate
them from each other because putting everything into a single one would
result in a rather crowded model.
Now we want to show some aspects of two of those models in the same
TreeViewer. The genmodel is configured to show elements from model2 as
children of model1 and that works as in they show up in the tree. The
problem is how they are displayed: Since elements from model2 are not
handled in the model1 ItemProviderAdapterFactory which is set as
LabelProvider for the TreeViewer they are simply showing as .toString()
with a default icon.
A workaround has been to introduce dummy classes in model1 which hold a
reference to the model2 elements we want to show and "pull up" the
properties from the real model2 element to the dummy. This works so far
but as we continue to add more of those dummies it feels like there
should be a better way.
Can anyone give me an advice as to how this is done "the EMF way"? I am
still new to EMF and it's been a really helpful tool but I am learning
every day and slowly discovering all the possibilities EMF offers.
Thanks,
|
|
|
|
Re: Multiple EMF models in one TreeViewer [message #637364 is a reply to message #637357] |
Fri, 05 November 2010 08:53 |
Eclipse User |
|
|
|
Originally posted by: andre.loerchner.david-bs.de
Thank you very much for your fast reply. That indeed was everything I
needed. I just didn't know a ComposedAdapterFactory existed.
Best regards,
Ed Merks:
> Comments below
>
> alo wrote:
>> Hi,
>>
>> in our application we defined a couple of quite complex ecore models.
>> There are connections between those models but we decided to seperate
>> them from each other because putting everything into a single one
>> would result in a rather crowded model.
>>
>> Now we want to show some aspects of two of those models in the same
>> TreeViewer. The genmodel is configured to show elements from model2 as
>> children of model1 and that works as in they show up in the tree. The
>> problem is how they are displayed: Since elements from model2 are not
>> handled in the model1 ItemProviderAdapterFactory which is set as
>> LabelProvider for the TreeViewer they are simply showing as
>> .toString() with a default icon.
> I'd expect the registered item provider adapter factories to kick in. Of
> course that depends on setting things up that way.
>>
>> A workaround has been to introduce dummy classes in model1 which hold
>> a reference to the model2 elements we want to show and "pull up" the
>> properties from the real model2 element to the dummy. This works so
>> far but as we continue to add more of those dummies it feels like
>> there should be a better way.
> That sounds not so good.
>>
>> Can anyone give me an advice as to how this is done "the EMF way"? I
>> am still new to EMF and it's been a really helpful tool but I am
>> learning every day and slowly discovering all the possibilities EMF
>> offers.
> Did you create the adapter factory something like this?
>
> adapterFactory = new
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Reg istry.INSTANCE);
>
>
> adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
> adapterFactory.addAdapterFactory(new <<Xyz>>ItemProviderAdapterFactory());
> adapterFactory.addAdapterFactory(new
> ReflectiveItemProviderAdapterFactory());
>
>>
>> Thanks,
|
|
|
Powered by
FUDForum. Page generated in 0.02119 seconds