Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtend2] for non xtext model(How can i programmatically run transformation for non xtext model via Xtend2)
[Xtend2] for non xtext model [message #1264421] Wed, 05 March 2014 08:01 Go to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Hi all,

i have non-xtext model and i need to run my generator via code not with mwe2. so i want to ask u how can i done this ?

Regards
Re: [Xtend2] for non xtext model [message #1264548 is a reply to message #1264421] Wed, 05 March 2014 10:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
Hi,

this is a bit old but the principles should still apply: http://christiandietrich.wordpress.com/2011/07/29/xtend2-code-generators-with-non-xtext-models/


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: [Xtend2] for non xtext model [message #1265184 is a reply to message #1264548] Wed, 05 March 2014 19:58 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Hi,

Thanks for answer this was very helpful for me.

I do your tutorial step by step. But i have problem i make this project in plug-in project and i want to do transformation on run-time eclipse.

if i understand correctly i need to write mwe2 workflow file on run-time eclipse for make transformation. But i don't want to write mwe2 file i just want to trigger transformation from java code.

Or how can i do this like in xpand. In xpand, i can make mwe file on development eclipse and i can trigger this mwe file on run-time eclipse via java code with given parameters like modelpath?

P.S: run-time Eclipse means This eclipse version have my project as plug-in

(with variables like ($(medolPath) )

and when i run your tutorial i always get error. Files created with right content there is no problem but i always get errror on console like;
0    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'sample.SamplePackage'
163  [main] ERROR esource.generic.XMLEncodingProvider  - Error detecting encoding for file:/C:/Users/unituser/runtime-mdd4cca/xtend2/src-gen/ser.txt
java.io.FileNotFoundException: C:\Users\unituser\runtime-mdd4cca\xtend2\src-gen\ser.txt (The system cannot find the file specified)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(Unknown Source)
	at org.eclipse.emf.ecore.resource.impl.FileURIHandlerImpl.createInputStream(FileURIHandlerImpl.java:99)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:354)
	at org.eclipse.xtext.resource.generic.XMLEncodingProvider.getEncoding(XMLEncodingProvider.java:35)
	at org.eclipse.xtext.generator.JavaIoFileSystemAccess.getEncoding(JavaIoFileSystemAccess.java:140)
	at org.eclipse.xtext.generator.JavaIoFileSystemAccess.generateFile(JavaIoFileSystemAccess.java:81)
	at org.eclipse.xtext.generator.AbstractFileSystemAccess.generateFile(AbstractFileSystemAccess.java:76)
	at sample.SampleGenerator.compile(SampleGenerator.java:37)
	at sample.SampleGenerator._compile(SampleGenerator.java:25)
	at sample.SampleGenerator.compile(SampleGenerator.java:45)
	at sample.SampleGenerator.doGenerate(SampleGenerator.java:18)
	at org.eclipse.xtext.generator.GeneratorComponent.invoke(GeneratorComponent.java:128)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
169  [main] ERROR esource.generic.XMLEncodingProvider  - Error detecting encoding for file:/C:/Users/unituser/runtime-mdd4cca/xtend2/src-gen/ak.txt


Regards

[Updated on: Wed, 05 March 2014 20:12]

Report message to a moderator

Re: [Xtend2] for non xtext model [message #1265192 is a reply to message #1265184] Wed, 05 March 2014 20:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
Hi,

i looks i totally do not understand what you want todo.

if you want to trigger it from java code i dont understand why you ask.
the same question would be: how do i call Integer.valueOf("123") from my java code

how did you call the xpand code? how is the model read...

if you used mwe1 you can translate my workflow to mwe1
you could write a own workflowcompontent
you could do it with pure java ....

it all depends on your needs.




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: [Xtend2] for non xtext model [message #1265200 is a reply to message #1265192] Wed, 05 March 2014 20:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
P.S: the error comes from changes in the access. maybe there should be a another encoding provider used.

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: [Xtend2] for non xtext model [message #1265206 is a reply to message #1265192] Wed, 05 March 2014 20:29 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Hi,

I just need to trigger transformation from Eclipse command on menu contribution.

I guess I need to dig.

Regards
Re: [Xtend2] for non xtext model [message #1265213 is a reply to message #1265206] Wed, 05 March 2014 20:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
Hi,

i blogged on that too, but it should work for non xtext stuff as well....
http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/
maybe you have to put some extra work to get guice stuff running but that should be possible
(building an executable extension factory)


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: [Xtend2] for non xtext model [message #1265238 is a reply to message #1265213] Wed, 05 March 2014 21:20 Go to previous message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
Registered: January 2013
Location: Izmir
Senior Member
Hi,

aaa that works

thank you so much Smile

Regards
Previous Topic:Headless ANT build
Next Topic:xtext with non-emf metamodel
Goto Forum:
  


Current Time: Sun Oct 25 23:41:04 GMT 2020

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

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

Back to the top