Problem with handler, command, and menu in simple tutorial [message #1711579] |
Sat, 17 October 2015 17:57 |
David M. Karr 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."
|
|
|
|
Powered by
FUDForum. Page generated in 0.02903 seconds