2

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
Lii
12.2k9 gold badges69 silver badges92 bronze badges
asked Jun 20, 2011 at 12:44
3
  • 1
    Is there anything in your error log? <workspace>/.metadata/.log or you can add -consoleLog to your launch arguments. You can also set some tracing options to see what happens when you press F9 - wiki.eclipse.org/Platform_Command_Framework#Tracing_Option Commented Jun 20, 2011 at 17:17
  • Thanks Paul!using tracing options i saw that an exception is thrown..more on edit Commented Jun 21, 2011 at 13:57
  • That means nothing is providing an implementation for that command in your RCP. Run the tracing in your eclipse and you'll get an idea of what is doing the work. Commented Jun 21, 2011 at 14:03

3 Answers 3

4

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.

answered Jun 20, 2011 at 13:10
Sign up to request clarification or add additional context in comments.

2 Comments

This would be true if I had defined the command..no? ToggleBreakpoint is a command defined in org.eclipse.debug.ui.commands.* and i would like to use that command. I successfully bind others commands from org.eclipse.debug.ui.commands.* but not ToggleBreakpoint.
If you want to override the behavior of an existing command, I have done that before by shadowing an entire JDT package. However, it is not guaranteed that your code will get run instead of the original. Another way to do it is with a feature patch I believe.
2

I suggest you go to

WindowsPreferencesGeneralKeys

and simply assign F9 to the Toggle Breakpoint command.

enter image description here

answered Jun 20, 2011 at 12:46

1 Comment

Hi, thanks for the response but it is not the case. I updated my question.
0

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.

answered Jun 20, 2011 at 15:22

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.