Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » eRCP » Programmatic added Commands and Handler throw Exception(since 4.3)
Programmatic added Commands and Handler throw Exception [message #1393764] Fri, 04 July 2014 08:27 Go to next message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 57
Registered: February 2012
Member
Hello,

I switched the platform from 3.8 to 4.3 for an old RCP-Application, where commands and handlers are added programmatically, not in the plugin.xml. I've got the problem that I get a NotHandledException in the command, because no handler has been found.

The commands and handlers are added, as described in https://wiki.eclipse.org/Platform_Command_Framework. I would expect that the following code snippet work:

ICommandService commandService = getCommandService();
Category category = commandService.getCategory("some.category");
if (!category.isDefined()) {
    category.define("SomeCategory", "The Category of the RCP");
}
Command command = commandService.getCommand("someId");
if (!command.isEnabled()) {
    command.define("SomeName", "SomeDescription", category);
}

IHandlerService handlerService = getHandlerService();
handlerService.activateHandler(menuCommand.getName(), getHandler());


I execute the command as follows:
getHandlerService().executeCommand("someId", null);


I also tried to execute the command with a ParameterizedCommand, but had the some problem:
Command command = getCommandService().getCommand("someId");
ParameterizedCommand pCommand = new ParameterizedCommand(command, null);
getHandlerService().executeCommand(pCommand, null);


As I have seen the handler is ever added to the command. Is this code snippet not valid any more, when using Eclipse 4.3?
Re: Programmatic added Commands and Handler throw Exception [message #1393786 is a reply to message #1393764] Fri, 04 July 2014 09:00 Go to previous message
Stefan Weiser is currently offline Stefan WeiserFriend
Messages: 57
Registered: February 2012
Member
OK,

I found out that this is an Eclipse Bug in Kepler. I created a little RCP snippet, which demonstrates the problem.

e3.8.2 --> OK
e4.3.2 --> Exception
e4.4.0 --> OK

As I can see this is a problem in Kepler. The only way to solve this problem is to set the handler manually to the command.
Previous Topic:Remove Menu from other plugin
Next Topic:Organizing files in a custom project explorer
Goto Forum:
  


Current Time: Sat Jul 27 05:14:16 GMT 2024

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

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

Back to the top