Community
Participate
Working Groups
Build Identifier: M20110804-1800 In testing of upgrading an existing RCP application from Eclipse 3.6 to 4.1, I encountered a dynamic menu that is always displaying only the first menu item. I didn't write the code for this menu myself so I can't explain exactly why it was written the way it was, but when looking I see that the class providing the contribution extends ContributionItem rather than CompoundContributionItem as suggested on the wiki [1]. I don't know if there is anything inherently wrong with the original code that explains why it doesn't work in 4.1, but it works fine in 3.7. Out of curiosity, I tried modifying the code to extend CompoundContributionItem instead and then the menu worked fine in 4.1 so that is a workaround. I will be attaching snippets that demonstrate how to add a dynamic menu to the RCP mail demo app that demonstrates how the dynamic menu works in 3.7 but does not work in 4.1. I originally discovered the issue with I20110620-1631, but later also tested M20110804-1800 to see if it might have a fix and it did not. I searched to try to find an existing bug report for this issue but did not find one. My apologies if this has already been reported. [1] http://wiki.eclipse.org/Menu_Contributions/Populating_a_dynamic_submenu Reproducible: Always Steps to Reproduce: 1. Create a new RCP mail demo app project 2. Use the attached plugin.xml snippet to add a dynamic menu 3. Use the attached DynamicMenu class to provide the dynamic menu contribution referenced in the plugin.xml 4. Run the mail demo application against a 3.7 target platform and view the dynamic menu. It will display 3 items ("a","b","c"). 5. Run the mail demo application against a 4.1 target platform and view the dynamic menu. Only item "a" will display.
Created attachment 201105 [details] plugin.xml snippet providing menu contribution
Created attachment 201106 [details] DynamicMenu java class providing the dynamic menu contribution
Another workaround is to always return 'true' for isDirty().
(In reply to comment #3) > Another workaround is to always return 'true' for isDirty(). Yep, that's true - thanks.
This problem is caused by us calling update(*) twice on MenuManagers. The isDirty() optimization causes dynamic contribution items to not get rendered properly.
It seems to be the same issue as reported with the Bug 392876 Daniel *** This bug has been marked as a duplicate of bug 392876 ***