如何在多个条件下激活 Eclipse UI 处理程序

How to activate Eclipse UI handler with multiple conditions

我正在尝试使用扩展点中的 "handler" 为多条件激活复制命令。如果我为单个视图添加工作条件,它工作正常。

 <extension
         point="org.eclipse.ui.handlers">
      <handler class="example.xyz.CopyHandler"
            commandId="org.eclipse.ui.edit.copy">
         <activeWhen
           <with
               variable="activePartId">
        </with>
           <equals
          value="example.xyz.view1">
           </equals>
        </with> 
     </activeWhen>
  </handler>
   </extension>

但是当我使用多种条件时,比如..
条件:

我试过这个片段,它不起作用。 这段代码有什么问题?

 <extension
             point="org.eclipse.ui.handlers">
    <handler
            class="example.xyz.CopyHandler"
            commandId="org.eclipse.ui.edit.copy">
         <activeWhen>
                 <with
                     variable="activePartId">
                 <iterate
                       operator="or">
                    <equals
                 value="example.xyz.view1">
                    </equals>
                    <equals
                          value="example.xyz.view2">
                    </equals>
                 </iterate>
               </with>
               <with
                     variable="selection">
                  <count
                        value="1">
                  </count>
                  <iterate>
                     <instanceof
                           value="example.xyz.ICharacteristicValue">
                     </instanceof></iterate>
               </with> 
       </activeWhen>
</handler>
 </extension>

<activeWhen 只接受 一个 子元素 - 你有两个。您需要将它们与 <and>:

<activeWhen>
   <and>
      <with
         variable="activePartId">
       .....
      </with>
      <with
         variable="selection">
       .....
      </with>
  </and>
</activeWhen>