Community
Participate
Working Groups
Build Identifier: 3.7.0 I20110310-1119 I use org.eclipse.ui.menus to contribute a view local toolbar item to Expressions View and Registers View (they are a kind of Variables View) that each of this View type can have multiple instances. I need to control the visibility of the button in each view instance because the operation R is making sense to certain context X and so it should be invisible for other cases. Thus, I make the contribution command item to have a visibleWhen element that references an expresssion definition (org.eclipse.core.expressions.definitions). The expression definition then uses a property tester to test the support of the operation R for a particular view instance. However, the context X that the operation R relies is a pinned context of the view to a certain debugger. In other words, I cannot use the activePart variable because the active view could be a debug view or anything else that is not what I want. I cannot use 'debugContext' variable because the value is a selected item in a debug view, that may not be the same pinnied debugger context of a view instance of Expresssions/Registers view. I cannot use any other 'source' as defined in org.eclipse.ui.ISources. As a workaround of this problem in static command contribution item for views, I use a dynamic contribution item and make it also implements org.eclipse.ui.menus.IWorkbenchContribution that would tell the dynamic item about the IServiceLocator instance, from which I can getService for IWorkbenchPartSite. With the part site service, I can know the site that hosts this contribution item as well as the site's primary and secondary IDs. Then I can correctly figure out the pinned context of the view instance and know whether the view instance can support operation R. The workaround may have potential problem because it is not clear whether IWorkbenchContribution is also designed for local view's contribution items, while it is promising for main menu bar/coolbar/toolbar. Also, it needs the fix of 339415. In summary, my property tester needs to know which view instance (either site object, or both view's primary id and secondary id) is asking for testing a property in order for the tester to correctly answer the support of operation R. To be more general, a property tester needs to know more information from expression's evaluation context, e.g. service locator. Reproducible: Always
Will this be addressed in e4?
In Eclipse 4 a menu items visibility, enabled state, and executing are all done in its parent context. ex: The main menu is evaluated in the Window's active leaf context, but a view toolbar item is always evaluated in its views context. But property testers are executed against the "default variable", so unless being in the view context changes the notion of active part, I'm not sure what will happen. PW
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. If you have further information on the current state of the bug, please add it. 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. If the bug is still relevant, please remove the "stalebug" whiteboard tag.