Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » problem with org.eclipse.ui.internal.MakeHandlersGo
problem with org.eclipse.ui.internal.MakeHandlersGo [message #782375] Mon, 23 January 2012 16:10 Go to next message
vincent lorenzo is currently offline vincent lorenzoFriend
Messages: 93
Registered: June 2010
Location: Paris Saclay, France
Hi all,
On Eclipse indigo, I wrote JUnit tests to tests the handler activation :
org.eclipse.core.commands.Command testedCommand = ...
IHandler handler = testedCommand.getHandler();
if(handler instanceof HandlerProxy) {
handler = ((HandlerProxy)currentHandler).getHandler();
Assert.isTrue(handler instanceof myOwnHandler);

Now, testedCommand.getHandler() returns an MakeHandlersGo and not the handler declared in the plugin.xml...
Do you have a solution to adapt my code to E4, but it continues to work on Eclipse 3.8 ?

Is a Layer Compatibility bug?


Re: problem with org.eclipse.ui.internal.MakeHandlersGo [message #783507 is a reply to message #782375] Wed, 25 January 2012 21:11 Go to previous message
Brian de Alwis is currently online Brian de AlwisFriend
Messages: 756
Registered: January 2012
Senior Member

vincent lorenzo wrote on Mon, 23 January 2012 11:10

Is a Layer Compatibility bug?

No. Your test is relying on an implementation detail.

There's no guarantee in Command.getHandler() that the handler returned is the actual handler object to be executed. But calling execute() on that returned handler object will cause the handler to be executed.

(In E4, handlers can be POJOs; the compat layer wraps these handlers in an IHandler wrapper.)

vincent lorenzo wrote on Mon, 23 January 2012 11:10

Do you have a solution to adapt my code to E4, but it continues to work on Eclipse 3.8 ?

Not really.

What are you actually trying to test? That your handler will be executed? (What if there are other handlers for the command?) That its activeWhen expression is correct? Perhaps associate a dummy handler with the same expression that sets a value on execution, and then actually execute it.

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Dependency Injection in Abstract Classes
Next Topic:Toolbar Contribution
Goto Forum:

Current Time: Mon Jun 18 13:58:49 GMT 2018

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

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

Back to the top