如何在Eclipse中为编辑器上下文菜单提供命令 [英] How do you contribute a command to an editor context menu in Eclipse

查看:136
本文介绍了如何在Eclipse中为编辑器上下文菜单提供命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当选择文本时,我想向任何文本编辑器的上下文菜单提供命令。在旧的日子中,我将使用objectContribution和一个嵌套的操作,使用enableFor ='+'。

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='+'".

推荐答案

我阅读更多关于命令表达式中可用的变量,我来了关闭自己弄清楚,但失败了。然后,我在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中为编辑器上下文菜单提供命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆