Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext plugin and context menu handler issue
Xtext plugin and context menu handler issue [message #1333991] Mon, 05 May 2014 06:35 Go to next message
Eclipse UserFriend
Hi,
I create an xtext plugin and i followed the C. Dietrich tutorial (http://goo.gl/Ua3fyC) to call the Xtext generator from the
context menu. Then i deployied the plugin and tested the plugin into a new fresh eclipse installation. When I call
the generator from the context menu i get an "Unhandled event loop exception" with this message:

org.eclipse.e4.core.di.InjectionException: org.eclipse.core.commands.NotHandledException: There is no handler to execute for command org.xtext.passi.DocGen.ui.GenerationCommand
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:231)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:212)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:131)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:171)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:831)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:724)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:708)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:647)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	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:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: org.eclipse.core.commands.NotHandledException: There is no handler to execute for command org.xtext.passi.DocGen.ui.GenerationCommand
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:84)
	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)
	... 33 more


Any idea??
Re: Xtext plugin and context menu handler issue [message #1334020 is a reply to message #1333991] Mon, 05 May 2014 06:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

your config in plugin.xml is incorrect. make sure you define both command and handler

btw the tutorial is for eclipse 3.x style handlers

[Updated on: Mon, 05 May 2014 06:52] by Moderator

Re: Xtext plugin and context menu handler issue [message #1336006 is a reply to message #1334020] Tue, 06 May 2014 03:30 Go to previous messageGo to next message
Eclipse UserFriend
this is what've done: i disabled the extension point
org.eclipse.xtext.builder.participant
, then i added the command
and the handler in this way:

<extension point="org.eclipse.ui.commands">
		<command 
			name="Generate Documentation" 
			id="org.xtext.passi.DocGen.ui.GenerationCommand">
		</command>
	</extension>
	
<extension point="org.eclipse.ui.handlers">
<handler
	class="org.xtext.passi.ui.DocGenExecutableExtensionFactory:org.xtext.passi.DocGen.ui.GenerationHandler"          
	commandId="org.xtext.passi.DocGen.ui.GenerationCommand">    
</handler> 
</extension>


then i added the context menu voice, but for all the types of files:

<extension point="org.eclipse.ui.menus">
   <menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">       
	  <command 
		commandId="org.xtext.passi.DocGen.ui.GenerationCommand" 
		style="push"> 
	  </command>   
	</menuContribution>   
</extension>


The class GenerationHandler extends AbstractHandler and implements the interface IHandler, as shown below.

public class GenerationHandler extends AbstractHandler implements IHandler
{

	@Inject
	private IGenerator generator;
	
	@Inject
	private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
	
	@Inject
	IResourceDescriptions resourceDescriptions;
	
	@Inject
	IResourceSetProvider resourceSetProvider;

	/**
	 * Used to call manual documentation generation from the context menu
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException
	{
	
		ISelection selection = HandlerUtil.getCurrentSelection(event); 
		if (selection instanceof IStructuredSelection)
		{
			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
			
			Object firstElement = structuredSelection.getFirstElement();
		
			if (firstElement instanceof IFile)
			{
				IFile file = (IFile) firstElement; 
				IProject project = file.getProject();
				
				final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
				
				URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
				ResourceSet rs = resourceSetProvider.get(project); 
				Resource r = rs.getResource(uri, true); 
				
				generator.doGenerate(r, fsa);
			}
		}
		return null;
	}

	@Override
	public boolean isEnabled()
	{
		return true;
	
	}
}


edit: In plugin.xml_gen were missing the command and handler definition so I added there, but nothing changed.

[Updated on: Tue, 06 May 2014 03:59] by Moderator

Re: Xtext plugin and context menu handler issue [message #1336092 is a reply to message #1336006] Tue, 06 May 2014 04:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi, this looks strange. are you sure there arent any other issues?
Re: Xtext plugin and context menu handler issue [message #1336110 is a reply to message #1336092] Tue, 06 May 2014 04:34 Go to previous messageGo to next message
Eclipse UserFriend
Don't really know. When i execute the plugin from within eclipse (Run as Eclipse application) it works, but i have this problem only when i deploy the entire plugin and test into a new eclipse installation. I checked the requirement but I think it's all ok: I installed xtext,graphiti, xtend and xcore. I think that the plugin should not be loaded at all if there was something missing. But instead I got the context menu voice "Generate Documentation" of my plugin, so I think it's ok...
Re: Xtext plugin and context menu handler issue [message #1336188 is a reply to message #1336110] Tue, 06 May 2014 05:19 Go to previous messageGo to next message
Eclipse UserFriend
make sure you dont have any warnings in the build.properties of the plugins
make sure the plugins start (via (host) osgi console)
Re: Xtext plugin and context menu handler issue [message #1336290 is a reply to message #1336188] Tue, 06 May 2014 06:17 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
make sure the plugins start (via (host) osgi console)


how?
Re: Xtext plugin and context menu handler issue [message #1336300 is a reply to message #1336290] Tue, 06 May 2014 06:21 Go to previous message
Eclipse UserFriend
Hi this is not Xtext specific you can start any eclipse with console
and you can open the host OSGi console in the console view

--
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
Previous Topic:DSL-Editor not found in runtime-workbench
Next Topic:How to load resources stored in a plug-in ?
Goto Forum:
  


Current Time: Wed Jul 23 18:32:39 EDT 2025

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

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

Back to the top