Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Embeded single line editor
Embeded single line editor [message #1746347] Thu, 27 October 2016 07:45 Go to next message
Eclipse UserFriend
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 07:50 Go to previous messageGo to next message
Eclipse UserFriend
you can simply add a binding for the factory

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

or you could subclass the EmbeddedEditorFactory
Re: Embeded single line editor [message #1746349 is a reply to message #1746348] Thu, 27 October 2016 07:58 Go to previous messageGo to next message
Eclipse UserFriend
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 08:03 Go to previous messageGo to next message
Eclipse UserFriend
It is per Lang as you create the embedded editor factory with the injector of your lang
Re: Embeded single line editor [message #1746352 is a reply to message #1746350] Thu, 27 October 2016 08:31 Go to previous messageGo to next message
Eclipse UserFriend
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 08:36 Go to previous messageGo to next message
Eclipse UserFriend
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

Re: Embeded single line editor [message #1746357 is a reply to message #1746353] Thu, 27 October 2016 09:07 Go to previous messageGo to next message
Eclipse UserFriend
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 13:55 Go to previous messageGo to next message
Eclipse UserFriend
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 13:57 Go to previous message
Eclipse UserFriend
No and no from my side
Previous Topic:Dealing with Eclipse XText syntax errors
Next Topic:How to validate wildcard package import
Goto Forum:
  


Current Time: Mon May 12 18:34:29 EDT 2025

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

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

Back to the top