Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Embeded single line editor
Embeded single line editor [message #1746347] Thu, 27 October 2016 11:45 Go to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

Hi,

We are already rather successfully using the embedded editor in our application. For a new use case it would be great to have a single line text field with an Xtext grammar.

In principle it is working however the look and feal is rather awkward. The main issue is that the withParent method is creating the sourceviewar with scrollbars enabled per default. The respective code is:
final XtextSourceViewer viewer = this.sourceViewerFactory.createSourceViewer(
					parent, 
					annotationRuler, 
					null, // overviewRuler
					false, // showAnnotationOverview 
					SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);


For my use-case it would be better if I could set the style to SWT.BORDER | SWT.SINGLE.

Therefore my question would be can I somehow overwrite or provide my own seourceViewerFactory which would take car of this?

Or is there an other option how to better handle this?

Thanks in advance,
Alois
Re: Embeded single line editor [message #1746348 is a reply to message #1746347] Thu, 27 October 2016 11:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you can simply add a binding for the factory

def Class<?extends XtextSourceViewer.Factory> bindXtextSourceViewer$Factory() {
return MyXSVF
}

or you could subclass the EmbeddedEditorFactory


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Embeded single line editor [message #1746349 is a reply to message #1746348] Thu, 27 October 2016 11:58 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

Will there be always the same factory injected or is the sourceviewer factory depending on my language?

I'm not so fit with dependency injection, Therefore where would I put our code?
Re: Embeded single line editor [message #1746350 is a reply to message #1746349] Thu, 27 October 2016 12:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
It is per Lang as you create the embedded editor factory with the injector of your lang

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Embeded single line editor [message #1746352 is a reply to message #1746350] Thu, 27 October 2016 12:31 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

Jep I got this. I meant the XTextSourceViewerFactory. But it looks like that the default implementation gets injected. so I could inherit from this and provide my own. SO my last dumb question would be how I do the binding. I played a bit with xxxUIModule class but was not very lucky. Could you be so kind and point me to some docs or to give me a hint for the names to be used there?
Re: Embeded single line editor [message #1746353 is a reply to message #1746352] Thu, 27 October 2016 12:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
The code above should do the trick

Besides this there is the section on dependen injection in the docs
https://eclipse.org/Xtext/documentation/302_configuration.html#dependency-injection

And the one on xtend on xtend-Lang.org



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Embeded single line editor [message #1746357 is a reply to message #1746353] Thu, 27 October 2016 13:07 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

Thanks for the hints. Reading helps Wink

Works now as a charm and opens up completely new posibilities for our application (e.g., DSLs in table or tree view fields or graphical editors. Very cool.
Re: Embeded single line editor [message #1746440 is a reply to message #1746357] Fri, 28 October 2016 17:55 Go to previous messageGo to next message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi guys,

We are trying to create a form editor aprox 10 textfields and each of them should be an embedded xtext editor for the same language, so I would like to know if you have idea or if you have tested something similar in order to check if the lazy initialisation for each editor could affect the performance.

Regards,
Luis
Re: Embeded single line editor [message #1746441 is a reply to message #1746440] Fri, 28 October 2016 17:57 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
No and no from my side

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Dealing with Eclipse XText syntax errors
Next Topic:How to validate wildcard package import
Goto Forum:
  


Current Time: Thu Apr 25 14:33:43 GMT 2024

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

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

Back to the top