Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » opening a xtext editor without a file
opening a xtext editor without a file [message #650357] Mon, 24 January 2011 15:26 Go to next message
No real name is currently offline No real nameFriend
Messages: 11
Registered: November 2010
Junior Member
Hi,

I´m trying to open the xtext editor without a file, i have tried to implement different classes like ieditorinput , istorage , idocumentprovider , but i cant make it work perfectly

I manage to open the editor with an istorageeditorinput but when i change something in it throws an excepcion because the model in the editor is null.

I especially have a problem getting the model for the editor without having an ifile.

So how can i open the editor without a file?? what should i extend or implement for this ??

Thanks

Re: opening a xtext editor without a file [message #650494 is a reply to message #650357] Tue, 25 January 2011 09:28 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Why don't you want an IFile? Where should your model come from or get
stored?

The usualy hook for these things in Eclipse is implementing your own
IEditorInput. So you should maybe have a try in that direction.
If you have an existing model instantiated in an EMF resource, you can
use the org.eclipse.xtext.ui.editor.info.ResourceWorkingCopyFileEdit orInput
as we do in the GMF example.


Am 24.01.11 16:26, schrieb manyacampeon3@hotmail.com:
> Hi,
>
> I´m trying to open the xtext editor without a file, i have tried to
> implement different classes like ieditorinput , istorage ,
> idocumentprovider , but i cant make it work perfectly
> I manage to open the editor with an istorageeditorinput but when i
> change something in it throws an excepcion because the model in the
> editor is null.
>
> I especially have a problem getting the model for the editor without
> having an ifile.
>
> So how can i open the editor without a file?? what should i extend or
> implement for this ??
>
> Thanks
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: opening a xtext editor without a file [message #650593 is a reply to message #650357] Tue, 25 January 2011 16:19 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 11
Registered: November 2010
Junior Member
In the application i'm making i want that when you create a new file opens an editor with a string from an inputstrem buffer that i have in memory and when the user saves the file in the editor there the file is created.

With the IEditorInput i manage to open something like this in the default text editor , but when i tried it in the xtext editor, the ieditorinput since it extends istorageeditorinput the procedure sets the model in null, and when the editor is change it throws a validation exception because the model is null.

I impemented my own documentprovider for my editorinput so that i can create the model for the editor, but there is where im stuck because i cant create the model y in the filedocumentprovider just sets the ifile as the model for the editor.
I found this http://wiki.eclipse.org/Xtext/FAQ that gives a code for creating a model with a inputStream but it didn't work.

Where is the GMF example that you mentioned ??


Thanks


Re: opening a xtext editor without a file [message #650731 is a reply to message #650593] Wed, 26 January 2011 10:03 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
You could try to
1) Using a StingInputStream to load your string into an XtextResource,
similar to
Resource r = resourceSet.createResource(uriOfFutureFile);
r.load(new StringInputStream(contentString);

2) Use an ResourceWorkingCopyFileEditorInput to get an editor input for
that and open an XtextEditor with that input.

The GMF example is shipped with Xtext. You get the code into your
workspace using New->Example->...


Am 25.01.11 17:19, schrieb manyacampeon3@hotmail.com:
> In the application i'm making i want that when you create a new file
> opens an editor with a string from an inputstrem buffer that i have in
> memory and when the user saves the file in the editor there the file is
> created.
>
> With the IEditorInput i manage to open something like this in the
> default text editor , but when i tried it in the xtext editor, the
> ieditorinput since it extends istorageeditorinput the procedure sets the
> model in null, and when the editor is change it throws a validation
> exception because the model is null.
>
> I impemented my own documentprovider for my editorinput so that i can
> create the model for the editor, but there is where im stuck because i
> cant create the model y in the filedocumentprovider just sets the ifile
> as the model for the editor.
> I found this http://wiki.eclipse.org/Xtext/FAQ that gives a code for
> creating a model with a inputStream but it didn't work.
>
> Where is the GMF example that you mentioned ??
>
>
> Thanks
>
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: opening a xtext editor without a file [message #899786 is a reply to message #650357] Thu, 02 August 2012 11:10 Go to previous messageGo to next message
Philipp M. Fischer is currently offline Philipp M. FischerFriend
Messages: 67
Registered: November 2010
Location: Germany
Member
Hi there,

We are currently concerned with a similar issue. We also do have a string in memory that we want to manipulate using an Xtext editor. We don't want to have any file interaction. Is there any easier way like just calling the editor with that string?

Cheers

Phil
Re: opening a xtext editor without a file [message #899789 is a reply to message #899786] Thu, 02 August 2012 11:16 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Phil,

please look into the
org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 02.08.12 13:10, schrieb Phil M. Fischer:
> Hi there,
>
> We are currently concerned with a similar issue. We also do have a
> string in memory that we want to manipulate using an Xtext editor. We
> don't want to have any file interaction. Is there any easier way like
> just calling the editor with that string?
>
> Cheers
>
> Phil
Previous Topic:From 2.1 to 2.3
Next Topic:Split XText Grammar into multiple files
Goto Forum:
  


Current Time: Sat Dec 05 09:31:54 GMT 2020

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

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

Back to the top