Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » trouble integrating the Xtext editor to an swt form
trouble integrating the Xtext editor to an swt form [message #1706396] Wed, 26 August 2015 15:34 Go to next message
Nawel Amok is currently offline Nawel AmokFriend
Messages: 18
Registered: November 2013
Junior Member
Hello,

I have followed this example http://fr.slideshare.net/meysholdt/lightweight-xtext-editorsasswtwidgets to integrate the Xtext editor of a grammer I created (BPmodel) in a composite - part of swt form, in a windowbuilder project. so I used this code :
BPModelActivator activator = BPModelActivator.getInstance()
Injector injector = activator.getInjector(activator.MY_LANGUAGE);
MyResourceProvider provider = injector.getInstance(MyResourceProvider.class);
EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
EmbeddedEditor handle = factory.newEditor(provider).withParent(leComposite);
EmbeddedEditorModelAccess partialEditor= handle.createPartialEditor("","a text","",false);


But i am having a java.lang.NullPointerException exception at this level :
Injector injector = activator.getInjector(activator.FR_EMA_LGI2P_ISOE_RESULIS_BPMODEL_BPMODEL); 

In fact the debug of my form shows that "activator" is null since "BPModelActivator" has not been started. Then I used this other code to obtain the injector :
BPModelStandaloneSetup.doSetup();
injector = new BPModelStandaloneSetup().createInjectorAndDoEMFRegistration();
injector.injectMembers(this);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
MyResourceProvider provider = injector.getInstance(MyResourceProvider.class);
EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
EmbeddedEditor handle = factory.newEditor(provider).withParent(leComposite);
EmbeddedEditorModelAccess partialEditor= handle.createPartialEditor("","a text","",false);


and I got this error :
com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for org.eclipse.xtext.ui.resource.IResourceSetProvider was bound.
  while locating org.eclipse.xtext.ui.resource.IResourceSetProvider
    for field at testIntegrateXtext.laWindow$MyResourceProvider.resourceSetProvider(Unknown Source)
  while locating testIntegrateXtext.laWindow$MyResourceProvider

1 error
	at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004)
	at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:961)
	at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)
	at testIntegrateXtext.laWindow$1.widgetSelected(laWindow.java:222)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at testIntegrateXtext.laWindow.open(laWindow.java:96)
	at testIntegrateXtext.laWindow.main(laWindow.java:81)



I don't seem to understand where the problem is Sad can you please help.

Thanks in advance,
Nawel
Re: trouble integrating the Xtext editor to an swt form [message #1706397 is a reply to message #1706396] Wed, 26 August 2015 15:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Are you targeting eclipse or are you standalone. In eclpse never call standalonesetup. Just take care the dsl plugin is activated

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: trouble integrating the Xtext editor to an swt form [message #1706398 is a reply to message #1706397] Wed, 26 August 2015 15:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Btw where (which plugin) does your code live in

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: trouble integrating the Xtext editor to an swt form [message #1706399 is a reply to message #1706398] Wed, 26 August 2015 15:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
And if you are standalone just make sure you module provides bindings for all stuff needed

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: trouble integrating the Xtext editor to an swt form [message #1706401 is a reply to message #1706396] Wed, 26 August 2015 15:50 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Nawel,

the Activator is not started, since you are not in an osgi container, but a plain Java application. So your second snippet looks better (don't know why you do injectMembers(this), looks unnecessary).

I guess somewhere in your code you use IResourceSetProvider, which is not available in the runtime context. Use Provider<XtextResourceSet> instead.

Cheers,
Stefan
Re: trouble integrating the Xtext editor to an swt form [message #1706410 is a reply to message #1706401] Wed, 26 August 2015 16:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
@Stefan EmbeddedEditor unfortunately needs tons of bindings in ui. thus it will not be trivial to get a module that will run smooth.
do you know if moritz really had a pure standalone example?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: trouble integrating the Xtext editor to an swt form [message #1706418 is a reply to message #1706410] Wed, 26 August 2015 17:37 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

@christian You're right, it doesn't work in standalone mode. Sven also tried that to make it run in e4 (without compatibility layer) and he concluded that it would be easier to write a standalone version from scratch.

So @Nawel sorry for getting your hopes up, it won't work in a plain SWT application right now. You'll have to build an Eclipse plugin.
Re: trouble integrating the Xtext editor to an swt form [message #1706483 is a reply to message #1706418] Thu, 27 August 2015 09:04 Go to previous messageGo to next message
Nawel Amok is currently offline Nawel AmokFriend
Messages: 18
Registered: November 2013
Junior Member
Hello,

Thank you Christian and Stefan for your answers.
If I got it right : the application that carries the EmbdedEditor should be an Eclipse plugin and not a standalone java application, right ?
And is calling the editor from a standalone application something Xtext is working on ?

Nawel
Re: trouble integrating the Xtext editor to an swt form [message #1706503 is a reply to message #1706483] Thu, 27 August 2015 12:24 Go to previous message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Nawel,

yes you got it right.

We are currently working on IntelliJ and Web support and factoring out common services into a platform independent bundle.
We are not working on plain SWT support right now, but please feel free to open an enhancement request for that.

Cheers,
Stefan
Previous Topic:Can't find INode.setText(...)
Next Topic:Changes on .xtend file crashes the workspace
Goto Forum:
  


Current Time: Mon Sep 23 04:20:10 GMT 2024

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

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

Back to the top