Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » project wizard and launch configuration
project wizard and launch configuration [message #559291] Thu, 16 September 2010 09:50 Go to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hi every body.
I have created a language with Xtext and it generate java classes with XPand.

in the workflow, I have uncommented these lines :
fragment = projectWizard.SimpleProjectWizardFragment {
					generatorProjectName = "${projectName}.generator" 
					modelFileExtension = file.extensions
			 }


(modelFileExtension is 'adapt')

So now, the user can create a project for my language.
but I would like that when he create a '<name>.adapt' file, he has just to do : right ciick-> run as -> launch configuration. (the same thing as the workflow files.)

Is it possible to do something like that?

Until now, I generate a java file which can launch the workflow.

Thanks,

Jérémie.

Re: project wizard and launch configuration [message #559367 is a reply to message #559291] Thu, 16 September 2010 13:33 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
This is called "context menus" and described in section 7.5.3 of the Xtext 1.0.1 User Guide. Note that the description is far from a full tutorial so you might want to Google for additional info which is non-Xtext specific. The problem essentially is divided into registering the context menu item and executing it -for the latter you'll have to know how to run the generator workflow programmatically, which you apparently already know.


[Updated on: Thu, 16 September 2010 13:34]

Report message to a moderator

Re: project wizard and launch configuration [message #559606 is a reply to message #559367] Fri, 17 September 2010 11:23 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hi,

I am close to resolve the problem :

To add a menu, I add this in the plugin..xml of the ui project :

<!--  popup menu -->
<extension
         point="org.eclipse.ui.commands">
      <command
            description="Trigger expensive validation"
            id="fr.irisa.cairn.graphAdapter.Language.generateAdapter"
            name="generate adapter">
      </command>
 </extension>
 
 <extension
  point="org.eclipse.ui.handlers">
  <handler
    class="fr.irisa.cairn.graphAdapter.ui.GraphAdapterGeneratorHandler"
    commandId="fr.irisa.cairn.graphAdapter.Language.generateAdapter">
  </handler>
</extension>

  <extension point="org.eclipse.ui.menus">
        <menuContribution
            locationURI="popup:#TextEditorContext?after=group.edit">
             <command
                 commandId="fr.irisa.cairn.graphAdapter.Language.generateAdapter"
                 style="push"
                 tooltip="generate the graph adapter">
            <visibleWhen checkEnabled="false">
                <reference
                    definitionId="fr.irisa.cairn.graphAdapter.Language.Editor.opened">
                </reference>
            </visibleWhen>
         </command>  
         </menuContribution>
    </extension>


and I have created an Handler class which look like this :
public class GraphAdapterGeneratorHandler extends AbstractHandler {

//	private final static String MODEL_PATH = "src/model/";
	private final static String JAVA_PATH = "src-gen/";
	private final static String ENCODING = "UTF-8";

	// @Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IFile adapterFile = getFilePath(event);
		String modelPath = adapterFile.getProjectRelativePath().toOSString();
		System.out.println("MODEL_PATH = " + modelPath);
		GraphAdapterGenerator.generate(modelPath, JAVA_PATH, ENCODING);
		return null;
	}


and to launch the workflow, i have this int
the GraphAdapterGenerator class :
Mwe2Launcher.main(new String[] { "workflow.LanguageGenerator", "-p",
				"modelPath=".concat(absoluteModelDir), "-p",
				"targetDir=".concat(absoluteTargetDir), "-p",
				"fileEncoding=".concat(this.encoding)
				});


unfortunately it doen't work : when I run the generator project and create a new adapter project, if i want to lanch the generation, I have this exception:
0    [Thread-0] ERROR org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher  - Couldn't find module with name 'workflow.LanguageGenerator'.
java.lang.IllegalArgumentException: Couldn't find module with name 'workflow.LanguageGenerator'.
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:63)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:76)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
	at fr.irisa.cairn.graphAdapter.language.generator.GraphAdapterGenerator.run(GraphAdapterGenerator.java:108)
	at fr.irisa.cairn.graphAdapter.language.generator.GraphAdapterGenerator.generate(GraphAdapterGenerator.java:25)
	at fr.irisa.cairn.graphAdapter.ui.GraphAdapterGeneratorHandler.execute(GraphAdapterGeneratorHandler.java:27)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:820)
	at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:806)
	at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:796)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3776)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1187)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3622)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3277)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	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:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

!ENTRY org.apache.log4j 4 0 2010-09-17 13:08:34.505
!MESSAGE org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher  - Couldn't find module with name 'workflow.LanguageGenerator'.


That's strange because I still van launch the generation by a "manual way"
when I crete an adapter project, in the project I have this java file :
public class AdapterGenerator {
	private final static String MODEL_PATH = "src/model/Model.adapt";
	private final static String JAVA_PATH = "src-gen/";
	private final static String ENCODING = "UTF-8";

	public static void main(String[] args) {
		AdapterGenerator.generate();
	}
	
	public static void generate() {
		GraphAdapterGenerator.generate(MODEL_PATH, JAVA_PATH, ENCODING);
	}
}


This class replace the GraphAdapterGeneratorHandler class. And If I launch this file, the generation works.
.
For me, the 2 ways should works, but no.
Have you got any ideas?

Jérémie
Re: project wizard and launch configuration [message #559627 is a reply to message #559606] Fri, 17 September 2010 13:01 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
This "usually" is a problem with location of the workflow file and whether that's resolved against the classpath or through a plugin-based URI.

Maybe you have to use something like "platform:/plugin/<your plugin ID>/workflow/&c" to get it to work. I usually end up using the debugger to see at a fairly low level how the file is looked up.


Re: project wizard and launch configuration [message #559640 is a reply to message #559627] Fri, 17 September 2010 13:32 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I tried to use de debugger, but I don"t have source for the Mwe2Launcher class, so it is not really clear what append in this class.
I tried to this :
Mwe2Launcher.main(new String[] { "platform:/plugin/fr.irisa.cairn.graphAdapter.language.generator/src/workflow/LanguageGenerator.mwe2", "-p",
				"modelPath=".concat(absoluteModelDir), "-p",
				"targetDir=".concat(absoluteTargetDir), "-p",
				"fileEncoding=".concat(this.encoding)
		// "tomPath=".concat(absoluteAdapterDir) });
				});
	}


but I have the same exception :
1    [Thread-0] ERROR org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher  - Couldn't find module with name 'workflow.LanguageGenerator'.
java.lang.IllegalArgumentException: Couldn't find module with name 'workflow.LanguageGenerator'.


But there is a difference, if I launch the generation with the old way, I have now, this exception :
MODEL_PATH = src/model/Model.adapt
1    ERROR Mwe2Launcher       - java.net.MalformedURLException: unknown protocol: platform
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.net.MalformedURLException: unknown protocol: platform
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
	at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:47)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
	at fr.irisa.cairn.graphAdapter.language.generator.GraphAdapterGenerator.run(GraphAdapterGenerator.java:108)
	at fr.irisa.cairn.graphAdapter.language.generator.GraphAdapterGenerator.generate(GraphAdapterGenerator.java:25)
	at hcdgAdapter.generator.AdapterGenerator.generate(AdapterGenerator.java:16)
	at hcdgAdapter.generator.AdapterGenerator.main(AdapterGenerator.java:12)
Caused by: java.net.MalformedURLException: unknown protocol: platform
	at java.net.URL.<init>(URL.java:574)
	at java.net.URL.<init>(URL.java:464)
	at java.net.URL.<init>(URL.java:413)
	at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:176)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:301)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1254)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
	... 9 more




I don't understand why it is not the same comportement for the both way.


Jérémie

Re: project wizard and launch configuration [message #559938 is a reply to message #559640] Mon, 20 September 2010 13:35 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
maybe an important things, these line :
Mwe2Launcher.main(new String[] { "workflow.LanguageGenerator", "-p",
				"modelPath=".concat(absoluteModelDir), "-p",
				"targetDir=".concat(absoluteTargetDir), "-p",
				"fileEncoding=".concat(this.encoding)
				});

are in a GraphAdapterGenerator class.
The GraphAdapterGenerator.jave and LanguageGenerator.mwe2 files are placed in the same plugin.

I don't understand why Mwe2Launcher can't find the workflow.

Previous Topic:How to access the EObject tree of another model file?
Next Topic:scope problem
Goto Forum:
  


Current Time: Wed Apr 24 14:03:50 GMT 2024

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

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

Back to the top