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
  • 11,553
  • 8
  • 64
  • 88
hara
  • 3,274
  • 4
  • 37
  • 55
  • 1
    Is there anything in your error log? `/.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 - http://wiki.eclipse.org/Platform_Command_Framework#Tracing_Option – Paul Webster Jun 20 '11 at 17:17
  • Thanks Paul!using tracing options i saw that an exception is thrown..more on edit – hara Jun 21 '11 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. – Paul Webster Jun 21 '11 at 14:03

3 Answers3

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.

Garrett Hall
  • 29,524
  • 10
  • 61
  • 76
  • 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. – hara Jun 20 '11 at 13:43
  • 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. – Garrett Hall Jun 20 '11 at 14:25
2

I suggest you go to

WindowsPreferencesGeneralKeys

and simply assign F9 to the Toggle Breakpoint command.

enter image description here

aioobe
  • 413,195
  • 112
  • 811
  • 826
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.

Chetan Bhagat
  • 610
  • 6
  • 21
Tonny Madsen
  • 12,628
  • 4
  • 31
  • 70