Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Code generation during generation of .gmfgen file(looking for templates...)
Code generation during generation of .gmfgen file [message #545025] Tue, 06 July 2010 12:52 Go to next message
m kranz is currently offline m kranzFriend
Messages: 69
Registered: January 2010
Member
hi all

my idea was to change the code for the figures used for all nodes in an editor in the codegen templates. but after some searching i found out that this code is already generated during creation of the .gmfgen file (it is located in the 'classBody' attribute of the 'viewmap' of each node in the 'GenDiagram').

since this code is also generated (and has the usual '@generated' comments), i guess there must be templates for the generation somewhere. so my question is, does anybody know where this templates are located and what's the best way to change them (if any)?

thanks in advance

mkranz
Re: Code generation during generation of .gmfgen file [message #545195 is a reply to message #545025] Wed, 07 July 2010 05:29 Go to previous messageGo to next message
Sven Krause is currently offline Sven KrauseFriend
Messages: 119
Registered: July 2009
Senior Member
Hi,

there are two options for the gmfgen creation you may choose at gen
model creation wizard's the last page:
- java transformation (the default one)
- qvto transformation

and you may choose dynamic templates.

The java transformation is done with the TransformToGenModelOperation
class. The transformation might be executed outside the wizard too. And
you might customize the operation for your own purpose.

Abstract:

ResourceSet resourceSet = ...
org.eclipse.emf.codegen.ecore.genmodel.GenModel genModel = ...
org.eclipse.gmf.mappings.Mapping mapping = ...

org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation
operation = new
org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation
(resourceSet);

operation.loadMappingModel(mapping.eResource().getURI(), progressMonitor);
operation.loadGenModel(genModel.eResource().getURI(), progressMonitor);

operation.setGenURI(gmfGenUri);
org.eclipse.gmf.internal.bridge.transform.TransformOptions options =
operation.getOptions();
options.setUseMapMode(true);
options.setUseRuntimeFigures(true);
options.setFigureTemplatesPath(null);
options.setTransformation(null);
options.setPreReconcileTransform(null);
options.setPostReconcileTransform(null);

IStatus transformationResult =
operation.executeTransformation(progressMonitor);

Sven

Am 06.07.2010 14:52, schrieb mkranz:
> hi all
>
> my idea was to change the code for the figures used for all nodes in an
> editor in the codegen templates. but after some searching i found out
> that this code is already generated during creation of the .gmfgen file
> (it is located in the 'classBody' attribute of the 'viewmap' of each
> node in the 'GenDiagram').
>
> since this code is also generated (and has the usual mailto:'@generated'
> comments), i guess there must be templates for the generation somewhere.
> so my question is, does anybody know where this templates are located
> and what's the best way to change them (if any)?
>
> thanks in advance
>
> mkranz
Re: Code generation during generation of .gmfgen file [message #545272 is a reply to message #545195] Wed, 07 July 2010 10:40 Go to previous messageGo to next message
m kranz is currently offline m kranzFriend
Messages: 69
Registered: January 2010
Member
hi sven

thanks for your in-depth answer. i think the dynamic templates thing is what i'm looking for.
as far as i understand, the 'dynamic templates' field takes the path to my templates folder, right?
so now i only have to find out where the default templates are located.
are they in 'org.eclipse.gmf.codegen' too? didn't look like that.
any hints appreciated.

cheers

marco

[Updated on: Wed, 07 July 2010 10:41]

Report message to a moderator

Re: Code generation during generation of .gmfgen file [message #545279 is a reply to message #545272] Wed, 07 July 2010 10:54 Go to previous messageGo to next message
Sven Krause is currently offline Sven KrauseFriend
Messages: 119
Registered: July 2009
Senior Member
Hi Marco,

I've never used the qvto transformation explicitly. But based on my
experiences: I would expect an full qualified path
(platform://resources/youryPlugin/path).

take a look at
org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation.createGenModelProducer(VisualIdentifierDispenserP rovider)
....
{
URI transfURI =
URI.createURI(getOptions().getMainTransformation().toExterna lForm());
QvtoTransformationHelper helper = new
QvtoTransformationHelper(transfURI);
}

Sven

Am 07.07.2010 12:40, schrieb mkranz:
> hi sven
>
> thanks for your in-depth answer. i think the dynamic templates thing is
> what i'm looking for. as far as i understand, the 'dynamic templates'
> field takes the path to the templates folder, right?
> so now i only have to find out where the default templates are located.
> are they in 'org.eclipse.gmf.codegen' too? didn't look like that.
> any hints appreciated.
>
> cheers
>
> marco
Re: Code generation during generation of .gmfgen file [message #545294 is a reply to message #545279] Wed, 07 July 2010 11:41 Go to previous messageGo to next message
m kranz is currently offline m kranzFriend
Messages: 69
Registered: January 2010
Member
hi sven

uhm, if i understand you right, you suggest to find the path to the default templates by looking into the code?
i do not really understand what's going on there, not sure where the path is taken from.
i guess things like default paths must be in some config file, but i wasn't able to find them yet...
not sure how things like that are handled in eclipse...
i'll now check the dependencies for the templates.
if someone else has an idea, please let me know.

cheers marco

[Updated on: Wed, 07 July 2010 11:42]

Report message to a moderator

Re: Code generation during generation of .gmfgen file [message #545349 is a reply to message #545272] Wed, 07 July 2010 13:34 Go to previous messageGo to next message
Stephane Bouchet is currently offline Stephane BouchetFriend
Messages: 280
Registered: July 2009
Senior Member
hi,
maybe this could help :

http://www.bonitasoft.org/blog/eclipse/customize-your-gmf-ed itor-by-customizing-templates/


Le 07/07/2010 12:40, mkranz a écrit :
> hi sven
>
> thanks for your in-depth answer. i think the dynamic templates thing is
> what i'm looking for. as far as i understand, the 'dynamic templates'
> field takes the path to the templates folder, right?
> so now i only have to find out where the default templates are located.
> are they in 'org.eclipse.gmf.codegen' too? didn't look like that.
> any hints appreciated.
>
> cheers
>
> marco


--
Cheers,

Stéphane Bouchet, OBEO
Re: Code generation during generation of .gmfgen file [message #545379 is a reply to message #545349] Wed, 07 July 2010 15:01 Go to previous messageGo to next message
m kranz is currently offline m kranzFriend
Messages: 69
Registered: January 2010
Member
hi stéphane

thanks for your answer. i know this link, but as far as i see they only
use the codegen templates that are used for generating the code
from the .gmfgen model.
but i am looking for the templates that are used in an earlier step
during creation of the .gmfgen model itself (there is some code
generated into the model, see first post).
and as far as i can see the templates for that are not in 'org.eclipse.gmf.codegen'.

cheers

marco
Re: Code generation during generation of .gmfgen file [message #545384 is a reply to message #545025] Wed, 07 July 2010 15:16 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,

why don't you use Custom Figure in the .gmfgraph?

Regards,


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Code generation during generation of .gmfgen file [message #545599 is a reply to message #545384] Thu, 08 July 2010 11:25 Go to previous messageGo to next message
m kranz is currently offline m kranzFriend
Messages: 69
Registered: January 2010
Member
Aurelien Pupier wrote on Wed, 07 July 2010 11:16
Hi,

why don't you use Custom Figure in the .gmfgraph?

Regards,


hi aurelien

well, all i want to do is
a) change the content of the labels in my figure
b) add listeners so the labels get updated on model change
i don't know if using a custom figure (as the main figure i guess?) would help me in this case.
but since i'm not sure how custom figures work, i'll have a look.

cheers

marco
Re: Code generation during generation of .gmfgen file [message #553396 is a reply to message #545599] Tue, 17 August 2010 12:14 Go to previous messageGo to next message
m kranz is currently offline m kranzFriend
Messages: 69
Registered: January 2010
Member
ok, finally found the templates...
in case anyone else is interested:

they are located in package:

org.eclipse.gmf.graphdef.codegen

to use them, add a root template dir to your project folder, and copy the templates you need (including folder structure!) into it.
in the last step of the "create generator model" wizard you can set the "GMFGraph dynamic templates" root folder.

cheers

marco
Re: Code generation during generation of .gmfgen file [message #553905 is a reply to message #545599] Thu, 19 August 2010 11:42 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

I know that you find a solution but it can be helpful anyway

mkranz wrote on Thu, 08 July 2010 13:25

a) change the content of the labels in my figure


You can use Custom figure. And perhaps just create it fom basic figures provided.

mkranz wrote on Thu, 08 July 2010 13:25

b) add listeners so the labels get updated on model change


This is the way: http://wiki.eclipse.org/GMF_Tips#Making_figures_sensitive_to _attributes_of_semantic_elements


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Previous Topic:Rounded / curved connection
Next Topic:Regarding Z-orders and layers
Goto Forum:
  


Current Time: Tue Apr 23 09:46:21 GMT 2024

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

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

Back to the top