| Summary: | <visibleWhen> clauses are not honoured on the first popup | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] e4 | Reporter: | Remy Suen <remy.suen> | ||||
| Component: | UI | Assignee: | Paul Webster <pwebster> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P1 | ||||||
| Version: | 1.0 | ||||||
| Target Milestone: | 4.1 RC3 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | 346543 | ||||||
| Bug Blocks: | |||||||
| Attachments: |
|
||||||
|
Description
Remy Suen
This snippet will show up once in the 'Problems' view and then disappear. It is always there in 3.x.
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="org.eclipse.ui.file.save"
label="Save Test...">
<visibleWhen>
<with variable="org.eclipse.core.runtime.Platform">
<test property="org.eclipse.core.runtime.bundleState"
args="org.eclipse.ui"
value="ACTIVE"/>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
The 'org.eclipse.core.runtime.Platform' variable cannot be found so the visibleWhen becomes 'false'. It's not clear to me why it was there on the first show though. May have something to do with ObjectActionContributor.ObjectContribution's isApplicableTo(Object) method. The menu filter doesn't get run on the first show because the popup menu doesn't yet have a model at that point so no processing is/can be done. Hence, the menu items' visibility states are not calculated so the 'Watch' and 'Generate...' items shows up. I've opened bug 334257 for the missing variable problem. (In reply to comment #0) > The 'Watch' and 'Generate...' menu items show up in the context menu once and > then disappear the next time you show the menu. You will get the same behaviour > again if you close and reopen the view. This is the xml snippet that Debug uses for the 'Watch' menu item. <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions"> <command commandId="org.eclipse.debug.ui.actions.WatchCommand" icon="$nl$/icons/full/etool16/watch_exp.gif" label="%Watch.label" helpContextId="variable_watch_action_context"> <visibleWhen> <and> <with variable="org.eclipse.core.runtime.Platform"> <test property="org.eclipse.core.runtime.bundleState" args="org.eclipse.debug.ui" value="ACTIVE"/> </with> <with variable="selection"> <count value="+"/> <iterate> <instanceof value="org.eclipse.core.runtime.IAdaptable"/> <test property="org.eclipse.debug.ui.canCreateWatchExpression" value="true"/> </iterate> </with> </and> </visibleWhen> </command> </menuContribution> </extension> Created attachment 196171 [details] find the MenuManager and Model v01 As Remy says, if the widget doesn't exist in PopupMenuExtender, the next change we get to hook anything up is in the first PME menuAboutToShow(*). By then, we've already dropped out of MenuManagerRendererFilter, where we do our visibility processing. In the filter, look at the Menu to find the MenuManager (which allows us to find the model). Requires a fix in JFace, bug 346543 PW Released for RC3 PW In I20110524-2200 PW |