Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354190 - [Contributions] [Compatibility] Dynamic menu displays only first item when extending ContributionItem rather than CompoundContributionItem
Summary: [Contributions] [Compatibility] Dynamic menu displays only first item when ex...
Status: CLOSED DUPLICATE of bug 392876
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Daniel Rolka CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-08 17:25 EDT by Ben Roling CLA
Modified: 2014-06-17 09:27 EDT (History)
2 users (show)

See Also:


Attachments
plugin.xml snippet providing menu contribution (527 bytes, text/plain)
2011-08-08 17:28 EDT, Ben Roling CLA
no flags Details
DynamicMenu java class providing the dynamic menu contribution (1.69 KB, application/octet-stream)
2011-08-08 17:29 EDT, Ben Roling CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Roling CLA 2011-08-08 17:25:15 EDT
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.
Comment 1 Ben Roling CLA 2011-08-08 17:28:23 EDT
Created attachment 201105 [details]
plugin.xml snippet providing menu contribution
Comment 2 Ben Roling CLA 2011-08-08 17:29:40 EDT
Created attachment 201106 [details]
DynamicMenu java class providing the dynamic menu contribution
Comment 3 Remy Suen CLA 2011-08-09 09:54:05 EDT
Another workaround is to always return 'true' for isDirty().
Comment 4 Ben Roling CLA 2011-08-09 14:42:51 EDT
(In reply to comment #3)
> Another workaround is to always return 'true' for isDirty().

Yep, that's true - thanks.
Comment 5 Remy Suen CLA 2011-08-09 22:00:34 EDT
This problem is caused by us calling update(*) twice on MenuManagers. The isDirty() optimization causes dynamic contribution items to not get rendered properly.
Comment 6 Daniel Rolka CLA 2014-06-17 09:27:33 EDT
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 ***