Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xtext2 xtend2] How to generate one file based on multiple models?
[xtext2 xtend2] How to generate one file based on multiple models? [message #698644] Tue, 19 July 2011 21:30 Go to next message
R.M. Morrien is currently offline R.M. MorrienFriend
Messages: 9
Registered: July 2009
Junior Member
As an xtext beginner I managed to get the Statemachine example working. I added the generation of html to the example to test Xtend. My test project generates 1 statemachine html file per statemachine model.

This is achieved by my .xtend file:

class StatemachineGenerator implements IGenerator {
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
fsa.generateFile(resource.className+".html", toHtmlCode(resource.contents.head as Statemachine))
}
...
}

testA.statemachine => testA.html
testB.statemachine => testB.html
testC.statemachine => testC.html

Now I would like to generate an index.html file that links to all my statemachines. I would like to iterate through all statemachine models in the 'context' / classpath.
What would be the best approach? Can I prevent generating the index.html file 3 times?

Thank you, Martijn


Re: [xtext2 xtend2] How to generate one file based on multiple models? [message #698647 is a reply to message #698644] Tue, 19 July 2011 21:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13588
Registered: July 2009
Senior Member
Hi,

Karsten blogged on this http://kthoms.wordpress.com/2011/07/12/xtend-generating-from-multiple-input-models/

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [xtext2 xtend2] How to generate one file based on multiple models? [message #699068 is a reply to message #698647] Wed, 20 July 2011 19:01 Go to previous messageGo to next message
R.M. Morrien is currently offline R.M. MorrienFriend
Messages: 9
Registered: July 2009
Junior Member
I implemented the solution from Karsten's blog. It works like a charm, thank you.
Re: [xtext2 xtend2] How to generate one file based on multiple models? [message #702686 is a reply to message #699068] Tue, 26 July 2011 17:13 Go to previous messageGo to next message
Carmela  is currently offline Carmela Friend
Messages: 10
Registered: July 2011
Junior Member
Hi,

I'm trying to follow the instructions of the blog, but for a beginner as I am, it's not obvious for me where I should introduce those changes.
Which files should I change or create?

Many thanks,
Carmela
Re: [xtext2 xtend2] How to generate one file based on multiple models? [message #702698 is a reply to message #702686] Tue, 26 July 2011 17:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13588
Registered: July 2009
Senior Member
Hi,

its quite easy:
create IGenerator2 (in the runtime plugin or somewhere on the path of the runtime module) and JavaProjectBasedBuilderParticipant2 (in the UI plugin or somewhere on the path of the ui plugin). change DomainmodelGenerator in the Runtime plugin.
change DomainmodelRuntimeModule and DomainmodelUiModule

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [xtext2 xtend2] How to generate one file based on multiple models? [message #703162 is a reply to message #702698] Wed, 27 July 2011 08:40 Go to previous message
Carmela  is currently offline Carmela Friend
Messages: 10
Registered: July 2011
Junior Member
Got it! Thank you!
Previous Topic:generator providing simple XML output
Next Topic:Integrating DSL in TableViewer (XtextResource?)
Goto Forum:
  


Current Time: Fri Sep 18 15:12:56 GMT 2020

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

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

Back to the top