trouble integrating the Xtext editor to an swt form [message #1706396] |
Wed, 26 August 2015 15:34 |
Nawel Amok 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 can you please help.
Thanks in advance,
Nawel
|
|
|
|
|
|
Re: trouble integrating the Xtext editor to an swt form [message #1706401 is a reply to message #1706396] |
Wed, 26 August 2015 15:50 |
|
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 #1706418 is a reply to message #1706410] |
Wed, 26 August 2015 17:37 |
|
@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.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03326 seconds