Bug 484143 - visibleWhen has no effect for MenuManager added in AbstractContributionFactory
Summary: visibleWhen has no effect for MenuManager added in AbstractContributionFactory
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5.1   Edit
Hardware: PC Linux
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-10 14:19 EST by Ben Steffensmeier CLA
Modified: 2020-09-18 11:47 EDT (History)
2 users (show)

See Also:


Attachments
Simple plugin which illustrates the issue (5.26 KB, application/zip)
2015-12-10 14:20 EST, Ben Steffensmeier CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Steffensmeier CLA 2015-12-10 14:19:23 EST
Overview:
I am currently working on upgrading a custom Eclipse RCP based application from eclipse 3.8 to 4.5.1. We use AbstractContributionFactory extensively to create custom, dynamic menus(with sub-menus). When a Factory adds a MenuManager to the IContributionRoot with a visibleWhen Expression then the Expression is ignored and the menu is always visible.

Steps to Reproduce:
The attached plugin uses an AbstractContributionFactory to contribute an "Invisible" menu item to the main eclipse menu. This menu item has a visibleWhen expression that is always false so it should never appear. The expected behavior is seen in Eclipse 3.8 where the menu is never displayed. The error occurs in eclipse 4.5.1 where the menu is always displayed.

Analysis:
I have traced the problem into the eclipse plugins and I believe I understand the problem. It originates in the ContributionFactoryGenerator which creates an MMenuElement to represent any contribution item. When the visibleWhen Expression is evaluated it correctly updates the MMenuElement but when that event is processed in MenuManagerRenderer.toBeRenderedUpdater the visibility is not applied to the MenuManager. That method only applies visibility to MMenuElement which are rendered using an instanceof ContributionItem. It seems like if the ContributionFactoryGenerator was creating an MMenu for the MenuManager instead of an MMenuElement then the MenuManagerRenderer could process the visibility successfully.
Comment 1 Ben Steffensmeier CLA 2015-12-10 14:20:06 EST
Created attachment 258591 [details]
Simple plugin which illustrates the issue
Comment 2 Eclipse Genie CLA 2020-03-02 08:39:57 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Ron Anderson CLA 2020-08-17 11:39:40 EDT
This is still an issue and our previous workaround is no longer working.
In the 4.16 version of MenuManagerRender.subscribeUIEleemntTopicVisibility() at line 206, perhaps the check should be whether obj is an instanceof IContributionItem instead of just ContributionItem.

This is breaking our application and we would like to see this bug reopened and addressed.
Comment 4 Lars Vogel CLA 2020-08-17 11:43:16 EDT
Ron, could you provide a Gerrit?
Comment 5 Ron Anderson CLA 2020-08-17 16:19:51 EDT
(In reply to Lars Vogel from comment #4)
> Ron, could you provide a Gerrit?

I cannot. The suggestion I previously mentioned will not resolve the issue as MenuManagerRender.subscribeUIEleemntTopicVisibility() is not even being called to update the visibility of our menus so the change to the instanceof check would not help.
Comment 6 Eclipse Genie CLA 2020-09-18 11:47:59 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/169595