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

Bug 128293

Summary: [Contributions] visible/enabled: Object contributions contributed to submenus do not show up
Product: [Eclipse Project] Platform Reporter: Dmitry Karasik <Dmitry_Karasik>
Component: UIAssignee: Douglas Pollock <douglas.pollock>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: eclipse, edebolle, jean-michel_lemieux, rbarthold, sxenos
Version: 3.2Keywords: helpwanted
Target Milestone: 3.2 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
A plugin (w/source) to show the problem none

Description Dmitry Karasik CLA 2006-02-16 15:43:49 EST
Object contributions with menubarpath pointing to a contributed menu, such as the first example at http://publib.boulder.ibm.com/infocenter/wsphelp/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_popupMenus.html do not work with Eclipse 3.2M4.

What happens is when findMenuUsingPath is called, it finds the menu and wraps it using SubMenuManager.wrapMenu() which calls setVisible(isVisible()) on it. Unfortunately SubMenuManager.isVisible() calls getParentMenuManager().isVisible() which turns out to be MenuManager.isVisible() which only returns true if it has at least 1 visible child. If the MenuManager doesn't have any children yet (since we are in the first pass of ObjectActionContributionManager.contributeObjectActions, as in my case) it will return false and thus the wrapper will forever have its visibile field set to false. Here's the stack trace leading up to it:

Thread [main] (Suspended (breakpoint at line 405 in SubMenuManager))
	SubMenuManager.wrapMenu(IMenuManager) line: 405
	SubMenuManager.getWrapper(IMenuManager) line: 263
	SubMenuManager.find(String) line: 179
	SubMenuManager.findUsingPath(String) line: 216
	SubMenuManager.findMenuUsingPath(String) line: 193
	ObjectActionContributor$ObjectContribution(PluginActionBuilder$BasicContribution).contributeMenu(IConfigurationElement, IMenuManager, boolean) line: 299
	ObjectActionContributor.contributeObjectMenus(IMenuManager, ISelectionProvider) line: 166
	ObjectActionContributorManager.contributeObjectActions(IWorkbenchPart, IMenuManager, ISelectionProvider) line: 80
	PopupMenuExtender.addObjectActions(IMenuManager) line: 250
	PopupMenuExtender.menuAboutToShow(IMenuManager) line: 302
	MenuManager.fireAboutToShow(IMenuManager) line: 285
	MenuManager.handleAboutToShow() line: 372
	MenuManager.access$0(MenuManager) line: 369
	MenuManager$2.menuShown(MenuEvent) line: 386
	TypedListener.handleEvent(Event) line: 117
	EventTable.sendEvent(Event) line: 66
	Menu(Widget).sendEvent(Event) line: 914
	Menu(Widget).sendEvent(int, Event, boolean) line: 938
	Menu(Widget).sendEvent(int) line: 919
	Shell(Control).WM_INITMENUPOPUP(int, int) line: 3521
	Shell(Control).windowProc(int, int, int, int) line: 3238
	Shell(Decorations).windowProc(int, int, int, int) line: 1538
	Display.windowProc(int, int, int, int) line: 3963
	OS.TrackPopupMenu(int, int, int, int, int, int, RECT) line: not available [native method]
	Menu._setVisible(boolean) line: 225
	Display.runPopups() line: 3311
	Display.readAndDispatch() line: 2899
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1762
	Workbench.runUI() line: 1726
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 397
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 143
	IDEApplication.run(Object) line: 106
	PlatformActivator$1.run(Object) line: 109
	EclipseAppLauncher.runApplication(Object) line: 92
	EclipseAppLauncher.start(Object) line: 68
	EclipseStarter.run(Object) line: 379
	EclipseStarter.run(String[], Runnable) line: 177
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 85
	NativeMethodAccessorImpl.invoke(Method, Object, Object[]) line: 58
	DelegatingMethodAccessorImpl.invoke(Method, Object, Object[]) line: 60
	Method.invoke(Object, Object[]) line: 391
	Main.invokeFramework(String[], URL[]) line: 338
	Main.basicRun(String[]) line: 282
	Main.run(String[]) line: 977
	Main.main(String[]) line: 952
Comment 1 Michael Van Meekeren CLA 2006-02-24 10:09:23 EST
Dimitry, can you ship without having this fixed?
Comment 2 Dmitry Karasik CLA 2006-02-27 14:32:47 EST
We use dynamic submenus for object contributions. I would like to have a submenu for a number of related actions that are only interesting rarely to a few people, to avoid cluttering the main menu which has frequently needed actions. The work around is to put everything into the main menu.
Comment 3 Douglas Pollock CLA 2006-02-28 15:52:24 EST
Dmitry: Can you provide a patch?
Comment 4 Dmitry Karasik CLA 2006-02-28 16:36:15 EST
Yes, in SubMenuManager.wrapMenu() simply replace

        mgr.setVisible(isVisible());

with

        mgr.setVisible(super.isVisible());


This solves the sub menu contribution problem without affecting anything else.

Although SubMenuManager.isVisible() should be looked at as the circumstances under which it makes sense for a child to call parent.isVisible() are unclear to me.
Comment 5 Douglas Pollock CLA 2006-03-03 16:49:51 EST
Interesting.  The introduction of an "isVisible" method to SubMenuManager was introduced as part of a fix for Bug 47098.
Comment 6 Douglas Pollock CLA 2006-03-06 17:16:11 EST
I have tried to reproduce this problem, but I think I may be missing something (as it does seem like there is a flaw).  Can you provide a small test case showing the problem?  (I have tried the first example in the popupMenus extension point.)
Comment 7 Eric DeBolle CLA 2006-03-06 18:40:39 EST
*** Bug 130425 has been marked as a duplicate of this bug. ***
Comment 8 Dmitry Karasik CLA 2006-03-07 10:41:49 EST
Created attachment 35839 [details]
A plugin (w/source) to show the problem

The plugin registers an object contribution on java.lang.Object, so you can see its actions show up pretty much anywhere. You will notice in the package explorer the submenu does show up (because the context menu is prepopulated), but in the view provided in the plugin if you try to open the context menu only the action added to additions shows up.
Comment 9 Douglas Pollock CLA 2006-03-07 14:47:23 EST
*** Bug 130785 has been marked as a duplicate of this bug. ***
Comment 10 Douglas Pollock CLA 2006-03-07 15:20:31 EST
I have removed the isVisible method for SubMenuManager.  This change should appear in I20060314-0800 and later.  When that build becomes available, could those seeing this bug please confirm that the fix works for them?  Thanks.
Comment 11 Eric DeBolle CLA 2006-03-17 16:12:35 EST
I downloaded and tested eclipse-SDK-I20060314-1200-linux-gtk.tar.gz and this issue appears fixed to me. Thanks Doug.