Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Problem with handler, command, and menu in simple tutorial
Problem with handler, command, and menu in simple tutorial [message #1711579] Sat, 17 October 2015 17:57 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 802
Registered: July 2009
Senior Member
I'm working through "Eclipse 4 Plug-in Development by Example Beginner's Guide" and up to "Time for action creating commands and handlers".

This defines a simple command, handler, and menuContribution. I followed the instructions in the text, but when the menu rendered, the menu item was insensitive.

I then noticed that the default implementation of the "isEnabled" method in the handler just returns "false". I changed it to "true" and that made the menu item sensitive, but when I selected it, I saw the following:
org.eclipse.core.commands.NotHandledException: There is no handler to execute for command com.packtpub.e4.clock.ui.command.hello
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:485)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)


Here is the relevant excerpt from my plugin.xml file:
   <extension
         point="org.eclipse.ui.commands">
      <command
            description="Says Hello World"
            id="com.packtpub.e4.clock.ui.command.hello"
            name="Hello">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="com.packtpub.e4.clock.ui.handlers.HelloHandler"
            commandId="com.packtpub.e4.clock.ui.command.hello">
      </handler>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="menu:help?after=additions">
         <command
               commandId="com.packtpub.e4.clock.ui.command.hello"
               label="Hello"
               style="push">
         </command>
      </menuContribution>
   </extension>


The text in the book even stated "If the Hello menu is disabled, verify that the handler extension point is defined, which connects the command to the handler class."
Re: Problem with handler, command, and menu in simple tutorial [message #1711586 is a reply to message #1711579] Sat, 17 October 2015 19:26 Go to previous message
David M. Karr is currently offline David M. KarrFriend
Messages: 802
Registered: July 2009
Senior Member
I've resolved this. What I didn't show here was the "HelloHandler" implementation, which I had originally defined to implement "IHandler", but it should have just extended "AbstractHandler". I'm not sure why, but that resolved the problem. I imagine something in AbstractHandler does the actual connection of the command to the handler, even though I'd declared it as such.
Previous Topic:Why do I only have "Custom plug-in wizard" in my list of available plug-in templates?
Next Topic:Add my own plugin templates to eclipse plugin template list
Goto Forum:
  


Current Time: Fri Apr 26 08:04:24 GMT 2024

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

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

Back to the top