Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 365975

Summary: org.eclipse.ui.menus contribution behaves differently on 3.7 and 4.2
Product: [Eclipse Project] Platform Reporter: Ralf Ebert <ralf>
Component: UIAssignee: Paul Webster <pwebster>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, pwebster, remy.suen
Version: 4.2   
Target Milestone: 4.2 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Example project
none
Screenshot showing the duplicate delete command none

Description Ralf Ebert CLA 2011-12-07 18:27:06 EST
Build Identifier: 4.2 I20111206-1015

A contribution like this behaves differently on 3.7 and 4.2:

   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:org.eclipse.ui.main.toolbar">
         <toolbar
               id="com.example.addressbook.toolbar1">
            <command
                  commandId="org.eclipse.ui.file.save"
                  style="push">
            </command>
            <command
                  commandId="org.eclipse.ui.file.exit"
                  style="push">
            </command>
         </toolbar>
      </menuContribution>
      <menuContribution
            allPopups="true"
            locationURI="popup:org.eclipse.ui.popup.any">
         <command
               commandId="org.eclipse.ui.edit.delete"
               style="push">
            <visibleWhen
                  checkEnabled="false">
               <with
                     variable="selection">
                  <iterate
                        ifEmpty="false"
                        operator="and">
                     <instanceof
                           value="com.example.addressbook.Country">
                     </instanceof>
                  </iterate>
               </with>
            </visibleWhen>
         </command>
      </menuContribution>
   </extension>

- On 3.7 the save command will be disabled because no savable part is open, on 4.2 the save command is activated, and when clicked, it throws:

!MESSAGE The proxied handler for 'org.eclipse.ui.internal.handlers.SaveHandler' could not be loaded
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in org.eclipse.ui was unable to load class org.eclipse.ui.internal.handlers.SaveHandler.
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:176)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
	at org.eclipse.ui.internal.handlers.HandlerProxy.loadHandler(HandlerProxy.java:350)
	at org.eclipse.ui.internal.handlers.HandlerProxy.setEnabled(HandlerProxy.java:230)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.canExecute(E4HandlerProxy.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:228)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:209)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:123)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.canExecute(HandlerServiceImpl.java:108)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.canExecuteItem(HandledContributionItem.java:731)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$1(HandledContributionItem.java:720)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$2.run(HandledContributionItem.java:178)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.updateItemEnablement(HandledContributionItem.java:205)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$ToolItemUpdateTimer.run(HandledContributionItem.java:123)
	at org.eclipse.swt.widgets.Display.runTimers(Display.java:4107)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3605)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:977)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:893)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:91)
	at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:565)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:520)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.example.addressbook.Application.start(Application.java:20)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:352)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:624)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:579)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1433)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1409)
Caused by: java.lang.ClassNotFoundException: org.eclipse.ui.internal.handlers.SaveHandler
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:340)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1212)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
	... 45 more

- On 4.2, when opening the popup menu the first time, the command will be shown two times (see screenshot).

Reproducible: Always

Steps to Reproduce:
1. Import the attached example project.
2. Run the included product (adding equinox.concurrent/equinox.event + all required bundles manually in the run configuration)
3. See/click the save button in the toolbar.
4. Click the table viewer in the view on the left.
Comment 1 Ralf Ebert CLA 2011-12-07 18:27:31 EST
Created attachment 208079 [details]
Example project
Comment 2 Ralf Ebert CLA 2011-12-07 18:28:21 EST
Created attachment 208080 [details]
Screenshot showing the duplicate delete command
Comment 3 Paul Webster CLA 2011-12-08 14:53:57 EST
The exception is because org.eclipse.ui/plugin.xml still defines org.eclipse.ui.internal.handlers.SaveHandler as the default handler for org.eclipse.ui.file.save.

In 3.7 the default handler exists and returns disabled.

PW
Comment 4 Paul Webster CLA 2012-01-18 11:55:33 EST
as commit 87e62667fba514637e36765121e7d17763ed013b
Comment 5 Paul Webster CLA 2012-01-24 13:55:36 EST
in I20120123-2200
PW