Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » how to get the reachable objects from an EObject
how to get the reachable objects from an EObject [message #929864] Mon, 01 October 2012 20:55 Go to next message
Junior Lekane Nimpa is currently offline Junior Lekane NimpaFriend
Messages: 23
Registered: September 2012
Junior Member
Hello everyone,
i am quite new to EMF and i want to implement a property sheet to display some properties of EObjects. Actually i am facing a problem. I want to display all types that an ETypedElement can take as value. But i don't know how to get all those reachable types.
Can someone help me?
Any help would be really appreciate
regards
Junior
Re: how to get the reachable objects from an EObject [message #929898 is a reply to message #929864] Mon, 01 October 2012 21:37 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 847
Registered: July 2009
Senior Member
Hi, Junior,

Have a look at the implementation of getChoiceOfValues() in the
ItemPropertyDescriptorWithUniqueChoiceOfValueLabels inner class in the
EModelElementItemProvider for an example.

Cheers,

Christian

On 2012-10-01 20:55:55 +0000, Junior Lekane Nimpa said:

> Hello everyone,
> i am quite new to EMF and i want to implement a property sheet to
> display some properties of EObjects. Actually i am facing a problem. I
> want to display all types that an ETypedElement can take as value. But
> i don't know how to get all those reachable types.
> Can someone help me?
> Any help would be really appreciate
> regards
> Junior
Re: how to get the reachable objects from an EObject [message #934016 is a reply to message #929898] Fri, 05 October 2012 15:10 Go to previous messageGo to next message
Junior Lekane Nimpa is currently offline Junior Lekane NimpaFriend
Messages: 23
Registered: September 2012
Junior Member
Hello ,
Thanks christian for your reply. I had a look at the implementation of getChoicesOfValues, but since i am new to EMF, i could not get smart.
Basically, my problem is as follows.
I am implementing property sheet pages to visualize some properties of EObjects
and i want to user to be able to set the eType of a selected ETypedElement in an advanced property sheet. To do this, i use a ComboBoxViewerCellEditor.
But i don't know what should be the input of the cellEditor, so that it display for example the following:

EBoolean
EChar
EString
...

I tried the following:
ComboBoxViewerCellEditor.setInput(EcorePackage.Literals.ECLASSIFIER); 

But i only get the attributes of the MetaObject EClassifier displayed.
I also tried the following

IItemPropertyDescriptor descriptor = new ItemPropertyDescriptor(new   EcoreItemProviderAdapterFactory(),null,null,EcorePackage.Literals.ETYPED_ELEMENT__ETYPE);	   
 result = descriptor.getChoiceOfValues(typedElement);

i only get the classes that are contained in my .ecore file.
But how do i get all predefined types like EBoolean,EString,... and all classes, that are contained in my .ecore file together as input of the ComboBoxViewerCellEditor?

Any hint and/or answer is really welcome
Regards
Junior
Re: how to get the reachable objects from an EObject [message #934799 is a reply to message #934016] Sat, 06 October 2012 09:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26287
Registered: July 2009
Senior Member
You'd need a content provider and a label provider for that; the
contents presumably will be computed by the content produced by the
content provider.

What you'll want is very similar to
org.eclipse.emf.ecore.provider.ETypedElementItemProvider.addETypePropertyDescriptor(...).new
ItemPropertyDescriptorWithUniqueChoiceOfValueLabels()
{...}.getChoiceOfValues(Object)

If you have an ETypedElement why don't get use
EcoreItemProviderAdapterFactory to get an adapter for
IItemPropertySource and then
org.eclipse.emf.edit.provider.IItemPropertySource.getPropertyDescriptor(Object,
Object) to get the property descriptor (the second argument should be
EcorePackage.Literals.ETYPED_ELEMENT__ETYPE) from which you can call
getChoiceOfValues. If you use EMF's content and label providers in the
cell editor, you can use
org.eclipse.emf.edit.provider.ItemProvider.ItemProvider(Collection<?>)
to create an input object that will list these choices.


On 05/10/2012 5:10 PM, Junior Lekane Nimpa wrote:
> Hello ,
> Thanks christian for your reply. I had a look at the implementation of
> getChoicesOfValues, but since i am new to EMF, i could not get smart.
> Basically, my problem is as follows.
> I am implementing property sheet pages to visualize some properties of
> EObjects
> and i want to user to be able to set the eType of a selected
> ETypedElement in an advanced property sheet. To do this, i use a
> ComboBoxViewerCellEditor. But i don't know what should be the input of
> the cellEditor, so that it display for example the following:
>
> EBoolean
> EChar
> EString
> ..
>
> I tried the following:
>
> ComboBoxViewerCellEditor.setInput(EcorePackage.Literals.ECLASSIFIER);
> But i only get the attributes of the MetaObject EClassifier displayed.
> I also tried the following
>
>
> IItemPropertyDescriptor descriptor = new ItemPropertyDescriptor(new
> EcoreItemProviderAdapterFactory(),null,null,EcorePackage.Literals.ETYPED_ELEMENT__ETYPE);
> result = descriptor.getChoiceOfValues(typedElement);
>
> i only get the classes that are contained in my .ecore file.
> But how do i get all predefined types like EBoolean,EString,... and
> all classes, that are contained in my .ecore file together as input of
> the ComboBoxViewerCellEditor?
> Any hint and/or answer is really welcome
> Regards
> Junior
>
Re: how to get the reachable objects from an EObject [message #937743 is a reply to message #934799] Tue, 09 October 2012 08:17 Go to previous message
Junior Lekane Nimpa is currently offline Junior Lekane NimpaFriend
Messages: 23
Registered: September 2012
Junior Member
Hi Ed,
many thanks for your reply.
Now i understand a little bit more.
Best regards
Junior
Previous Topic:Serialize only selected objects....
Next Topic:[net4j] Configuring the HTTP Acceptor
Goto Forum:
  


Current Time: Mon Dec 22 00:52:40 GMT 2014

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

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