Eclipse 命令的键绑定
我想将切换断点命令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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将以下内容添加到plugin.xml,其中defaultHandler是一个扩展AbstractHandler并覆盖execute()的类
此外,您还需要添加以下内容,其中 commandId 等于您在上面定义的命令的 id
以上是让我的插件正常工作所需的全部内容。如果它出现在“按键”首选项菜单中,您就会知道它正在工作。这是一个插件,当您按 Ctrl+Shift+D 时,会删除源代码中的所有注释。
You need to add the following to plugin.xml, where defaultHandler is a class extending AbstractHandler and overridding execute()
Also, you need to add the following, where commandId equals the id of the command you defined above
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.
我建议您转到
Windows→首选项→常规→键
并简单地分配F9 到切换断点命令。
I suggest you go to
Windows → Preferences → General → Keys
and simply assign F9 to the Toggle Breakpoint command.
您没有指定您正在使用哪个平台,但是...
某些平台 - 例如 MacOS - F9、F10 等的键分配 无法更改:-(
您也可以在常规 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.