Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Better way to initialize object with sub-objects?
Better way to initialize object with sub-objects? [message #509704] Sun, 24 January 2010 21:20 Go to next message
Christoph Wienands is currently offline Christoph WienandsFriend
Messages: 55
Registered: July 2009
Member
Hello all,

I have just implemented the following functionality in a GMF editor: When a
user creates an object of type A in a diagram, the DSL automatically creates
two contained sub-objects of type B in object of type A. This is because
type A mandates that there are always two contained objects of type B and it
makes the language more usable because the user does not manually have to
create those two objects.

Currently, I modified some generated code in the GMF-generated .diagram
plug-in to add the two B objects. However, this is kind of nasty and I think
there must be a better way. And here is the reason why I am posting this in
the EMF NG...

The GMF code retrieves an object of 'IElementType' that represents the A
class. The 'IElementType' objects are provided by EMF's
'ElementTypeRegistry'. So on this IElementType object, GMF calls the
'getEditCommand' function, which returns an object of type 'ICommand' (named
'configureCommand' in GMF). When debugging, the call returns NULL. However,
I believe that I somehow could register my own configure command so that GMF
automatically executes it. But that's where I lost the trail.

My question is, is this EMF functionality the right place/mechanism for
custom object initialization code? And what is the proper way/place in the
lifecycle/place to hook to register my own edit command?

Thanks a lot,

Christoph
Re: Better way to initialize object with sub-objects? [message #509753 is a reply to message #509704] Mon, 25 January 2010 10:13 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31909
Registered: July 2009
Senior Member
Christoph,

Comments below.

Christoph Wienands wrote:
> Hello all,
>
> I have just implemented the following functionality in a GMF editor: When a
> user creates an object of type A in a diagram, the DSL automatically creates
> two contained sub-objects of type B in object of type A. This is because
> type A mandates that there are always two contained objects of type B and it
> makes the language more usable because the user does not manually have to
> create those two objects.
>
> Currently, I modified some generated code in the GMF-generated .diagram
> plug-in to add the two B objects. However, this is kind of nasty and I think
> there must be a better way. And here is the reason why I am posting this in
> the EMF NG...
>
Using news://new.eclipse.org/eclipse.tools.emf would be better.
> The GMF code retrieves an object of 'IElementType' that represents the A
> class. The 'IElementType' objects are provided by EMF's
> 'ElementTypeRegistry'. So on this IElementType object, GMF calls the
> 'getEditCommand' function, which returns an object of type 'ICommand' (named
> 'configureCommand' in GMF). When debugging, the call returns NULL. However,
> I believe that I somehow could register my own configure command so that GMF
> automatically executes it. But that's where I lost the trail.
>
That's definitely a GMF question.
> My question is, is this EMF functionality the right place/mechanism for
> custom object initialization code? And what is the proper way/place in the
> lifecycle/place to hook to register my own edit command?
>
In a basic generated EMF editor the place to do this would be in the
creation of the child descriptors, i.e., collectNewChildDescriptors, but
GMF doesn't reuse that so I'm not sure what to suggest.

> Thanks a lot,
>
> Christoph
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:MWE: capture log output?
Next Topic:Better way to initialize object with sub-objects?
Goto Forum:
  


Current Time: Sat Jun 19 16:53:07 GMT 2021

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

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

Back to the top