简体   繁体   English

RCP应用程序:更改具有相同视图的透视图时,菜单禁用

[英]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. 该视图具有一个基于instanceof启用的菜单。 If I select the item from the tree and right-click, the menu is enabled because the instanceof qualifies. 如果我从树中选择该项目并单击鼠标右键,则会启用菜单,因为instanceof符合条件。 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. 这是我定义的plugin.xml的方式。 I think the plugin.xml is fine because it works fine when NOT changing the perspective. 我认为plugin.xml很好,因为在不更改视角的情况下它可以正常工作。 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>

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. 我使用可变的activePartID将选择提供程序的数量限制为一个视图。 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>

Most probably you are encountering this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=334524 Which version of Eclipse are you using? 您最有可能遇到此错误: https : //bugs.eclipse.org/bugs/show_bug.cgi? id = 334524您正在使用哪个版本的Eclipse? I fixed it in 3.7 M5. 我将其固定在3.7 M5中。 Does this happen in the recent builds or 3.7 M6? 这会在最近的版本或3.7 M6中发生吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM