Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » IOutputConfigurationProvider Binding-Problem
IOutputConfigurationProvider Binding-Problem [message #1128223] Mon, 07 October 2013 13:20 Go to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
Hi,

I follwed the following link to bind another output-dir for my generated files:
http://stackoverflow.com/questions/10350022/how-to-add-multiple-outlets-for-generated-xtext-dsl

If I clean my model and start a buildAll, this binding works fine.
If I start my generator via a generration-handler (see http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/) only the default-OutputConfiguration is available. So in the EclipseResourceFileSystemAccess an Exception occurs.

I use Xtext 2.4.3 with Eclipse Kepler.

Has somebody an idea to fix the probelm?

Greets Björn
Re: IOutputConfigurationProvider Binding-Problem [message #1128256 is a reply to message #1128223] Mon, 07 October 2013 14:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
What happens exactly. Name sure you add the binding to the uimodule.
Make sure you make a binding that fits to what you inject into the
handler

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IOutputConfigurationProvider Binding-Problem [message #1128306 is a reply to message #1128256] Mon, 07 October 2013 14:59 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
I added the binding to the UI module (with cleanAll - buildAll the functionality works fine).

I think it is something wrong with my generation handler. If I start the generator from my context-menue I get the Exception:
java.lang.RuntimeException: IContainer P/null does not exist


These are my injections in the handler and the generator-call:
public class GenerationHandler extends AbstractHandler implements IHandler {
@Inject
private IGenerator oGenerator;
@Inject
private Provider<EclipseResourceFileSystemAccess> oFileAccessProvider;
@Inject
IResourceDescriptions oRresourceDescriptions;
@Inject
IResourceSetProvider oResourceSetProvider;
@Override
public Object execute(ExecutionEvent oEvent) throws ExecutionException {
...
final EclipseResourceFileSystemAccess oFsa = oFileAccessProvider.get();
URI oUri = URI.createPlatformResourceURI(oFile.getFullPath().toString(), true);
ResourceSet oResourceSet = oResourceSetProvider.get(oProject);
Resource oResource = oResourceSet.getResource(oUri, true);
oGenerator.doGenerate(oResource, oFsa);

My OutputConfiguration:
public class WorkflowOutputConfigurationProvider implements IOutputConfigurationProvider {

public final static String s_sDEFAULT_OUTPUT_ONCE = "DEFAULT_OUTPUT_ONCE";
public final static String s_sDEFAULT_OUTPUT_FOLDER = "/src/configuration";

@Override
public Set<OutputConfiguration> getOutputConfigurations() {
Set<OutputConfiguration> oOutputConfig = new HashSet<OutputConfiguration>();

OutputConfiguration oDefaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
oDefaultOutput.setDescription("Output Folder");
oDefaultOutput.setOutputDirectory("./src-gen");
oDefaultOutput.setOverrideExistingResources(true);
oDefaultOutput.setCreateOutputDirectory(true);
oDefaultOutput.setCleanUpDerivedResources(true);
oDefaultOutput.setSetDerivedProperty(true);
oOutputConfig.add(oDefaultOutput);

OutputConfiguration oOnceOutput = new OutputConfiguration(s_sDEFAULT_OUTPUT_ONCE);
oOnceOutput.setDescription("Output Folder (once)");
oOnceOutput.setOutputDirectory("." + s_sDEFAULT_OUTPUT_FOLDER);
oOnceOutput.setOverrideExistingResources(false);
oOnceOutput.setCreateOutputDirectory(true);
oOnceOutput.setCleanUpDerivedResources(false);
oOnceOutput.setSetDerivedProperty(true);
oOutputConfig.add(oOnceOutput);

return oOutputConfig;
}
}

I tried two two Ways to bind the configuration in the ui-module (the fist one as comment):
// @Override
// public void configure(Binder binder) {
// super.configure(binder);
// binder.bind(IOutputConfigurationProvider.class).to(WorkflowOutputConfigurationProvider.class).in(Singleton.class);
// }

public Class<? extends IOutputConfigurationProvider> bindIOutputConfigurationProvider() {
return WorkflowOutputConfigurationProvider.class;
}

Re: IOutputConfigurationProvider Binding-Problem [message #1128366 is a reply to message #1128306] Mon, 07 October 2013 16:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Are you sure your provider is not called?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IOutputConfigurationProvider Binding-Problem [message #1128374 is a reply to message #1128366] Mon, 07 October 2013 16:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.S: do you have a complete stacktrace?

btw having a look at the code it seems like the builder uses org.eclipse.xtext.builder.EclipseOutputConfigurationProvider in the shared module.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IOutputConfigurationProvider Binding-Problem [message #1128979 is a reply to message #1128374] Tue, 08 October 2013 07:12 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
The Stacktrace:
java.lang.RuntimeException: IContainer P/null does not exist
at org.eclipse.xtext.builder.EclipseResourceFileSystemAccess.createFolder(EclipseResourceFileSystemAccess.java:118)
at org.eclipse.xtext.builder.EclipseResourceFileSystemAccess.generateFile(EclipseResourceFileSystemAccess.java:62)
at com.bsp.metamodel.dsl.workflow.generator.WorkflowDslGenerator.generateDefaultConfig(WorkflowDslGenerator.java:1619)
at com.bsp.metamodel.dsl.workflow.generator.WorkflowDslGenerator.doGenerate(WorkflowDslGenerator.java:301)
at com.bsp.metamodel.dsl.workflow.ui.handler.GenerationHandler$1.exec(GenerationHandler.java:148)
at com.bsp.metamodel.dsl.workflow.ui.handler.GenerationHandler$1.exec(GenerationHandler.java:1)
at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:62)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:246)
at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:84)
at com.bsp.metamodel.dsl.workflow.ui.handler.GenerationHandler.execute(GenerationHandler.java:140)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:285)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:504)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:555)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:376)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:322)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:84)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1056)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
at org.eclipse.swt.widgets.Widget.wmKeyDown(Widget.java:1827)
at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:4975)
at org.eclipse.swt.widgets.Canvas.WM_KEYDOWN(Canvas.java:429)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4643)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Re: IOutputConfigurationProvider Binding-Problem [message #1128980 is a reply to message #1128979] Tue, 08 October 2013 07:15 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
The provider is called if I start a new eclipse-application to use the dsl-editor.
If I call the generator from context menue the provider is not invoked.
Re: IOutputConfigurationProvider Binding-Problem [message #1128985 is a reply to message #1128979] Tue, 08 October 2013 07:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Sure you generate to an existing project?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IOutputConfigurationProvider Binding-Problem [message #1128990 is a reply to message #1128985] Tue, 08 October 2013 07:23 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
Yes, the Generation works fine, if I start the new eclipse-application to use the dsl-editor. The build starts, the provider is called and the generated code is in the right folder.
Only calling the generator from contextmenue does not work.

[Updated on: Tue, 08 October 2013 07:24]

Report message to a moderator

Re: IOutputConfigurationProvider Binding-Problem [message #1129019 is a reply to message #1128990] Tue, 08 October 2013 07:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi you have to link access and config yourself. Calling
FSA.setoutputpath is no longer sufficient.

Have a look at other calls of setoutputconfigs

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IOutputConfigurationProvider Binding-Problem [message #1129278 is a reply to message #1129019] Tue, 08 October 2013 13:25 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
The last version I tried.
The Provider works fine with cleanAll buildAll.
Calling the generator from context menue works not furthermore.
- I had problems with the path. So I implemented getOutputConfigurationsFromContext(). This fixed my path-problem.
- Another problem is, that the generation with oFsa overrides the already generated files. That's not what I want and not what I had configured (see OutputConfiguration(s_sDEFAULT_OUTPUT_ONCE))

Du to the fact that the functionality works fine with cleanAll buildAll it must be a problem in my Handler.
The Method getOutputConfigurations must be correct.

I use the deprecated EclipseResourceFileSystemAccess, but EclipseResourceFileSystemAccess2 don't work too Sad (see commented lines NullProgressMonitor and getWorkflowProject).


private EclipseResourceFileSystemAccess createFileSystemAccess(
WorkflowOutputConfigurationProvider oOutputConfigurationProvider) {
final EclipseResourceFileSystemAccess oFsa = oFileAccessProvider.get();
// oFsa.setMonitor(new NullProgressMonitor());
// oFsa.setProject(getWorkflowProject());
Map<String, OutputConfiguration> oOutputs = uniqueIndex(oOutputConfigurationProvider.getOutputConfigurationsFromContext(), new Function<OutputConfiguration, String>() {
public String apply(OutputConfiguration from) {
return from.getName();
}
});
oFsa.setOutputConfigurations(oOutputs);
...
oGenerator.doGenerate(oResource, oFsa);


From my Provider:
public final static String s_sDEFAULT_OUTPUT_ONCE = "DEFAULT_OUTPUT_ONCE";
public final static String s_sDEFAULT_OUTPUT_FOLDER = "/src/_Configuration";

@Override
public Set<OutputConfiguration> getOutputConfigurations() {
Set<OutputConfiguration> oOutputConfig = new HashSet<OutputConfiguration>();

OutputConfiguration oDefaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
oDefaultOutput.setDescription("Output Folder");
oDefaultOutput.setOutputDirectory("./src-gen");
oDefaultOutput.setOverrideExistingResources(true);
oDefaultOutput.setCreateOutputDirectory(true);
oDefaultOutput.setCleanUpDerivedResources(true);
oDefaultOutput.setSetDerivedProperty(true);
oOutputConfig.add(oDefaultOutput);

OutputConfiguration oOnceOutput = new OutputConfiguration(s_sDEFAULT_OUTPUT_ONCE);
oOnceOutput.setDescription("Output Folder (once)");
oOnceOutput.setOutputDirectory("." + s_sDEFAULT_OUTPUT_FOLDER);
oOnceOutput.setOverrideExistingResources(false);
oOnceOutput.setCreateOutputDirectory(true);
oOnceOutput.setCleanUpDerivedResources(false);
oOnceOutput.setSetDerivedProperty(true);
oOutputConfig.add(oOnceOutput);

return oOutputConfig;
}

//TODO Patch
public Set<OutputConfiguration> getOutputConfigurationsFromContext() {
Set<OutputConfiguration> oOutputConfig = getOutputConfigurations();
Iterator<OutputConfiguration> oIter = oOutputConfig.iterator();
while (oIter.hasNext()) {
OutputConfiguration oOutput = oIter.next();
if (s_sDEFAULT_OUTPUT_ONCE.equals(oOutput.getName())) {
oOutput.setOutputDirectory("./model-workflow" + s_sDEFAULT_OUTPUT_FOLDER);
return oOutputConfig;
}
}
return oOutputConfig;
}

[Updated on: Tue, 08 October 2013 13:33]

Report message to a moderator

Re: IOutputConfigurationProvider Binding-Problem [message #1129313 is a reply to message #1129278] Tue, 08 October 2013 14:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Sorry i fear i dont have the time to debug this myself. Did you try
to debug the stuff?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IOutputConfigurationProvider Binding-Problem [message #1129358 is a reply to message #1129313] Tue, 08 October 2013 14:54 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
Yes.
Now I try to copy some relevant code out of the BuilderParticipant...
Re: IOutputConfigurationProvider Binding-Problem [message #1129378 is a reply to message #1129358] Tue, 08 October 2013 15:11 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
without success Sad
Re: IOutputConfigurationProvider Binding-Problem [message #1129424 is a reply to message #1129378] Tue, 08 October 2013 16:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Still The question: debugging The code: what happens in the access?
Does it get the information from the config? Does it use it at all?
Please have a look at the code (I have no eclipse with me so that I
can't)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IOutputConfigurationProvider Binding-Problem [message #1129992 is a reply to message #1129424] Wed, 09 October 2013 06:03 Go to previous messageGo to next message
Björn Rellesch is currently offline Björn RelleschFriend
Messages: 38
Registered: January 2013
Member
Good Morning,
now I fixed it. The Problem was that I used:
IWorkspace oWorkspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot oRoot = oWorkspace.getRoot();
IProject oProject = oRoot.getProject("model-project");

instead of:
IProject oProject = oFile.getProject() from the Example mentioned above.

That caused my path-problems and the ignored configurations.

Sorry for any inconvenience...

Greets Björn
Re: IOutputConfigurationProvider Binding-Problem [message #1402971 is a reply to message #1128223] Sat, 19 July 2014 02:28 Go to previous message
Mohamed Elbeltagy is currently offline Mohamed ElbeltagyFriend
Messages: 5
Registered: July 2014
Junior Member
A complete running example can be found here:
http:// xtextcasts.org/episodes/15-output-configurations
Previous Topic:Right place to load properties from file and retrieve them
Next Topic:Testing tool for Xtext
Goto Forum:
  


Current Time: Sat Apr 20 06:09:19 GMT 2024

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

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

Back to the top