Generated Code of ViewMap [message #900251] |
Mon, 06 August 2012 07:45  |
Eclipse User |
|
|
|
Hi,
I want to change the generated code of the .
Therefore, I figured out, that the code is stated "ClassBody" attribute in the genmodel:
Top Level Node ItemFigure
- Inner Class Viewmap ItemFigure
- Class Body
However, I don't want to customize the generator model directly.
Can anyone tell me where the class body's content comes from ?!
Thanks
|
|
|
|
Re: Generated Code of ViewMap [message #902581 is a reply to message #902580] |
Sat, 18 August 2012 15:51   |
Eclipse User |
|
|
|
Ok, now i'm a step further. top::Descriptor references a template in the templates folder of the "org.eclipse.gmf.graphdef.codegen" plugin.
This calls another template Figure which declares a method ClassBody
«EXPAND Figure::ClassBody(compilationUnitName(self)) FOR actualFigure»
And here is where the figure content is finally created:
«DEFINE ClassBody(cuName : String) FOR gmfgraph::RealFigure-»
/**
* @generated
*/
public «cuName»() {
«clearBorders()-»
«EXPAND Layout::Init('this') FOR layout-»
«EXPAND Attrs::Init('this')-»
«IF not (children)[gmfgraph::Figure]->isEmpty()-»
createContents();
}
«EXPAND Children::CreateChildren-»
«EXPAND Border::InitMethods»
«ELSE-»
}
«ENDIF-»
«EXPAND Extras::extraMethods»
«EXPAND additions-»
«ENDDEFINE»
Now you can extend/modifiy the class body according to your needs. Hope this helps.
Regards,
Rami
[Updated on: Sat, 18 August 2012 16:25] by Moderator Report message to a moderator
|
|
|
Re: Generated Code of ViewMap [message #1011386 is a reply to message #902581] |
Tue, 19 February 2013 13:06  |
Eclipse User |
|
|
|
Rami, thanks for your reply on this topic. It really helped me a lot so far.
But i guess you missed to mention that the ClassBody definition you are reffering to is in the file "org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt".
However, it still does not work for me to add custom code to the inner class during the generation process.
It seems to me that this file is not touched by the GMF generator process at all. It might be due to the fact that it is not from the "org.eclipse.gmf.codegen" plug-in directory but from the "org.eclipse.gmf.graphdef.codegen" instead!?
Am i wrong on using the "Figure.xpt" file?
Or do i miss to include some other files in my project (such as the "Map2Gen.qvto" from the "org.eclipse.gmf.bridge/transformed/" Plug-in directory)?
Or do i have to define/set somewhere that the generation process uses the "org.eclipse.gmf.graphdef.codegen" plug-in directory as well as the "org.eclipse.gmf.codegen"?
|
|
|
Powered by
FUDForum. Page generated in 0.03456 seconds