E4 Commands and Handlers [message #787666] |
Tue, 31 January 2012 16:14  |
Eclipse User |
|
|
|
Should this code work?
ECommandService eCommandService = context.get(ECommandService.class);
final Category lunch = eCommandService.getCategory("z.ex.view.keybindings.category");
if (!lunch.isDefined()) {
lunch.define("Lunch", "Actions take at lunch time.");
}
final Command eatTaco = eCommandService.getCommand("z.ex.view.keybindings.eatTaco");
if (!eatTaco.isDefined()) {
eatTaco.define("Eat That Taco", "Go for the taco.", lunch);
}
EHandlerService eHandlerService = context.get(EHandlerService.class);
final IHandler handler = new AbstractHandler() {
public Object execute(final ExecutionEvent event) throwsExecutionException {
System.out.println("Eat that Taco");
return null;
}
};
eHandlerService.activateHandler("z.ex.view.keybindings.eatTaco", handler);
I can't seem to get it to do what I am expecting.
I expect the command to be created (which it does) and then a handler added to the command (which it does not)
I copied this example from an example for adding commands and handlers in e3. I modified how the services are looked up
When activateHandler is called shouldn't eatTaco.getHandler() not be null? Unfortunately it is still null. I am having the same issue when I try to use the compatibility layer (IHandlerService and ICommandService is used in the e3 example)
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04083 seconds