简体   繁体   English

选择计数大于1的Eclipse RCP Plugin.xml命令绑定启用

[英]Eclipse RCP Plugin.xml Command binding enablement with a selection count of more than 1

I'm trying to enable this command when 2 or more elements are selected. 我试图在选择2个或更多元素时启用此命令。 Here`sa snippet of my plugin.xml: 这是我的plugin.xml的一个片段:

<binding
  commandId="com.stackoverflow.commands.myCommand"
  rank="100">
 <enablement>
  <and>
   <count
    value="2">
   </count>
  </and>
 </enablement>
</binding>

This obviously only works when exactly 2 elements are selected. 显然,这仅在选择了恰好2个元素时才有效。 Any idea? 任何想法?

Use <not> with <or> like that: 像这样将<not><or>一起使用:

<binding
    commandId="com.stackoverflow.commands.myCommand"
    rank="100">
<enablement>
<not>
    <or>
        <count value="0" />   
        <count value="1" />
    </or>
</not>
</enablement>

I haven't tried it, but it should works. 我没有尝试过,但是应该可以。

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

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