Community
Participate
Working Groups
Created attachment 222083 [details] Sample project showing the issue I noticed a problem in the perspective contributions, particularly perspectiveExtension, hiddenMenuItem, when I tried updating our product to Eclipse 4.2. I define two perspectives. I want one menu removed from one of the perspective. That works. The problem is that the menu is also removed from the other perspective. Is this a known issue? If so, it is planned to be addressed and when? I attached a small project demonstration the issues, and here are the steps to reproduce it: Import the attached plugin project in Eclipse 4.2 SDK. Start a launch configuration that clears the workspace. Open “My Edit Perspective” – see the “Run/Resume” menu is not there as expected by the contribution. Open “My Debug Perspective” – see the “Run/Resume” menu is not there. That is not what I expected. I only specified the menu to be removed from “My Edit Perspective”, not from “My Debug Perspective”. Thanks Dobrin
Thanks Dobrin. I took a quick look yesterday and it appears that I can get it to either appear or not on both depending on the order that I open the perspectives in. If I open the MyDebugPerspective first then it's always there. I've also verified that we only call the ModeledageLayout#addHiddenMenuItemId for the 'Edit' perspective so I'm not really sure what's up...
Out of curiosity: If we remove the check for isDynamic() in MenuManager#update(boolean, boolean) (line 790) the bug seems to disappear. But again, I have little understanding of the code at this moment.
I debug this issue by comparing 4.x with 3.8, it looks like the top level menu wasn't rebuild on perspective activation. I put back the code from 3.8 to rebuild the menu manager in WorkbenchWindow and it seems to resolved this issue. Here is what I did. Is this the correct fix for this issue? firePerspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { IMenuManager windowManager = ((WorkbenchPage)page).getActionBars().getMenuManager(); allowUpdates(windowManager); windowManager.update(false); UIListenerLogging.logPerspectiveEvent(this, page, perspective, UIListenerLogging.PLE_PERSP_ACTIVATED); perspectiveListeners.firePerspectiveActivated(page, perspective); } private void allowUpdates(IMenuManager menuManager) { menuManager.markDirty(); final IContributionItem[] items = menuManager.getItems(); for (int i = 0; i < items.length; i++) { if (items[i] instanceof IMenuManager) { allowUpdates((IMenuManager) items[i]); } else if (items[i] instanceof SubContributionItem) { final IContributionItem innerItem = ((SubContributionItem) items[i]).getInnerItem(); if (innerItem instanceof IMenuManager) { allowUpdates((IMenuManager) innerItem); } } } }
(In reply to comment #3) > I debug this issue by comparing 4.x with 3.8, it looks like the top level > menu wasn't rebuild on perspective activation. > I put back the code from 3.8 to rebuild the menu manager in WorkbenchWindow > and it seems to resolved this issue. > > Here is what I did. Is this the correct fix for this issue? The fix doesn't look like it will hurt anything (it's just marking the hierarchy dirty and that won't matter until the menus are shown). If it solves the problem, that might be it. See http://wiki.eclipse.org/Platform_UI/How_to_Contribute for submitting changes through Gerrit: http://git.eclipse.org/r/ PW
Thanks Paul. I have pushed to Gerrit - https://git.eclipse.org/r/#/c/11694/
Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=c62a3ef10e498c7866dc395bfbf81c1ed8fe20fe Thanks Patrick, PW
Has this made it into a build, yet?
It should be in http://download.eclipse.org/eclipse/downloads/drops4/I20130409-0900/ It might not help your bug which mentions hiddenToolItems, but the fix should be similar. PW
Patrick, does this work for you now in the latest 4.3 builds? PW
Verified in the build: I20130516-2200