|
Re: Cast DynamicEObjectImpl to EMF model element [message #1699594 is a reply to message #1699533] |
Thu, 25 June 2015 09:42 |
|
Le 24/06/2015 21:50, qwer qwer a écrit :
> Hi everyone,
>
> I'm using a Java service to create a label for a component of my editor.
> The label consists of many parts. The reference to the java service
> works properly and I'm calling it in this way: [self.createLabel()/].
> The service method looks like this:
> public String createLabel(EObject eObject) {
> ....
> return ((MyObject)eObject).getSomeProperty();
> }
>
> The problem is that I'm not able to cast eObject to my EMF generated
> object (MyObject) because eObject is of type DynamicEObjectImpl and I
> don't know how to get MyObject from DynamicEObjectImpl and if that's
> possible. Do you have any ideas how to make this work? I need the actual
> object (MyObject) which is passed to the service method.
If you use DynamicEObject, you need to use EMF's refective APIs, as the
Java classes and methods do not exist in that case.
somehting like
eObject.eGet(eObject.eClass().getEStructuralFeature("someProperty"))
--
Pierre-Charles David - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Powered by
FUDForum. Page generated in 0.03219 seconds