2010-11-29 66 views
0

我遇到此問題,我在排除故障時遇到問題。我們有兩個包含相同觀點的觀點。該視圖具有基於instanceof啓用的菜單。如果我從樹中選擇項目並單擊鼠標右鍵,則由於instanceof符合要求,菜單已啓用。如果我然後切換到具有相同視圖的另一個視角,樹中的選擇不會改變,但是如果我右鍵單擊所選的相同項目,菜單將不再啓用。我必須點擊視圖並返回,才能再次啓用菜單。以下是我如何定義plugin.xml。我認爲plugin.xml很好,因爲它在不改變視角的情況下工作正常。我只需要弄清楚爲什麼更改透視圖會刷新菜單,但不會重新檢查。RCP App:使用相同視圖更改透視圖時禁用菜單

另外,如果我切換到不包含此視圖的透視圖,則菜單在我回來時啓用。

<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> 

回答

1

看來問題是在元件因爲選擇處理在透視任何選擇供應商。當您切換透視選擇更改並禁用菜單項時。我使用valiable activePartID將選擇提供程序的計數限制爲一個視圖。例如提供:

<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> 
+0

謝謝,但這並沒有改變任何東西。仍然有同樣的問題。這兩個觀點中的視圖的實例是否相同? – mdamman 2011-01-10 21:51:48