Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext editor in a component(Embedding an Xtext editor in a JFace/SWT component)
Xtext editor in a component [message #658343] Tue, 08 March 2011 01:01 Go to next message
Balint Torok is currently offline Balint TorokFriend
Messages: 7
Registered: July 2009
Junior Member
Hello,

Xtext generates a very nice editor. Is it possible in any way to put that editor into a regular JFace/SWT component? This way the editor could be embedded in a view or a wizard.

Thanks,
Balint
Re: Xtext editor in a component [message #658389 is a reply to message #658343] Tue, 08 March 2011 09:33 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
In org.eclipse.xtext.ui.codetemplates.ui there is some code demoing an
Xtext editor in a Text widget, but it has not been extracted for easy
reuse yet.

Am 08.03.11 02:01, schrieb Balint Torok:
> Hello,
>
> Xtext generates a very nice editor. Is it possible in any way to put
> that editor into a regular JFace/SWT component? This way the editor
> could be embedded in a view or a wizard.
>
> Thanks,
> Balint


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Xtext editor in a component [message #775682 is a reply to message #658389] Fri, 06 January 2012 14:10 Go to previous messageGo to next message
Tobias Böhm is currently offline Tobias BöhmFriend
Messages: 21
Registered: January 2012
Junior Member
Hello,
I'm really interested in doing that too.
Is there any chance of getting a tutorial or sample code for including an editor in a SWT component?

Cheers,
Tobi
Re: Xtext editor in a component [message #776130 is a reply to message #658343] Sat, 07 January 2012 15:26 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi,

check this http://code.google.com/a/eclipselabs.org/p/xtext-forms-integration/,
It's based on version 1.0, but I successfully use it in 2.0. It formed the base to embed xtext in various ways,
like in Dialog, forms etc... (See screenshot).

You will need to adapt a few things according to your needs, but I recall it wasn't too hard. (sorry this was 6 months ago).

I also saw, xtext 2.2 has embedded editor part of the release.

http://www.eclipse.org/Xtext/releasenotes/2.2.0/new_and_noteworthy.php


Cheers Christophe
Re: Xtext editor in a component [message #776251 is a reply to message #658343] Sun, 08 January 2012 00:20 Go to previous messageGo to next message
Tobias Böhm is currently offline Tobias BöhmFriend
Messages: 21
Registered: January 2012
Junior Member
Thanks Christophe.
I was very exited when I read the release notes saying that 2.2 ships with an editor but unfortunately thats the only thing I actually found. I would really benefit from a tutorial but I can't find one.

And I always read that it is only possible to do form based Xtext editors. Can someone tell me why that is? Can't I have a simple editor of my dsl inside a IViewPart?


Thanks,
Tobi
Re: Xtext editor in a component [message #776385 is a reply to message #776251] Sun, 08 January 2012 08:14 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi Tobias,

I can't comment on the 2.2 release and documentation, I am sure someone will blog about it eventually.

But for the already existing code http://code.google.com/a/eclipselabs.org/p/xtext-forms-integration/, you can use it non-form based, it accepts a Composite as a parent control.

rgds, Christophe

Re: Xtext editor in a component [message #776444 is a reply to message #776385] Sun, 08 January 2012 12:13 Go to previous messageGo to next message
Tobias Böhm is currently offline Tobias BöhmFriend
Messages: 21
Registered: January 2012
Junior Member
Thanks again for that information. I must have misunderstood that part.
I will have a deeper look at the example on googlecode.

Can someone tell me if there is some documentation about the "Embedded editor" in the pipeline? (Or even already available somewhere)

Cheers,
Tobi
Re: Xtext editor in a component [message #776512 is a reply to message #776444] Sun, 08 January 2012 16:35 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi Tobias,

documentation is in the pipeline.
Have a look at the EmbeddedEditorFactory (since 2.2)

@Override
protected SourceViewer createViewer(Composite parent) {
IEditedResourceProvider resourceProvider = new IEditedResourceProvider() {
.. anonymous class with createResource()
};
EmbeddedEditor handle =
embeddedEditorFactory.newEditor(resourceProvider).withParent(parent);
// access to the content of the editor
EmbeddedEditorModelAccess partialEditor = handle.createPartialEditor(true);
// keep the partialEditor as instance var to read / write the edited text
...
// return the source viewer
return handle.getViewer();
}

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

Am 08.01.12 13:13, schrieb Tobias Böhm:
> Thanks again for that information. I must have misunderstood that part.
> I will have a deeper look at the example on googlecode.
>
> Can someone tell me if there is some documentation about the "Embedded
> editor" in the pipeline? (Or even already available somewhere)
>
> Cheers,
> Tobi
>
Re: Xtext editor in a component [message #781418 is a reply to message #776512] Sat, 21 January 2012 07:03 Go to previous messageGo to next message
Marcel Bruch is currently offline Marcel BruchFriend
Messages: 289
Registered: July 2009
Senior Member

Excellent. Works Smile
Re: Xtext editor in a component [message #894548 is a reply to message #781418] Mon, 09 July 2012 14:58 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Any news for this documentation ?

Thanks.
Re: Xtext editor in a component [message #894963 is a reply to message #894548] Wed, 11 July 2012 09:01 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Am 09.07.12 16:58, schrieb Maxime D:
> Any news for this documentation ?
>
> Thanks.

Unfortunately not. I'm afraid you'll have to stay tuned :-(

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Xtext editor in a component [message #894968 is a reply to message #894963] Wed, 11 July 2012 09:27 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Thanks for your response Sebastian.

By the way, I tried to implement what you write above, but I got a warning using the EmbeddedEditorFactory object.
It seems pretty bad, it says :
Discouraged access: The type EmbeddedEditorFactory is not accessible due to restriction on required library D:\eclipse\plugins\org.eclipse.xtext.ui_2.3.0.v201206120633.jar
Re: Xtext editor in a component [message #894989 is a reply to message #894968] Wed, 11 July 2012 10:53 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
It's provisional API and therefore exported as 'internal' in the sense
of OSGi. That's where the warning comes from. However, it's pretty safe
to use it and suppress the warning.

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

Am 11.07.12 11:28, schrieb Maxime D:
> Thanks for your response Sebastian.
>
> By the way, I tried to implement what you write above, but I got a
> warning using the EmbeddedEditorFactory object.
> It seems pretty bad, it says :
> Discouraged access: The type EmbeddedEditorFactory is not accessible due
> to restriction on required library
> D:\eclipse\plugins\org.eclipse.xtext.ui_2.3.0.v201206120633.jar
Re: Xtext editor in a component [message #1248432 is a reply to message #894989] Mon, 17 February 2014 08:51 Go to previous messageGo to next message
Marcus Höpfner is currently offline Marcus HöpfnerFriend
Messages: 53
Registered: February 2014
Member
Hi Sebastian,

I have installed Xtext 2.5.2.
org.eclipse.xtext.ui.editor.embedded package is still internal and I get the warnings about discouraged access.

EmbeddedEditor has been recommended several times in this forum.

Can we use it without the danger that it's api gets changed or deleted?

Thanks you.

Marcus

Re: Xtext editor in a component [message #1248934 is a reply to message #1248432] Mon, 17 February 2014 20:23 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
i'd not care and simply use it

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Exporting DSL Plugins as Eclipse Product
Next Topic:Indent Based DSL with Xtext
Goto Forum:
  


Current Time: Mon Oct 19 22:49:00 GMT 2020

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

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

Back to the top