Bug 380946 - [Commands] [Compatibility] helpContextId not registered for legacy handlers
Summary: [Commands] [Compatibility] helpContextId not registered for legacy handlers
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 4.4 M7   Edit
Assignee: Paul Webster CLA
QA Contact: Wojciech Sudol CLA
URL:
Whiteboard:
Keywords:
: 366562 (view as bug list)
Depends on: 433492
Blocks:
  Show dependency tree
 
Reported: 2012-05-29 14:34 EDT by Brian de Alwis CLA
Modified: 2014-04-29 05:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2012-05-29 14:34:01 EDT
Basically CommandService.getHelpContextId(command) delegates to the CommandManager instance, which looks to see if a helpContextId has been registered for the provided command's handler.  Since we set most Command handlers to an instance MakeHandlersGo, and LegacyHandlerService doesn't actually associate and record the helpContextIds, most handlers don't have a helpContextId.
Comment 1 Wojciech Sudol CLA 2014-03-13 13:36:52 EDT
When trying to fix this bug I noticed the following problems:
1. Command.getHelpContextId() is package private, hence I need to use CommandManager to retrieve the value (or keep the command-helpContextId in a separate place).
2. HandlerServiceHandler does not provide any method to determine the current 'real' handler, so I need to add a new method to it or store the information somewhere else.
3. CommandManager does not allow to get helpContextId by handler (but only by command), therefore it cannot be used for commands with assigned HandlerServiceHandler.

Thus, the question is whether the fix should be a minimal change that restores the missing functionality or a new approach to managing helpContextId is necessary.

I uploaded to gerrit a simple patch that experiments with the first approach, but I will try to provide a better solution.
The Gerrit URL is: https://git.eclipse.org/r/23343

Any comments and suggestions are welcome.
Comment 2 Paul Webster CLA 2014-03-27 14:57:40 EDT
(In reply to Wojciech Sudol from comment #1)
> When trying to fix this bug I noticed the following problems:
> 1. Command.getHelpContextId() is package private, hence I need to use
> CommandManager to retrieve the value (or keep the command-helpContextId in a
> separate place).

We do have access to the CommandManager in the IEclipseContext, if you need it.

> 2. HandlerServiceHandler does not provide any method to determine the
> current 'real' handler, so I need to add a new method to it or store the
> information somewhere else.

I see we're using the HandlerServiceHandler to look up the IHandler.  Would it not make more sense to do that in the CommandService implementation, instead of going to the HandlerServiceHandler?

> 
> I uploaded to gerrit a simple patch that experiments with the first
> approach, but I will try to provide a better solution.
> The Gerrit URL is: https://git.eclipse.org/r/23343

What difference can I see in the UI if we enable this functionality?

PW
Comment 3 Paul Webster CLA 2014-04-17 15:32:13 EDT
I can see we can't use the CommandManager to manage help-per-handler any more, since the Command will return the HandlerServiceHandler.

I guess the primary thing to solve is the HandlerContributionItem responding to an SWT.Help event.  I think having your internal IHelpService would be OK.  It can take a command and handler, figure out a helpId, and display it.  The HandleContributionItem can provide the context and then look up the handler the same was as HandlerServiceHandler.  Then if it's an E4ProxyHandler, we can get the IHandler from it and calculate the helpId from that and fall back to the Command.  Then the call the workbench level help display.

The implementation of the IHelpService can live in the workbench, where it can see all of the players.



The secondary thing to solve is org.eclipse.ui.commands.ICommandService.getHelpContextId(String) mostly works like when called from org.eclipse.ui.menus.CommandContributionItem.CommandContributionItem(CommandContributionItemParameter)

PW
Comment 4 Paul Webster CLA 2014-04-24 15:13:01 EDT
When I rebase the change on master, I get some failures in UIAllTest:

UIAllTests-fixed
org.eclipse.e4.ui.tests.UIAllTests
org.eclipse.e4.ui.tests.workbench.MMenuItemTest
testElementHierarchyInContext_HandledItem(org.eclipse.e4.ui.tests.workbench.MMenuItemTest)
junit.framework.AssertionFailedError
	at junit.framework.Assert.fail(Assert.java:55)
	at junit.framework.Assert.assertTrue(Assert.java:22)
	at junit.framework.Assert.assertNotNull(Assert.java:256)
	at junit.framework.Assert.assertNotNull(Assert.java:248)
	at junit.framework.TestCase.assertNotNull(TestCase.java:417)
	at org.eclipse.e4.ui.tests.workbench.MMenuItemTest.testElementHierarchyInContext_HandledItem(MMenuItemTest.java:764)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

testMHandledMenuItem_Check_Bug316752(org.eclipse.e4.ui.tests.workbench.MMenuItemTest)
junit.framework.AssertionFailedError
	at junit.framework.Assert.fail(Assert.java:55)
	at junit.framework.Assert.assertTrue(Assert.java:22)
	at junit.framework.Assert.assertNotNull(Assert.java:256)
	at junit.framework.Assert.assertNotNull(Assert.java:248)
	at junit.framework.TestCase.assertNotNull(TestCase.java:417)
	at org.eclipse.e4.ui.tests.workbench.MMenuItemTest.testMHandledMenuItem_Check_Bug316752(MMenuItemTest.java:276)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at junit.framework.TestSuite.runTest(TestSuite.java:255)
	at junit.framework.TestSuite.run(TestSuite.java:250)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 6 Dani Megert CLA 2014-04-28 05:02:06 EDT
*** Bug 366562 has been marked as a duplicate of this bug. ***
Comment 7 Wojciech Sudol CLA 2014-04-29 05:23:00 EDT
Verified in I20140428-2000.