mdamman
mdamman

Reputation: 45

RCP App: Menu disabling when changing perspective with same view

I have this issue that I’m having trouble troubleshooting. We have two perspectives that contain the same view. This view has a menu that is enabled based on instanceof. If I select the item from the tree and right-click, the menu is enabled because the instanceof qualifies. If I then change to the other perspective that has the same view, the selection in the tree doesn’t change, but if I right click on the same item that is selected, the menu isn’t enabled anymore. I have to click off the view and back for it to enable the menu again. Here is how I have the plugin.xml defined. I think the plugin.xml is fine because it works fine when NOT changing the perspective. I just need to figure out why changing perspective refreshes the menu, but doesn’t recheck.

Also, if I switch to a perspective that doesn't contain this view, the menu is enabled when I come back.

<extension

     point="org.eclipse.ui.commands">

  <command

        id="com.cerner.automation.touchstone.workflow.Modify"

        name="%com.cerner.automation.touchstone.workflow.Modify.label">

  </command>

<extension

      point="org.eclipse.ui.handlers">

   <handler



         commandId="com.cerner.automation.touchstone.workflow.Modify">

      <enabledWhen>

         <with

               variable="selection">

            <iterate

                  ifEmpty="false"

                  operator="and">

               <instanceof

                     value="com.cerner.automation.touchstone.model.ModuleItem">

               </instanceof>

            </iterate>  

         </with>

      </enabledWhen>

   </handler>

</extension>

<extension

     point="org.eclipse.ui.menus">

  <menuContribution

        locationURI="popup:com.cerner.automation.touchstone.views.ModuleView">

     <command

           commandId="com.cerner.automation.touchstone.workflow.Modify"

           icon="icons/modify.png"

           label="%com.cerner.automation.touchstone.workflow.Modify.label"

           style="push">

     </command>

  </menuContribution>

 </extension>

Upvotes: 0

Views: 853

Answers (2)

Prakash G. R.
Prakash G. R.

Reputation: 4892

Most probably you are encountering this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=334524 Which version of Eclipse are you using? I fixed it in 3.7 M5. Does this happen in the recent builds or 3.7 M6?

Upvotes: 0

Viktor Stolbin
Viktor Stolbin

Reputation: 2939

It seems the problem is in element because selection is processing for any selection providers in perspective. When you switch perspective selection changes and menu item becames disabled. I used valiable activePartID to restrict count of selection providers to one view. Example provided:

<handler
            class="ru.griffo.core.handlers.EditBOHandler"
            commandId="ru.scops.applications.edit">
         <activeWhen>
            <and>
               <with
                     variable="activePartId">
                  <equals
                        value="ru.scops.applications.applications">
                  </equals>
               </with>
               <count
                     value="+">
               </count>
           <with
                 variable="selection">
              <iterate
                    ifEmpty="false"
                    operator="and">
                 <not>
                    <test
                          property="ru.griffo.core.ui.bo.super"
                          value="griffo.state.State">
                    </test>
                 </not>
              </iterate>
           </with>
        </and>
     </activeWhen>
  </handler>

Upvotes: 1

Related Questions