Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF Xpand templates
GMF Xpand templates [message #648340] Wed, 12 January 2011 13:59 Go to next message
Eclipse UserFriend
Originally posted by: hodaie.in.tum.de

Hi,

I'm new to code generation templates in GMF and would be greatful if
someone could help me on following issues:

1. We have some very simple .xpt templates to change the generated
diagram classes. These templates are not complicated, for example they
just add some "... extends ClassXYZ" to generated classes so that they
inherit some other code from ourside. We also don't use any extensions.
The templates worked well with Ganymede and GMF 2.1 but as we upgraded
to Helios and GMF 2.2 they have no effect any more. There is no error
message at all, the code is generated without problems but the generated
classes do not inherit from our code any more. Can someone point out
where the problem can be?

2. In relation to the question above, in general which versions of GMF
along wiht eclipse platform are recommanded? Should we continue to use
Ganymede and GMF 2.1 or start using Helios and GMF 2.2? I have read that
extension mechanism is changed in GMF 2.2 from Xtend to QVTO. We are
probably going to write more complex templates that need to use
extensions. And in general can some one please summerize the differences
of GMF 2.1 and GMF 2.2?

3. We need the diagrams to be created directly from gmf genmodel,
whithout further manual customizations. We have created an Ecore model,
generate genmodel and diagram genmodel from it. The code can be
generated without probelem. However we need to do some changes in
plugin.xml of generated diagram (adding some extension points) and also
we need to add some java classes to generated diagram code (for example
we have our custom implementation of model element opener or property
tester). How should we do it? I looked and org.eclipse.gmf.codegen
plugin and saw there a hierarchy of folders under templates containing
..xpt files. I guess we must also follow exact this hierarchy in our
templates. What does this hierarchy of different folders in templates
mean? Where should we exactly put our templates (Both for plugin.xml
customisations and generated java classes)? And also how should we
create a new java class using templates? I tried <<FILE>> statement for
XPand, but actually this class is not related to any entity in our model.

4. Also In relation to above question, Is there any tutorial about GMF
Xpand that answers those questions in a step by step manner? Also what I
expect is how to use extensions (using QVTO and/or Xtend)? We have
googled so much, but could'nt find anything that guides us in
customizing code generation of GMF.

Thanks in advance for your help,

Best Regards,
Zardosht
Re: GMF Xpand templates [message #648346 is a reply to message #648340] Wed, 12 January 2011 14:27 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

Eclipse User wrote on Wed, 12 January 2011 14:59
Originally posted by: hodaie.in.tum.de
1. We have some very simple .xpt templates to change the generated
diagram classes. These templates are not complicated, for example they
just add some "... extends ClassXYZ" to generated classes so that they
inherit some other code from ourside. We also don't use any extensions.
The templates worked well with Ganymede and GMF 2.1 but as we upgraded
to Helios and GMF 2.2 they have no effect any more. There is no error
message at all, the code is generated without problems but the generated
classes do not inherit from our code any more. Can someone point out
where the problem can be?



Tempates can have been renamed.


Eclipse User wrote on Wed, 12 January 2011 14:59

2. In relation to the question above, in general which versions of GMF
along wiht eclipse platform are recommanded? Should we continue to use
Ganymede and GMF 2.1 or start using Helios and GMF 2.2? I have read that
extension mechanism is changed in GMF 2.2 from Xtend to QVTO. We are
probably going to write more complex templates that need to use
extensions. And in general can some one please summerize the differences
of GMF 2.1 and GMF 2.2?



I think that you should use the version of GMF corresponding to the release train of Eclipse.

To see what's new: http://wiki.eclipse.org/GMF_New_and_Noteworthy

Eclipse User wrote on Wed, 12 January 2011 14:59

3. We need the diagrams to be created directly from gmf genmodel,
whithout further manual customizations. We have created an Ecore model,
generate genmodel and diagram genmodel from it. The code can be
generated without probelem. However we need to do some changes in
plugin.xml of generated diagram (adding some extension points) and also
we need to add some java classes to generated diagram code (for example
we have our custom implementation of model element opener or property
tester). How should we do it? I looked and org.eclipse.gmf.codegen
plugin and saw there a hierarchy of folders under templates containing
..xpt files. I guess we must also follow exact this hierarchy in our
templates. What does this hierarchy of different folders in templates
mean? Where should we exactly put our templates (Both for plugin.xml
customisations and generated java classes)? And also how should we
create a new java class using templates? I tried <<FILE>> statement for
XPand, but actually this class is not related to any entity in our model.



Yes you need to respect the folder hierarchy.
I don'k know for now, but some times ago when I ask, <<FILE>> was not yet implemented.



Eclipse User wrote on Wed, 12 January 2011 14:59

4. Also In relation to above question, Is there any tutorial about GMF
Xpand that answers those questions in a step by step manner? Also what I
expect is how to use extensions (using QVTO and/or Xtend)? We have
googled so much, but could'nt find anything that guides us in
customizing code generation of GMF.



You can take a look to my blog article: http://www.bonitasoft.org/blog/eclipse/customize-your-gmf-ed itor-by-customizing-templates/

Regards,


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: GMF Xpand templates [message #649114 is a reply to message #648346] Mon, 17 January 2011 17:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hodaie.in.tum.de

Hi,

thank you Aurelien for you reply.
I had already looked at your blog. It was useful, howerver it does not
answer all my questions. What I need is to understand how exactly the
whole GMF Xpand works (e.g. the relationship between templates,
extensions and generated code for example).
Can you explain more what do mean with "tempalte can be renamed"? Do the
template names have something to do with classes being generated form them?
Does GMF Xpand have a workflow, like the one being explaind in this
Xpand tutorial
( http://eclipse.dzone.com/articles/getting-started-code?utm_s ource=feedburner&utm_medium=feed&utm_campaign=Feed%3 A+eclipsezone%2Ffrontpage+%28Eclipse+Zone%29),
or the one generated in example Xpand project (created using new project
wizard)?
How can I generate for example something like following class? Should I
create a Foo.xpt template? If yes where should I put this file in
template hierarchy? From where is it called? I looked at templates in
org.eclipse.gmf.codegen. There is nothing like a workfolow that calls
templates (in sense one can see in example Xpand project).

package my.package;

import otherpackage;

public class Foo {

//how to get diagram package name in a generic way?
private String diagramPackageName = "";

public void buz(){
new ClassInOtherPackage().sayHello();
}
}


From your blog I can see you have done lots of stuff with GMF Xpand in
Bonita Open Solution. Is the software opensource? If yes, can you please
send me a link to repository, so that I can look at what you did? Thanks
you for your help.

Regards,
Zardosht.



Am 12.01.2011 15:27, schrieb Aurelien Pupier:
> Hi,
>
> Eclipse User wrote on Wed, 12 January 2011 14:59
>> Originally posted by: hodaie.in.tum.de
>> 1. We have some very simple .xpt templates to change the generated
>> diagram classes. These templates are not complicated, for example they
>> just add some "... extends ClassXYZ" to generated classes so that they
>> inherit some other code from ourside. We also don't use any
>> extensions. The templates worked well with Ganymede and GMF 2.1 but as
>> we upgraded to Helios and GMF 2.2 they have no effect any more. There
>> is no error message at all, the code is generated without problems but
>> the generated classes do not inherit from our code any more. Can
>> someone point out where the problem can be?
>
>
> Tempates can have been renamed.
>
>
> Eclipse User wrote on Wed, 12 January 2011 14:59
>> 2. In relation to the question above, in general which versions of GMF
>> along wiht eclipse platform are recommanded? Should we continue to use
>> Ganymede and GMF 2.1 or start using Helios and GMF 2.2? I have read
>> that extension mechanism is changed in GMF 2.2 from Xtend to QVTO. We
>> are probably going to write more complex templates that need to use
>> extensions. And in general can some one please summerize the
>> differences of GMF 2.1 and GMF 2.2?
>
>
> I think that you should use the version of GMF corresponding to the
> release train of Eclipse.
>
> To see what's new: http://wiki.eclipse.org/GMF_New_and_Noteworthy
>
> Eclipse User wrote on Wed, 12 January 2011 14:59
>> 3. We need the diagrams to be created directly from gmf genmodel,
>> whithout further manual customizations. We have created an Ecore
>> model, generate genmodel and diagram genmodel from it. The code can be
>> generated without probelem. However we need to do some changes in
>> plugin.xml of generated diagram (adding some extension points) and
>> also we need to add some java classes to generated diagram code (for
>> example we have our custom implementation of model element opener or
>> property tester). How should we do it? I looked and
>> org.eclipse.gmf.codegen plugin and saw there a hierarchy of folders
>> under templates containing ..xpt files. I guess we must also follow
>> exact this hierarchy in our templates. What does this hierarchy of
>> different folders in templates mean? Where should we exactly put our
>> templates (Both for plugin.xml customisations and generated java
>> classes)? And also how should we create a new java class using
>> templates? I tried <<FILE>> statement for XPand, but actually this
>> class is not related to any entity in our model.
>
>
> Yes you need to respect the folder hierarchy.
> I don'k know for now, but some times ago when I ask, <<FILE>> was not
> yet implemented.
>
>
>
> Eclipse User wrote on Wed, 12 January 2011 14:59
>> 4. Also In relation to above question, Is there any tutorial about GMF
>> Xpand that answers those questions in a step by step manner? Also what
>> I expect is how to use extensions (using QVTO and/or Xtend)? We have
>> googled so much, but could'nt find anything that guides us in
>> customizing code generation of GMF.
>
>
> You can take a look to my blog article:
> http://www.bonitasoft.org/blog/eclipse/customize-your-gmf-ed itor-by-customizing-templates/
>
>
> Regards,
>
Re: GMF Xpand templates [message #649115 is a reply to message #649114] Mon, 17 January 2011 18:06 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

just a quick answer for the source code: http://www.bonitasoft.org/websvn/


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: GMF Xpand templates [message #649589 is a reply to message #649114] Wed, 19 January 2011 20:18 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

Eclipse User wrote on Mon, 17 January 2011 18:51
Originally posted by: hodaie.in.tum.de
Can you explain more what do mean with "tempalte can be renamed"?


between 2.1 and 2.2, there was several modifications into the templates in order to integrate Qvto. So some templates from 2.1 might have been renamed or deleted.

Eclipse User wrote on Mon, 17 January 2011 18:51

Do the
template names have something to do with classes being generated form them?


Not necesseraly, but there is a logic between name of the the template and the generated classes.

Eclipse User wrote on Mon, 17 January 2011 18:51

Does GMF Xpand have a workflow, like the one being explaind in this
Xpand tutorial
( http://eclipse.dzone.com/articles/getting-started-code?utm_s ource=feedburner&utm_medium=feed&utm_campaign=Feed%3 A+eclipsezone%2Ffrontpage+%28Eclipse+Zone%29),
or the one generated in example Xpand project (created using new project
wizard)?
How can I generate for example something like following class? Should I
create a Foo.xpt template? If yes where should I put this file in
template hierarchy? From where is it called? I looked at templates in
org.eclipse.gmf.codegen. There is nothing like a workfolow that calls
templates (in sense one can see in example Xpand project).

package my.package;

import otherpackage;

public class Foo {

//how to get diagram package name in a generic way?
private String diagramPackageName = "";

public void buz(){
new ClassInOtherPackage().sayHello();
}
}



I don't know how to generate new files integrated directly from the gmfgen.
At least, you should be able to integrate another generation workflow before/after the classical generation using your preferred language (XPand, ATL, JET, Qvto, ...)
If anyone have a better answer I am also interested Smile

Eclipse User wrote on Mon, 17 January 2011 18:51

From your blog I can see you have done lots of stuff with GMF Xpand in
Bonita Open Solution. Is the software opensource? If yes, can you please
send me a link to repository, so that I can look at what you did? Thanks
you for your help.


As said quickly previously:
Bonita Open Solution is Open Source.
You can browse the code from here: http://www.bonitasoft.org/websvn/
For the .xpt template files: bonita-studio->plugins->org.bonitasoft.studio-model

Regards,


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Previous Topic:Outline problem
Next Topic:Extending palette
Goto Forum:
  


Current Time: Thu Apr 25 13:54:07 GMT 2024

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

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

Back to the top