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

Bug 108314

Summary: [Contributions] PopupMenuExtender does not update list of static actions when new menu ids are added
Product: [Eclipse Project] Platform Reporter: Amy Wu <for.work.things>
Component: UIAssignee: Douglas Pollock <douglas.pollock>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_williams, eclipse
Version: 3.1   
Target Milestone: 3.2 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Amy Wu CLA 2005-08-29 16:31:02 EDT
using eclipse 3.1

I want to register my editor's context menu under 2 different menu ids so 
clients can contribute to it using either id.

So I have something like the following:
String MENUID_1 = "menuid1";
String MENUID_2 = "menuid2";

MenuManager manager = new MenuManager(MENUID_1, MENUID_1);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(getContextMenuListener());

fTextContextMenu = manager.createContextMenu(styledText);
					styledText.setMenu(fTextContextMenu);

getSite().registerContextMenu(MENUID_1, manager, getSelectionProvider());

// also register this menu under another id
getSite().registerContextMenu(MENUID_2, manager, getSelectionProvider());


I notice that the actions contributed using MENUID_2 are not showing up.

Looks like in 
org.eclipse.ui.internal.PopupMenuExtender#addMenuId
when you add a menu id, you should also reset STATIC_ACTION_READ
so that you reread list of static actions next time menuAboutToShow.
Comment 1 Douglas Pollock CLA 2005-08-30 10:33:03 EDT
When the dynamic support was added to PopupMenuExtender, this flag was added.  
However, it wasn't reset in the addMenuId(String) method, so this bug was 
introduced. 
 
I'm going to add the following to addMenuId(String): 
 
		bitSet &= ~STATIC_ACTION_READ; 
		if (staticActionBuilder != null) { 
			staticActionBuilder.dispose(); 
			staticActionBuilder = null; 
		} 
		readStaticActions(); 
 
The rationale for the readStaticActions() is to try to get all the one-time 
only work done up-front -- instead of when trying to respond to a user event 
(e.g., right mouse button click). 
 
Comment 2 Douglas Pollock CLA 2005-08-30 10:44:24 EDT
Fixed in CVS. 
Comment 3 Kim Horne CLA 2005-09-06 14:42:50 EDT
I'm rolling back this fix as it's introduced bug 108709. 
Comment 4 Douglas Pollock CLA 2005-09-30 11:19:03 EDT
Fixed in HEAD ... again ... but better this time, I promise. 
Comment 5 Douglas Pollock CLA 2005-11-02 17:23:32 EST
Amy: Could you verify that I20051102-1200 or later fixes this problem for you? 
Comment 6 Amy Wu CLA 2006-04-19 13:26:28 EDT
verified in 3.2 RC1 (sorry it took so long to verify)