Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Is there a way to automatically display the classes children of other classes?
Is there a way to automatically display the classes children of other classes? [message #1852391] Fri, 13 May 2022 14:44 Go to next message
Namea lasta is currently offline Namea lastaFriend
Messages: 50
Registered: March 2022
Member
Hello,
Lets say i have a metamodel that contains a class A : "car" and a class B : "motor" inside it.


Is is possible to make that whenever a user create a classe "car", then a class "motor" is automatically created?

Adding to that, both should be displayed.

Thanks
Re: Is there a way to automatically display the classes children of other classes? [message #1852398 is a reply to message #1852391] Fri, 13 May 2022 18:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32563
Registered: July 2009
Senior Member
Your question is "context free". Of course you can create a "car" and a "motor" and if the "car" has a "motor" containment reference you can set the car's motor. But you mention a "user" doing this so I guess this is a question about an editor, I guess the generated editor.

The generated editor uses item providers to create new instances and you can specialize the methods that create such instances, e.g., have a look at org.eclipse.emf.ecore.provider.EModelElementItemProvider.collectNewChildDescriptors(Collection<Object>, Object) where we specialize the creation to create several "pre-populated" EAnnotation instances.

In general, set a breakpoint in the CarImpl constructor and you will see where/where the editor (or wizard) is creating instances and then you know where to specialize the code to also create a motor.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Is there a way to automatically display the classes children of other classes? [message #1852426 is a reply to message #1852398] Mon, 16 May 2022 07:31 Go to previous message
Namea lasta is currently offline Namea lastaFriend
Messages: 50
Registered: March 2022
Member
Very interesting!
I am still a beginner in EMF, i will level up and probably come back here to reread your answer and see how I can implement his. Will write a new answer then.
Previous Topic:[Edapt] Adding a new EPackage cause NPE during Migration
Next Topic:EMF diff Merge usage on this folder?
Goto Forum:
  


Current Time: Fri Dec 02 10:04:46 GMT 2022

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

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

Back to the top