Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Generated Code of ViewMap
Generated Code of ViewMap [message #900251] Mon, 06 August 2012 07:45 Go to next message
Matthias N is currently offline Matthias NFriend
Messages: 66
Registered: June 2012
Member
Hi,
I want to change the generated code of the
Inner Class Viewmap
.

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 #902580 is a reply to message #900251] Sat, 18 August 2012 15:48 Go to previous messageGo to next message
Rami D. is currently offline Rami D.Friend
Messages: 14
Registered: August 2012
Junior Member
Hi Matthias,

i also want to modify the generated class body code (the figure inner class of an edit part). What i've found out so far is the responsible plugin that creates the InnerClassViewmap object, namely "org.eclipse.gmf.bridge".
There is a transforms folder which contains a file called Map2Gen.qvto. This in turn contains a helper method defined as follows:

helper GMFGRAPH::FigureDescriptor::viewmap() : GMFGEN::Viewmap {
	if self.actualFigure.isBareInstance() then 
		return object GMFGEN::FigureViewmap {
			figureQualifiedClassName := self.actualFigure.xpand('Runtime::fqn', templateRoots);
		}
	endif;
	return object GMFGEN::InnerClassViewmap { 
		classBody := self.xpand('top::Descriptor::Inner', templateRoots);
		className := self.name.firstToUpper(); -- FIXME InnerClassViewmapProducer has validJavaIdentifier(capName()) 
	};
}


QVT operational is absolutely new to me and I don't understand what this line of code
is actually doing. Maybe we can support each other to lift the secret of the classBody generation Smile

Regards,
Rami

[Updated on: Sat, 18 August 2012 15:49]

Report message to a moderator

Re: Generated Code of ViewMap [message #902581 is a reply to message #902580] Sat, 18 August 2012 15:51 Go to previous messageGo to next message
Rami D. is currently offline Rami D.Friend
Messages: 14
Registered: August 2012
Junior Member
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]

Report message to a moderator

Re: Generated Code of ViewMap [message #1011386 is a reply to message #902581] Tue, 19 February 2013 13:06 Go to previous message
web Mac is currently offline web MacFriend
Messages: 5
Registered: February 2013
Location: Germany
Junior Member
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"?
Previous Topic:How to install GMF runtime?
Next Topic:Programmatically navigate and export Diagram to PNG file
Goto Forum:
  


Current Time: Thu Mar 28 16:24:54 GMT 2024

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

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

Back to the top