Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Correct way to initialize sub-objects?
Correct way to initialize sub-objects? [message #509884] Mon, 25 January 2010 16:21
Christoph Wienands is currently offline Christoph WienandsFriend
Messages: 55
Registered: July 2009
Hello all,

First of all, I previously asked this question in the group but the answer there was that the "proper EMF
way" does not apply to a solution with GMF. Therefore, I hope you don't mind
this double-post.

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. Specifically, I modified the
'doExecuteWithResult' method in the generated CreateCommand class of the
respective model class. However, this is kind of ugly and I think there must
be a better way.

During execution of the creation command, 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 functionality the right place and mechanism for
custom object initialization code? And what is the proper place in the
lifecycle and in code to to register my own edit command?

Thanks a lot,

Previous Topic:running diagram in debug
Next Topic:Double border
Goto Forum:

Current Time: Sun Apr 18 10:01:37 GMT 2021

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

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

Back to the top