Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332246 - <visibleWhen> clauses are not honoured on the first popup
Summary: <visibleWhen> clauses are not honoured on the first popup
Status: VERIFIED FIXED
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: 4.1 RC3   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 346543
Blocks:
  Show dependency tree
 
Reported: 2010-12-09 14:52 EST by Remy Suen CLA
Modified: 2011-05-25 07:51 EDT (History)
0 users

See Also:


Attachments
find the MenuManager and Model v01 (2.52 KB, patch)
2011-05-19 17:16 EDT, Paul Webster CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2010-12-09 14:52:27 EST
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.
Comment 1 Remy Suen CLA 2011-01-12 13:28:33 EST
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>
Comment 2 Remy Suen CLA 2011-01-12 13:54:57 EST
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.
Comment 3 Remy Suen CLA 2011-01-13 08:58:47 EST
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.
Comment 4 Remy Suen CLA 2011-05-17 16:36:08 EDT
(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>
Comment 5 Paul Webster CLA 2011-05-19 17:16:40 EDT
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
Comment 6 Paul Webster CLA 2011-05-24 16:21:46 EDT
Released for RC3
PW
Comment 7 Paul Webster CLA 2011-05-25 07:51:42 EDT
In I20110524-2200
PW