java - 如何激活具有多个条件的 Eclipse UI 处理程序

标签 java eclipse handler

我正在尝试使用扩展点中的“处理程序”来激活多个条件的复制命令。如果我添加适用于单一 View 的条件,它就能正常工作。

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

但是当我与多种条件一起使用时,例如..
条件:

  • 它应该在“view1”或“view2”处于 Activity 状态时打开。
  • 并且选择的 cont 应该正好为 1,并且选择的实例应该是 example.xyz.ICharacteristicValue。

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

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

关于java - 如何激活具有多个条件的 Eclipse UI 处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56592047/

相关文章:

java - 选择该表中的任何行后,如何使 JTable 行变为 "unselected"状态?

java - Mockito 单元测试 RestTemplate

java - android ImageButton 在 api 8 中设置 alpha

java - 从 eclipse 使用 tomcat 服务器运行 web 项目

android - 如何在 Eclipse 中构建 APK 文件?

java - Install4j 处理多个屏幕的取消事件

java - 如何将 JTextField 添加到具有 JButton 的 Jpanel

c++ - 如何从终端运行用 eclipse 编写的 c++ 程序

javascript - SharePoint 2013 View 中所有浏览器中的 .js MIME 类型错误

php - ...vendor/composer/ClassLoader.php :444 (Laravel) 中没有这样的文件或目录