Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Multiple EMF models in one TreeViewer
Multiple EMF models in one TreeViewer [message #637354] Fri, 05 November 2010 08:09 Go to next message
Eclipse UserFriend
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 #637357 is a reply to message #637354] Fri, 05 November 2010 08:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
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,


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Multiple EMF models in one TreeViewer [message #637364 is a reply to message #637357] Fri, 05 November 2010 08:53 Go to previous message
Eclipse UserFriend
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,
Previous Topic:Show a list of child elements in property view
Next Topic:use CDO in an JEE environment?
Goto Forum:
  


Current Time: Thu Apr 18 02:53:11 GMT 2024

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

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

Back to the top