Eclipse 命令的键绑定

发布于 2024-11-16 18:09:34 字数 1704 浏览 4 评论 0原文

我想将切换断点命令org.eclipse.debug.ui.commands.ToggleBreakpoint绑定到F9键。

我以这种方式扩展了 org.eclipse.ui.bindings :

<extension point="org.eclipse.ui.bindings">
  <scheme
        description="Default scheme for xvr"
        id="org.xvr.scheme"
        name="xvr.scheme"
        parentId="org.eclipse.ui.defaultAcceleratorConfiguration">
  </scheme>
  <key
        commandId="org.eclipse.debug.ui.commands.ToggleBreakpoint"
        contextId="org.eclipse.ui.contexts.window"
        schemeId="org.xvr.scheme"
        sequence="F9">
  </key>

但是,当我启动 RCP 应用程序时,如果按 F9,什么也不会发生。

我做错了什么?

编辑

很抱歉造成误解,但我正在开发 Eclipse 的新产品,并且无法使用 Eclipse 的首选项窗口。

我必须通过 org.eclipse.ui.bindings 扩展点提供绑定。

EDIT2

感谢 Paul,使用跟踪我发现当我按 F9 时会引发异常

COMMANDS >>> execute >>> starting: id=org.eclipse.debug.ui.commands.ToggleBreakpoint; event=ExecutionEvent(Command(org.eclipse.debug.ui.commands.ToggleBreakpoint,Toggle Breakpoint,
        Creates or removes a breakpoint,
        Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true),
        ,
        ,,true),{},Event {type=1 StyledText {} time=25349140 data=null x=0 y=0 width=0 height=0 detail=0},org.eclipse.core.expressions.EvaluationContext@ffa7e1)
COMMANDS >>> execute >>> not handled: id=org.eclipse.debug.ui.commands.ToggleBreakpoint; exception=org.eclipse.core.commands.NotHandledException: There is no handler to execute for command org.eclipse.debug.ui.commands.ToggleBreakpoint

I would like to bind the Toggle Breakpoint command, org.eclipse.debug.ui.commands.ToggleBreakpoint, to F9 key.

I extended org.eclipse.ui.bindings in this way:

<extension point="org.eclipse.ui.bindings">
  <scheme
        description="Default scheme for xvr"
        id="org.xvr.scheme"
        name="xvr.scheme"
        parentId="org.eclipse.ui.defaultAcceleratorConfiguration">
  </scheme>
  <key
        commandId="org.eclipse.debug.ui.commands.ToggleBreakpoint"
        contextId="org.eclipse.ui.contexts.window"
        schemeId="org.xvr.scheme"
        sequence="F9">
  </key>

But when I launch my RCP application nothing happens if I press F9.

What am I doing wrong?

EDIT

Sorry for the misunderstanding, but I'm developing a new product from eclipse and I can't use the preference window of eclipse.

I have to provide a binding through org.eclipse.ui.bindings extension point.

EDIT2

Thanks to Paul, using tracing I saw that an exception is thrown when I press F9

COMMANDS >>> execute >>> starting: id=org.eclipse.debug.ui.commands.ToggleBreakpoint; event=ExecutionEvent(Command(org.eclipse.debug.ui.commands.ToggleBreakpoint,Toggle Breakpoint,
        Creates or removes a breakpoint,
        Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true),
        ,
        ,,true),{},Event {type=1 StyledText {} time=25349140 data=null x=0 y=0 width=0 height=0 detail=0},org.eclipse.core.expressions.EvaluationContext@ffa7e1)
COMMANDS >>> execute >>> not handled: id=org.eclipse.debug.ui.commands.ToggleBreakpoint; exception=org.eclipse.core.commands.NotHandledException: There is no handler to execute for command org.eclipse.debug.ui.commands.ToggleBreakpoint

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

天邊彩虹 2024-11-23 18:09:34

您需要将以下内容添加到plugin.xml,其中defaultHandler是一个扩展AbstractHandler并覆盖execute()的类

   <extension point="org.eclipse.ui.commands">
    <command name="Remove All Comments"
        defaultHandler="commentremover.actions.CommentRemover"
        description="Removes all comments in source code"
        categoryId="org.eclipse.jdt.ui.category.source"
        id="commentremover.removeallcomments">
   </command>
</extension>

此外,您还需要添加以下内容,其中 commandId 等于您在上面定义的命令的 id

    <extension point="org.eclipse.ui.bindings">
    <key sequence="Ctrl+Shift+D"
        commandId="commentremover.removeallcomments"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
        contextId="org.eclipse.jdt.ui.javaEditorScope"/>
</extension>

以上是让我的插件正常工作所需的全部内容。如果它出现在“按键”首选项菜单中,您就会知道它正在工作。这是一个插件,当您按 Ctrl+Shift+D 时,会删除源代码中的所有注释。

You need to add the following to plugin.xml, where defaultHandler is a class extending AbstractHandler and overridding execute()

   <extension point="org.eclipse.ui.commands">
    <command name="Remove All Comments"
        defaultHandler="commentremover.actions.CommentRemover"
        description="Removes all comments in source code"
        categoryId="org.eclipse.jdt.ui.category.source"
        id="commentremover.removeallcomments">
   </command>
</extension>

Also, you need to add the following, where commandId equals the id of the command you defined above

    <extension point="org.eclipse.ui.bindings">
    <key sequence="Ctrl+Shift+D"
        commandId="commentremover.removeallcomments"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
        contextId="org.eclipse.jdt.ui.javaEditorScope"/>
</extension>

The above is all I needed to get my plugin to work. You will know it is working if it appears in the "Keys" preference menu. It is a plugin that removes all comments in the source code when you press Ctrl+Shift+D.

婴鹅 2024-11-23 18:09:34

我建议您转到

Windows首选项常规

并简单地分配F9切换断点命令。

在此处输入图像描述

I suggest you go to

WindowsPreferencesGeneralKeys

and simply assign F9 to the Toggle Breakpoint command.

enter image description here

万劫不复 2024-11-23 18:09:34

您没有指定您正在使用哪个平台,但是...

某些平台 - 例如 MacOS - F9F10 等的键分配 无法更改:-(

您也可以在常规 Eclipse 中从“Keys”首选项页面进行尝试。

You don't specify which platform you're working on, but...

one some platforms - e.g. MacOS - the key assignment for F9, F10, etc cannot be changed :-(

You can try that out inside a regular Eclipse as well from the Keys preference page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文