how to get the reachable objects from an EObject [message #929864] |
Mon, 01 October 2012 16:55  |
Eclipse User |
|
|
|
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 11:10   |
Eclipse User |
|
|
|
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 05:56   |
Eclipse User |
|
|
|
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
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03934 seconds