我正在尝试使用扩展点中的“处理程序”来激活多个条件的复制命令。如果我添加适用于单一 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/