Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EReference] How to change its referred EClass
[EReference] How to change its referred EClass [message #423041] Mon, 22 September 2008 02:13 Go to next message
Wang Liang is currently offline Wang LiangFriend
Messages: 5
Registered: July 2009
Junior Member
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] Mon, 22 September 2008 03:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EReference] How to change its referred EClass [message #1790411 is a reply to message #423042] Sat, 09 June 2018 20:01 Go to previous messageGo to next message
Paul Roubekas is currently offline Paul RoubekasFriend
Messages: 207
Registered: March 2012
Location: Chattanooga, TN USA
Senior Member
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 95 times)
  • Attachment: Snap17.pdf
    (Size: 117.75KB, Downloaded 88 times)


Oxygen 3a
Windows 10
Re: [EReference] How to change its referred EClass [message #1790415 is a reply to message #1790411] Sun, 10 June 2018 07:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 08:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EReference] How to change its referred EClass [message #1790429 is a reply to message #1790417] Sun, 10 June 2018 17:43 Go to previous message
Paul Roubekas is currently offline Paul RoubekasFriend
Messages: 207
Registered: March 2012
Location: Chattanooga, TN USA
Senior Member
Thanks. Ed That answered the question.

Oxygen 3a
Windows 10
Previous Topic:[EMF compare] ExampleLauncher problem
Next Topic:[CDO] View update timing/concurrency
Goto Forum:
  


Current Time: Wed Apr 24 17:48:22 GMT 2024

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

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

Back to the top