Skip to main content



      Home
Home » Modeling » EMF » [EReference] How to change its referred EClass
[EReference] How to change its referred EClass [message #423041] Sun, 21 September 2008 22:13 Go to next message
Eclipse UserFriend
Hi, All,

I met a problem. How can I change EReference's referred EClass. There is
getEReferenceType method to retrieve information about this EClass.
However, it seems no way to change it.


Thanks.
Re: [EReference] How to change its referred EClass [message #423042 is a reply to message #423041] Sun, 21 September 2008 23:01 Go to previous messageGo to next message
Eclipse UserFriend
Wang,

Use setEType. EReference.eReferenceType and EAttribute.eAttributeType
are each derived from EStructuralFeature.eType.



Wang Liang wrote:
> Hi, All,
>
> I met a problem. How can I change EReference's referred EClass. There
> is getEReferenceType method to retrieve information about this EClass.
> However, it seems no way to change it.
>
>
> Thanks.
>
Re: [EReference] How to change its referred EClass [message #1790411 is a reply to message #423042] Sat, 09 June 2018 16:01 Go to previous messageGo to next message
Eclipse UserFriend
I am on EMF 2.13.0

Auto complete does not show anything of the pattern setEType.*

What Property setting is needed on the EReference in the .ecore model for the setEType method to be generated by "Generate Model Code"?

Please see attached screen captures of more details.



  • Attachment: Snap16.pdf
    (Size: 102.13KB, Downloaded 129 times)
  • Attachment: Snap17.pdf
    (Size: 117.75KB, Downloaded 118 times)
Re: [EReference] How to change its referred EClass [message #1790415 is a reply to message #1790411] Sun, 10 June 2018 03:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi

You appear to be confusing metamodel levels.

The ETypedElement.setEType(EClassifier) is available in EReference since Ecore.ecore defines an ETypedElement.eType property and because EReference is derived from ETypedElement.

If you do not see setEType in the JDT editor when the source context is an EReference, then either this is a bug in JDT (very unlikely) or you have managed to adjust JDT's preferences so that this completion is not offered. I have accidentally dug this hole once, it is very confusing. I strongly recommend keeping completion preferences at their defaults. Reset them in the preference page.

(Note the the definition of ETypedElement.eType the the Ecore metamodel is itself defined by an EReference from the Ecore metametmodel, which is also Ecore.ecore).

In the more conventional direction, a setEType will only be generated for a DepictionPart in your model if you define a DepictionPart.eType property. What this property will do is dependent on your implementation. You appear to be looking for re-classification which neither EMF nor most other OO technologies support. You can implement it in EMF but it is very tricky and certainly not a recommended approach for a non-expert.

More likely you want the concept of a Role, which unfortunately has other meanings making a Google search hard. "reclassification role metamodel" finds "Extending OO Metamodels Towards Dynamic Object Roles" for me.
https://pdfs.semanticscholar.org/cda2/2f50302d0e63dfe2d0d0e372511d76794549.pdf

Regards

Ed Willink
Re: [EReference] How to change its referred EClass [message #1790417 is a reply to message #1790415] Sun, 10 June 2018 04:11 Go to previous messageGo to next message
Eclipse UserFriend
I can't tell what type "d" is but it appears to have no setter methods. If its is Depication there will only be a getDepicationParts method which returns a list to which you can add DepicationPart instances. In no case is a setter generated for a multi-valued feature because the getter returns a list that can be modified. You should only expect a setEType method if you've modeled a single-valued feature named eType.
Re: [EReference] How to change its referred EClass [message #1790429 is a reply to message #1790417] Sun, 10 June 2018 13:43 Go to previous message
Eclipse UserFriend
Thanks. Ed That answered the question.
Previous Topic:[EMF compare] ExampleLauncher problem
Next Topic:[CDO] View update timing/concurrency
Goto Forum:
  


Current Time: Sun Nov 02 03:16:22 EST 2025

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

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

Back to the top