Eclipse Luna: Handlers' @CanExecute methods not called due to wrong context
Asked Answered
I

0

0

I upgraded my eclipse RCP application from Juno to Luna. This caused my application toolbar to be permenantly disabled.

I found a solution in this thread: Eclipse Luna: Handlers' @CanExecute methods not called (Solution: generate event manually). But alas, the cure didn't work :-(.

I drilled down with the debugger to find the root cause of failure. I found that in HandlerServiceHandler.class the method setEnabled(Object evaluationContext) fails. This is due to the extraction of the wrong execution context from the evaluation context.

I will go into more details: What is happening is that after I perform a selection on the project explorer I send my event. The setEnabled(Object evaluationContext) looks up the handler of the relevant command that is associated with my toolbar item. However, it looks for the handler within the * execution context* of the project explorer. The handler isn't in this context so the method fails!!

Any ideas on how to resolve this. I don't really understand how I can control my contexts well.

Thanks!!!!!

Immersionism answered 2/9, 2014 at 8:21 Comment(7)
So where are you defining your handler?Vladamir
In the e4xmi file I have a handler defined. This handler is connected to a command which is connected to a toolbar item.Immersionism
Yes but where in the e4xmi, is it in the top level Handlers list or in the Handlers list for a particular window?Vladamir
The handler lookup should work, all contexts from the active leaf up to the application context are searched. Your handler will be in the application context. Are you sure the command id is correct?Vladamir
I use the find button to link the command to its handler and tool item in e4xmi. So I don't see where I can go wrong. Thanks for your answers by the way.Immersionism
I came back to look at this after a long time. I probably shoul've said that I got an exception with css spy when I am loading my rcp app. org.osgi.framework.BundleException: Could not resolve module: org.eclipse.e4.tools.css.spy [174] Another singleton bundle selected: osgi.identity; osgi.identity="org.eclipse.e4.tools.css.spy"; type="osgi.bundle"; version:Version="0.12.0.v20130814-1230"; singleton:="true" at org.eclipse.osgi.container.Module.start(Module.java:434)Immersionism
I moved event broker code to another place and now I am in MainWindow context (not application context). It is still not working... Sometimes HandlerServiceImpl.lookUpHandler() in setEnabled() returns null and sometime it isn't null but setEnabled() still disables the toolItem...Immersionism

© 2022 - 2024 — McMap. All rights reserved.