Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText TextViewer instead of Editor
XText TextViewer instead of Editor [message #875558] Wed, 23 May 2012 00:40 Go to next message
Eclipse UserFriend
Hi,

Have created a simple query language to use with a BIRT ODA driver.

Instead of using the XText generated Editor for my query language, I
will need to present the user with a TextViewer in the DataSet Wizard in
order to specify the query string.

I am still a novice when it comes to XText, but I did look but haven't
found any documentation, examples or newsgroup entries regarding a use
case like this.

Can anyone give me an example on how to go about doing this.

thanks,
John
Re: XText TextViewer instead of Editor [message #875765 is a reply to message #875558] Wed, 23 May 2012 10:09 Go to previous messageGo to next message
Massimo Rabbi is currently offline Massimo RabbiFriend
Messages: 20
Registered: November 2010
Location: Padova
Junior Member
Hi John,
I don't know if it will fits your needs but you can use a plugin provided by the guys of Itemis, used in the Yakindu project.
They provide a JFace integration plugin and more stuff too.
I used it in my project (simply used the StyledTextXtextAdapter class). It worked fine.

More information can be found watching this video tutorial took from the latest EclipseCon Europe.
hxxp://www.fosslc.org/drupal/content/tmf-meets-gmf-combining-graphical-and-textual-modeling

Repository for the yakindu project is here:
hxxp://code.google.com/a/eclipselabs.org/p/yakindu/

You can checkout their code and have a look.
You can install the integration features you need using this update site
hxxp://updates.yakindu.com/indigo/milestones

Hope this helps.
Massimo.
Re: XText TextViewer instead of Editor [message #875939 is a reply to message #875558] Wed, 23 May 2012 15:32 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 2936
Registered: July 2009
Senior Member
John,

if you use Xtext 2.3, you may want to have a look at the
EmbeddedEditorFactory.

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

Am 23.05.12 02:40, schrieb John E. Conlon:
> Hi,
>
> Have created a simple query language to use with a BIRT ODA driver.
>
> Instead of using the XText generated Editor for my query language, I
> will need to present the user with a TextViewer in the DataSet Wizard in
> order to specify the query string.
>
> I am still a novice when it comes to XText, but I did look but haven't
> found any documentation, examples or newsgroup entries regarding a use
> case like this.
>
> Can anyone give me an example on how to go about doing this.
>
> thanks,
> John
>
>
>
>
Re: XText TextViewer instead of Editor [message #876125 is a reply to message #875765] Thu, 24 May 2012 00:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi Massimo,

Yes, that worked great!

I did the same as you and used the StyledTextXtextAdapter with a StyleText.

The video tutorial was very informative as well.

thanks much,

John

On 05/23/2012 05:09 AM, Massimo Rabbi wrote:
> Hi John,
> I don't know if it will fits your needs but you can use a plugin
> provided by the guys of Itemis, used in the Yakindu project.
> They provide a JFace integration plugin and more stuff too.
> I used it in my project (simply used the StyledTextXtextAdapter class).
> It worked fine.
>
> More information can be found watching this video tutorial took from the
> latest EclipseCon Europe.
> hxxp://www.fosslc.org/drupal/content/tmf-meets-gmf-combining-graphical-and-textual-modeling
>
>
> Repository for the yakindu project is here:
> hxxp://code.google.com/a/eclipselabs.org/p/yakindu/
>
> You can checkout their code and have a look.
> You can install the integration features you need using this update site
> hxxp://updates.yakindu.com/indigo/milestones
>
> Hope this helps.
> Massimo.
Re: XText TextViewer instead of Editor [message #876268 is a reply to message #875939] Thu, 24 May 2012 09:23 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 322
Registered: July 2009
Location: Gothenburg
Senior Member
Sebastian Zarnekow wrote on Wed, 23 May 2012 17:32
John,
if you use Xtext 2.3, you may want to have a look at the
EmbeddedEditorFactory.


Hi Sebastian,

Would that be the recommended way to use an Xtext editor in a multi-page one too?

regards,
Vlad

[Updated on: Thu, 24 May 2012 12:10]

Report message to a moderator

Re: XText TextViewer instead of Editor [message #876548 is a reply to message #876268] Thu, 24 May 2012 20:25 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 2936
Registered: July 2009
Senior Member
Hi Vlad,

I'd try something along these lines:

public class MultiPageEditor extends MultiPageEditorPart {

@Inject
private Provider<XtextEditor> editorProvider;

private XtextEditor editor;

@Override
protected void createPages() {
try {
editor = editorProvider.get();
int index = addPage(editor, getEditorInput());
setPageText(index, editor.getTitle());
} catch (PartInitException e) {
ErrorDialog.openError(
getSite().getShell(),
"Error creating nested text editor",
null,
e.getStatus());
}
}

@Override
public void doSave(IProgressMonitor monitor) {
editor.doSave(monitor);
}

@Override
public void doSaveAs() {
editor.doSaveAs();
setPageText(0, editor.getTitle());
setInput(editor.getEditorInput());
}

@Override
public boolean isSaveAsAllowed() {
return true;
}

}

The EmbeddedEditorFActory should be used to embed an editor in a
composite that is not an IEditorPart itself.

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

Am 24.05.12 11:23, schrieb Vlad Dumitrescu:
> Sebastian Zarnekow wrote on Wed, 23 May 2012 17:32
>> John,
>> if you use Xtext 2.3, you may want to have a look at the
>> EmbeddedEditorFactory.
>
>
> Hi Sebastian,
>
> Would that be the recommended way to use a Xtext editor in a multi-page
> one too?
>
> regards,
> Vlad
>
Re: XText TextViewer instead of Editor [message #876556 is a reply to message #876548] Thu, 24 May 2012 20:35 Go to previous messageGo to next message
Vlad Dumitrescu is currently offline Vlad DumitrescuFriend
Messages: 322
Registered: July 2009
Location: Gothenburg
Senior Member
Thanks a lot, a code example was more than I expected as an answer! Smile

regards,
Vlad
Re: XText TextViewer instead of Editor [message #905954 is a reply to message #875558] Fri, 31 August 2012 11:10 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 128
Registered: March 2012
Location: Italy
Senior Member

Hi at all,

does it work also on Eclipse 4?

I don't understand what I have to put in my @PostContruct method to see the xtext editor.

Very thank you.
Re: XText TextViewer instead of Editor [message #906357 is a reply to message #905954] Sat, 01 September 2012 07:57 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De SicaFriend
Messages: 128
Registered: March 2012
Location: Italy
Senior Member

I made several steps ahead from yesterday.

Now I've got this doubt: in my part I have to insert a code like this:
StyledText styledText=new StyledText(parent, SWT.BORDER);
		StyledTextXtextAdapter xtextAdapter=new StyledTextXtextAdapter(getInjector());
xtextAdapter.adapt(styledText);


what is "getInjector()"?

Basic Eclipse 4 injection or com.google.inject.Injector that use also in StyledTextXtextAdapter definition? How can I get it?

Thanks all.
Re: XText TextViewer instead of Editor [message #906390 is a reply to message #906357] Sat, 01 September 2012 10:14 Go to previous messageGo to next message
Massimo Rabbi is currently offline Massimo RabbiFriend
Messages: 20
Registered: November 2010
Location: Padova
Junior Member
Hi Tommaso,
I don't know where you get the code snippet you copy-pasted.
However the injector you need to pass there is an instance of com.google.inject.Injector. It should be the injector relative to your dsl language.
You can get this injector via the generated plugin class inside the generated ui XText project (method getInjector(String languageName)).

Regards,
Massimo.
Re: XText TextViewer instead of Editor [message #994043 is a reply to message #876548] Wed, 26 December 2012 08:16 Go to previous messageGo to next message
kavitha Mising name is currently offline kavitha Mising nameFriend
Messages: 8
Registered: March 2011
Junior Member
Hi Sebastian

I did try to use the MPE eq: you have mentioned,

Quote:

public class MultiPageEditor extends MultiPageEditorPart {

@Inject
private Provider<XtextEditor> editorProvider;

private XtextEditor editor;


but for me editor = editorProvider.get(); was giving a null pointer exception

Is there anything else I need to do for the @Injector to populate the values for editorProvider.

Please let me know

Thanks
Kavitha
Re: XText TextViewer instead of Editor [message #994100 is a reply to message #994043] Wed, 26 December 2012 11:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injec
tor.html?m=1

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: XText TextViewer instead of Editor [message #1000729 is a reply to message #994100] Tue, 15 January 2013 10:43 Go to previous messageGo to next message
kavitha Mising name is currently offline kavitha Mising nameFriend
Messages: 8
Registered: March 2011
Junior Member
Hi Christian ,

Thanks for the link, it was really useful. I am able to add XtextEditor on a MultiPageEditor.

Now I have one more issue, I am trying to add the EMF editor as another page on the MPE where the XtextEditor is already added.

How can I link the EMF editor to the xtext input file (the dsl file).

Please let me know your comments.

Thanks,
Kavitha
Re: XText TextViewer instead of Editor [message #1000758 is a reply to message #1000729] Tue, 15 January 2013 11:42 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6485
Registered: July 2009
Senior Member
HI,

sorry have no idea about is. you should be able to access the resource.

~Christian
Previous Topic:Making part of DSL read-only
Next Topic:Line break after multi-line comments using serialization
Goto Forum:
  


Current Time: Sun Nov 23 20:15:36 GMT 2014

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

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