Community
Participate
Working Groups
Hello, When I use a MDynamicMenuContribution and I populate it with MMenu objects, these are not cleaned (In the renderer?). To reproduce: 1. Add a Dynamic Menu Contribution to a Part. 2. Create a class with this implementation. @AboutToHide public void aboutToHide(List<MMenuElement> items) { // Clearing items here, has no effect. items.clear(); } @AboutToShow public void aboutToShow(List<MMenuElement> items) { MMenu menu = MMenuFactory.INSTANCE.createMenu(); menu.setLabel("Test");//$NON-NLS-1$ menu.setElementId("test.menu.id"); MDirectMenuItem createDirectMenuItem = MMenuFactory.INSTANCE.createDirectMenuItem(); createDirectMenuItem.setElementId("test.id.whatever"); createDirectMenuItem.setLabel("test"); createDirectMenuItem.setContributorURI("platform://...."); createDirectMenuItem.setContributionURI("bundleclass://..."); createChildMenuManager.getChildren().add(createDirectMenuItem); items.add(createChildMenuManager); } will try to diagnose, if this is indeed recognized as a bug. Note, no response on the forum, hence the bug report.
Potentially related to bug 375393.
As mentioned in the forum http://www.eclipse.org/forums/index.php/mv/msg/472828/1037345/#msg_1037345 , your usage scenario does not make sense to me. I see this bug as invalid, please discuss in the forum.
This bug is valid, please change the title of the bug to: "Incorrectly handling of MMenu element contributions in DynamicMenuContribution " Adding an MMenu element in a DynamicMenuContribution class leads to inconsistent behaviour. The respective contributions are not cleared as expected.
Thx Marco, Did you manage to reproduce? You want me to provide a patch?
Yes, could reproduce! If you want you can certainly try a patch, I will try to bring one up too! :)
I already got something that causes it. In MenuManagerRenderer#removeDynamicMenuContributions the contributions are incorrectly removed. This is due to the fact that MMenu does not have an associated IContributionItem. I could already provide a quick fix, by employing menuManager.removeAll(); instead of menuManager.remove(ici) per ContributionItem @Paul A question: - We do want to remove all items anyway before freshly populating the list. Wouldn't it be generally better to just call menuManager.removeAll() once instead of menuManager.remove(ici) n times? Like for performance etc.? - Should structurs like nested DynamicMenuContributions be supported? Remark: Will have to test for nested (>2) scenarios of MMenu contributions.
You're right, for MMenus we need to use getManager(*) instead of getContribution(*). The MenuManager returned from getManager(*) is its ICI. PW
Pushed a possible solution to https://git.eclipse.org/r/#/c/11856/ please review! I checked nested menus, they do work now. The ici==null comparison is for performance reasons as I think it is faster than the instanceof, now is it?
@Paul: I refactored the patch, unfortunatley I still do not seem to get the hang of gerrit, so sorry for the messed up patch, I hope it's okay though! The new dependencies came as I was not able to push the new patch without a pull ....
I completely reworked the patch in https://git.eclipse.org/r/#/c/11880/ please consider reviewing this one.
Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=3a4f5ff85b6b22a0cc0840ff539a4d0219f10b0c Thanks Marco. PW
Christophe, thanks for pointing this bug out! :)
Thanks for solving it! Do I need to be on edge, with the latest commit to get this fix? When do you expect it to show up in a build?
@Christophe, official build should be available soon via http://download.eclipse.org/e4/downloads/. AFAIK it is created daily, or you can use the vogella integration build which is triggered every 15 min if their is a new commit: p2 update site: http://download.vogella.com/kepler/e4tools
Ah, sorry this is for platform not the tools. Check out the nightly build from http://download.eclipse.org/eclipse/downloads/
In 4.3.0.I20130516-2200 PW
I see the same problem with Eclipse 4.8 when using DirectMenuItems (the menu itself is created with model editor). Was this fix special for MMenu types?