gpt4 book ai didi

java - Eclipse 命令的键绑定(bind)

转载 作者:行者123 更新时间:2023-11-30 05:57:00 26 4
gpt4 key购买 nike

我想将切换断点命令org.eclipse.debug.ui.commands.ToggleBreakpoint绑定(bind)到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 扩展点提供绑定(bind)。

编辑2

感谢 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

最佳答案

您需要将以下内容添加到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 时,会删除源代码中的所有注释。

关于java - Eclipse 命令的键绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6411329/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com