5

I am trying to make eclipse keybindings work. I tried to make the rename command work. I looked at some tutorials and experimented. I enabled command and key binding trace in console (http://eclipsesource.com/blogs/2009/07/08/tip-tracing-keybindings-in-rcp/).

I have created a custom command:

com.mycompany.myproduct.command.rename

This is what I got so far:

1) I tried to follow this tutorial,http://www.vogella.com/tutorials/EclipseCommandsKeybindings/article.html, but I came to the conclusion that this is for e3. This is because you need to add commands plugin that recognize only old e3 handlers. No xmi is involved

2) I tried to use xmi binding contexts. I had my command registered in the top level commands tree and connected to a handler in the top level handlers tree. In the binding tables section I have a bindingTable that works in Dialog and Windows context. I added a key binding. The sequence is "F2" and it is connected to my custom command.

When I hit F2 I get the following message in trace:

COMMANDS >>> execute >>> starting: id=org.eclipse.ui.edit.rename; event=ExecutionEvent(Command(org.eclipse.ui.edit.rename,Rename,
        Rename the selected item,
        Category(org.eclipse.ui.category.file,File,null,true),
        org.eclipse.ui.internal.MakeHandlersGo@1285594,
        ,,true),{},Event {type=1 Tree {} time=1480412218 data=null x=0 y=0 width=0 height=0 detail=0},org.eclipse.e4.ui.workbench.modeling.ExpressionContext@177fc1a)

In short the default eclipse IDE rename command is fired (my key binding does nothing), and nothing happens on my application.

However, if I change the sequece to "M1+1" and hit ctrl + 1, a little pop up comes up that lets me choose between "quick fix" (eclipse IDE command) and my rename. If I choose rename the handler fires.

Now, how do I disable eclipse IDE default keybindings. The instructions of the tutorial in step 1 definitely don't do it.

Thanks!

whomaniac
  • 1,258
  • 4
  • 15
  • 22
  • A pure e4 RCP should not be using any 'org.eclipse.ui.xxx' plugins – greg-449 May 13 '15 at 15:57
  • The Vogella [e4 tutorial](http://www.vogella.com/tutorials/EclipseRCP/article.html#keybindings) covers key bindings. – greg-449 May 13 '15 at 16:21
  • apprently there is a well known proble if the @FOCUS annotaion is missing. http://www.vogella.com/tutorials/EclipseRCP/article.html#runconfiguration_problems – whomaniac May 27 '15 at 13:03
  • Ok after upgrading eclipse and diving deeper in I managed to get the keybindings to work the E3 way. However, I am building an e4 application with the compatability layer and all of my commands are E4. It seems that E3 is blocking E4 keybindings... How do I over come that?? – whomaniac Jan 19 '16 at 14:40
  • 1
    And yes I do have some org,eclipse.ui.xxx plugins... But If I remove them my app won't work... – whomaniac Jan 19 '16 at 14:44
  • I have not seen anything on doing this. Once you have the compatibility layer your app is basically 3.x not e4. – greg-449 Jan 19 '16 at 15:09
  • Ok... So I have a little question for you. In Eclipse MARS IDE has the navigator (Package Explorer) part. To the best of my knowledge this an E3 part that requires the compatability layer. However using spies I know that MARS uses E4 binding tables!! So how does Eclipse IDE do that?? Thanks for your comments by the way!! – whomaniac Jan 20 '16 at 10:13
  • The core of Eclipse is e4, the compatibility layer maps all 3.x APIs to e4 internally. The Package Explorer is written entirely using the 3.x API. – greg-449 Jan 20 '16 at 10:20
  • So you are saying that I have 3.x core rather than an E4 core... Thanks! – whomaniac Jan 20 '16 at 10:38
  • No, the core of Eclipse 4 is always e4. But if you include the compatibility layer that will make it will behave like 3.x – greg-449 Jan 20 '16 at 10:40
  • I am confused... you wrote that once I use the compatability layer my app is basically 3.x which is why E4 keybindings don't work. But MARS uses the compatability layer and it has working E4 keybindings... What am I missing? – whomaniac Jan 20 '16 at 10:52

2 Answers2

7

You can try to force E4 to read your key binding as an user one, adding the "type:user" tag to the KeyBinding itself :

enter image description here

Arcadien
  • 2,258
  • 16
  • 26
  • Amazing!!! How did you know that??????? That information isn't available anywhere!!!! Seriously, how do you know that??? I even have Lars' book. Another question for you while we're speaking. I have a 3.x package explorer tree with an action provider that define a rename action via plugin.xml. This 3.x action runs an E4 rename handler. When I set my E4 keybinfing for rename (F2), can the rename action somehow recognize it and print it in the context menu? – whomaniac Jan 21 '16 at 14:11
  • You should be able to wire directly the keybinding to your handler, using an intermediate command : all of this in the e4xmi – Arcadien Jan 21 '16 at 14:52
  • You didn't say what was your source of information about the tag :-) – whomaniac Jan 21 '16 at 16:06
0

I swear sometimes it seems like the application just likes to see us suffer. I had the same issue you had; a while ago my key binding was working just fine and today I notice it doesn't work anymore. Thanks for this post I found 2 solutions:

  1. "type:user" from the above comment
  2. remove org.eclipse.ui from the run configurations; it seems this was added when I pressed add required plugins after adding some plugin myself
gdany
  • 104
  • 7