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 #622045] Mon, 25 January 2010 02:01 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 #622046 is a reply to message #622045] Mon, 25 January 2010 10:13 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
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:Better way to initialize object with sub-objects?
Next Topic:Subversive intent to MTF
Goto Forum:
  


Current Time: Thu Apr 25 05:11:38 GMT 2024

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

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

Back to the top