Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Using the EMF classes and from a new plugin
Using the EMF classes and from a new plugin [message #48536] Fri, 05 June 2009 11:06 Go to next message
Eclipse UserFriend
I am trying to use the EMF classes generated from xtext to save the file to
the text format, but when I save the file it saves as xml. I am not using
the editor plugin that is generated, but instead another hello world plugin
that includes the plugin that has the generated xtext emf model. I must be
missing something simple (some google juice hook maybe).

Here is the code I use to create and save the file.
XtextResourceSet rsrcSet = new XtextResourceSet();
URI uri = URI.createFileURI(file.getAbsolutePath()+".tmp");

Resource theConnRes = rsrcSet.createResource(uri);
ParseStatementsList sl =
Package.eINSTANCE.getFactory().createParseStatementsList();
TerminatedStatement sc =
Package.eINSTANCE.getFactory().createTerminatedStatement();

sl.getStatements().add(sc);
theConnRes.getContents().add(sl);
theConnRes.save(rsrcSet.getURIResourceMap());
Re: Using the EMF classes and from a new plugin [message #48601 is a reply to message #48536] Fri, 05 June 2009 11:30 Go to previous messageGo to next message
Eclipse UserFriend
Got around this by.

a)using the correct file extension for the file.
b)including the ui text editor generated plugin.
Seems odd that I need the UI plugin, but it works for now.

"drew" <drew@acm.org> wrote in message
news:h0bc98$8ai$1@build.eclipse.org...
>I am trying to use the EMF classes generated from xtext to save the file to
>the text format, but when I save the file it saves as xml. I am not using
>the editor plugin that is generated, but instead another hello world plugin
>that includes the plugin that has the generated xtext emf model. I must be
>missing something simple (some google juice hook maybe).
>
> Here is the code I use to create and save the file.
> XtextResourceSet rsrcSet = new XtextResourceSet();
> URI uri = URI.createFileURI(file.getAbsolutePath()+".tmp");
>
> Resource theConnRes = rsrcSet.createResource(uri);
> ParseStatementsList sl =
> Package.eINSTANCE.getFactory().createParseStatementsList();
> TerminatedStatement sc =
> Package.eINSTANCE.getFactory().createTerminatedStatement();
>
> sl.getStatements().add(sc);
> theConnRes.getContents().add(sl);
> theConnRes.save(rsrcSet.getURIResourceMap());
>
>
Re: Using the EMF classes and from a new plugin [message #48659 is a reply to message #48536] Fri, 05 June 2009 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Hi Drew,

I assume "tmp" is the file extension for your specific DSL?
Can you confirm, that theConnRes is an instance of XtextResource?

Regards,
Sebastian

Am 05.06.2009 17:06 Uhr, schrieb drew:
> I am trying to use the EMF classes generated from xtext to save the file to
> the text format, but when I save the file it saves as xml. I am not using
> the editor plugin that is generated, but instead another hello world plugin
> that includes the plugin that has the generated xtext emf model. I must be
> missing something simple (some google juice hook maybe).
>
> Here is the code I use to create and save the file.
> XtextResourceSet rsrcSet = new XtextResourceSet();
> URI uri = URI.createFileURI(file.getAbsolutePath()+".tmp");
>
> Resource theConnRes = rsrcSet.createResource(uri);
> ParseStatementsList sl =
> Package.eINSTANCE.getFactory().createParseStatementsList();
> TerminatedStatement sc =
> Package.eINSTANCE.getFactory().createTerminatedStatement();
>
> sl.getStatements().add(sc);
> theConnRes.getContents().add(sl);
> theConnRes.save(rsrcSet.getURIResourceMap());
>
>
Re: Using the EMF classes and from a new plugin [message #48688 is a reply to message #48601] Fri, 05 June 2009 11:45 Go to previous message
Eclipse UserFriend
Hi Drew,

please find my comment below.

Am 05.06.2009 17:30 Uhr, schrieb drew:
> Got around this by.
>
> a)using the correct file extension for the file.

nice :-)

> b)including the ui text editor generated plugin.

Please have a look at the plugin.xml of your editor plugin and find a
secion <!-- Resource factories -->.

If you want to use your resource without the ui plugin, you'll have to
come up with something similar in your runtime plugin.

Regards,
Sebastian

> Seems odd that I need the UI plugin, but it works for now.
>
> "drew"<drew@acm.org> wrote in message
> news:h0bc98$8ai$1@build.eclipse.org...
>> I am trying to use the EMF classes generated from xtext to save the file to
>> the text format, but when I save the file it saves as xml. I am not using
>> the editor plugin that is generated, but instead another hello world plugin
>> that includes the plugin that has the generated xtext emf model. I must be
>> missing something simple (some google juice hook maybe).
>>
>> Here is the code I use to create and save the file.
>> XtextResourceSet rsrcSet = new XtextResourceSet();
>> URI uri = URI.createFileURI(file.getAbsolutePath()+".tmp");
>>
>> Resource theConnRes = rsrcSet.createResource(uri);
>> ParseStatementsList sl =
>> Package.eINSTANCE.getFactory().createParseStatementsList();
>> TerminatedStatement sc =
>> Package.eINSTANCE.getFactory().createTerminatedStatement();
>>
>> sl.getStatements().add(sc);
>> theConnRes.getContents().add(sl);
>> theConnRes.save(rsrcSet.getURIResourceMap());
>>
>>
>
>
Previous Topic:Xtext Plan
Next Topic:[XText] Attaching a behavioral extension
Goto Forum:
  


Current Time: Tue Jul 22 01:59:56 EDT 2025

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

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

Back to the top