Handled Menu Items contributed to the "ShowIn"-Menu do not evaluate Visible-When Expressions. Because of this problem, entries in the "ShowIn"-Menu can be disabled, but cannot be made invisible.
Steps to reproduce
Reproducing this problem inside the workspace requires additional PDE bundles (in order to create and modify a new E4 model fragment).
Since this is a E4 problem, the easiest reproduction I found for this is by modifying the "org.eclipse.e4.ui.examples.e4editor" test bundle and adding this bundle to my run configuration:
- Open the E4 fragment editor for /org.eclipse.e4.ui.examples.e4editor/fragment.e4xmi
- Add a new menu contribution with parent-ID org.eclipse.ui.menus.showInMenu
- Add a new handled menu item with a matching command and handler and connect them to each other
- Add a imperative expression for the menu item
- Create a new handler class which implements (at)Evaluate, (at)CanExecute and (at)Execute as follows (both the handled menu item and the imperative expression must point to this class):
- Add the "org.eclipse.e4.ui.examples.e4editor" bundle to a run configuration and start the application
- Inside the runtime application, create a new project and open the "ShowIn"-menu (via the context menu) -> The problem occurs: The added menu item is show as disabled although the imperative expression we've added for this item should make it invisible (since the "Evaluate" method of our handler always returns false)
For comparison: Change the parent-ID of the handled menu item to "popup" and restart the application -> The item is now an invisible entry in the popup menu (can be tested via breakpoints or by changing the "Evaluate" method to return true).
Note: I've tried fixing this issue as a PR but stopped, since it looks like fixing this would require a bigger change in the way the "ShowIn"-Menu is filled. As far as I can tell the root cause for this problem seems to be inside org.eclipse.ui.internal.ShowInMenu.fillMenu(IMenuManager). Here, the handled menu items get converted to CommandContributionItem without considering if a visibleWhen-Expression is present on the item.
Community
Handled Menu Items contributed to the "ShowIn"-Menu do not evaluate Visible-When Expressions. Because of this problem, entries in the "ShowIn"-Menu can be disabled, but cannot be made invisible.
Steps to reproduce
Reproducing this problem inside the workspace requires additional PDE bundles (in order to create and modify a new E4 model fragment).
Since this is a E4 problem, the easiest reproduction I found for this is by modifying the "org.eclipse.e4.ui.examples.e4editor" test bundle and adding this bundle to my run configuration:
For comparison: Change the parent-ID of the handled menu item to "popup" and restart the application -> The item is now an invisible entry in the popup menu (can be tested via breakpoints or by changing the "Evaluate" method to return true).
Note: I've tried fixing this issue as a PR but stopped, since it looks like fixing this would require a bigger change in the way the "ShowIn"-Menu is filled. As far as I can tell the root cause for this problem seems to be inside org.eclipse.ui.internal.ShowInMenu.fillMenu(IMenuManager). Here, the handled menu items get converted to CommandContributionItem without considering if a visibleWhen-Expression is present on the item.
Community