Community
Participate
Working Groups
In order to fix bug 136397 we tried to provide a proxy for the submenu and only load it when the plug-in is available: final Menu proxyMenu= new Menu(parent); // Listenter to load the menu when needed final MenuListener[] menuListeners = new MenuListener[1]; menuListeners[0] = new MenuListener() { public void menuHidden(MenuEvent e) { } public void menuShown(MenuEvent e) { MenuItem parentItem = proxyMenu.getParentItem(); if (parentItem != null) parentItem.setMenu(loadMenu(proxyMenu)); proxyMenu.removeMenuListener(menuListeners[0]); proxyMenu.dispose(); } }; proxyMenu.addMenuListener(menuListeners[0]); return proxyMenu; While this worked on Windows (with a little flickering) it crashes on Linux GTK (see bug 136397 comment 23). We'd probably need something like 'aboutToBeShown'.
Not for 3.3. It shouldn't flicker or crash but Bogdan can fix the crash first, then I will look at the flicker.
For 3.4 we should look with Platform UI whether this is a must have to fix bug 136397 and if so, fix this one.
Based on our attempts in bug 136397 it looks like I have 2 suggestions, either of which could help us: 1) In a SWT.Show event, allow us to swap out the source Menu with another Menu (both children of the same parent menu and same menu item). That is Dani's original example code with a slight mod: parentItem.setMenu(loadMenu(proxyMenu)); becomes parentItem.setMenu(loadMenu(parent)); 2) in the SWT.Arm event for a cascade menu item, allow us to call menuItem.setMenu(*) and have that be the menu that is cascaded. That's what I'm attempting in bug 136397 attachement #77368 Option 2 works on linux and the mac, just not reliably on windows. PW
Created attachment 78384 [details] Snippet The following snippet worked for me consistently on all platforms (well Linux, Mac and Win32) without flicker. Can you give it a try on your machine?
The snippet doesn't replace the menu on demand but already replaces the menu while selecting the 'Replaceble Menu' item. This is too early as we only want to load the plug-in when the casceded menu is inded shown. With the current snippet if you have: Menu1 Menu2 Proxy Menu3 Menu4 and scroll down the top menu, it replaces the proxy already while moving down to Menu3 or Menu4. That's why I think something along the lines of 'aboutToBeShown' might be needed.
(In reply to comment #4) > Created an attachment (id=78384) [details] > Snippet This works well on linux and Mac for me but it fails on Tod's boxes (both XP and Vista). When I use the arrow down to arm the cascade item and the arm listener swaps the menus, something pops up quickly and disappears, and then the cascade item remains armed but moving the mouse causes the first time to be armed as well. PW
Besides the fact that it doesn't fix the issue the snippet worked on my machine (T43p, WindowsXP Classic Look).
The show event is intended to be used as an "about to show" notification. Paul's going to try to replace the menu items with proxy menu items and forward events to the real menu items in a show listener. For Menu, the events are: Hide, Show and Help For MenuItems, the events are: Selection, Arm and Help.
Created attachment 78505 [details] Menu clone v01 Trying the ActionContributionItem menu clone idea with more events. PW
Created attachment 79731 [details] Menu copy v02 Have the ActionContributionItem proxy any submenus that it can. PW
(In reply to comment #10) > Created an attachment (id=79731) [details] > Menu copy v02 Bogden, could you please give my patch a quick review. It seems straight forward enough and it looks effective at delaying the request for the real menu until the proxy menu gets an SWT.Show event. PW
Paul - the patch looks good to me!
Released to HEAD >20071018 PW