How do you contribute a command to an editor context menu in Eclipse(您如何在 Eclipse 中向编辑器上下文菜单提供命令)
问题描述
我想在选择文本时向任何文本编辑器的上下文菜单提供一个命令.在过去"中,我会使用 objectContribution 和带有enablesFor='+'"的嵌套操作来完成此操作.
I want to contribute a command to the context menu of any text editor when text is selected. In "the old days", I would have done this using objectContribution and a nested action with "enablesFor='+'".
如何使用命令而不是操作来做到这一点?
How does one do this using commands instead of actions?
推荐答案
我阅读了有关命令表达式中可用变量的更多信息,我接近自己想弄清楚它,但失败了.然后我在 eclipse 新闻组上问了一个类似的问题,并被引导到正确的方向.下面是一个示例,说明如何主要做我正在寻找的事情:
I read more about the variables available in command expressions, and I came close to figuring it out on my own, but failed. I then asked a similar question on the eclipse newsgroup and was led in the right direction. Here's an example of how to do mostly what I was looking for:
<command
commandId="org.marcesher.blogcodeformatter.commands.wikiFormatterCommand"
tooltip="Format And Copy to Clipboard"
id="org.marcesher.blogcodeformatter.popup.wikiFormatterCommand">
<visibleWhen>
<with variable="selection">
<instanceof value="org.eclipse.jface.text.ITextSelection"/>
</with>
</visibleWhen>
这篇关于您如何在 Eclipse 中向编辑器上下文菜单提供命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:您如何在 Eclipse 中向编辑器上下文菜单提供命令
基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
