eclipse rcp keybindings don't work
Asked Answered
F

2

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!

Florettaflorette answered 13/5, 2015 at 15:54 Comment(11)
A pure e4 RCP should not be using any 'org.eclipse.ui.xxx' pluginsThan
The Vogella e4 tutorial covers key bindings.Than
apprently there is a well known proble if the @FOCUS annotaion is missing. vogella.com/tutorials/EclipseRCP/…Florettaflorette
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??Florettaflorette
And yes I do have some org,eclipse.ui.xxx plugins... But If I remove them my app won't work...Florettaflorette
I have not seen anything on doing this. Once you have the compatibility layer your app is basically 3.x not e4.Than
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!!Florettaflorette
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.Than
So you are saying that I have 3.x core rather than an E4 core... Thanks!Florettaflorette
No, the core of Eclipse 4 is always e4. But if you include the compatibility layer that will make it will behave like 3.xThan
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?Florettaflorette
A
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

Asymptote answered 21/1, 2016 at 9:28 Comment(3)
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?Florettaflorette
You should be able to wire directly the keybinding to your handler, using an intermediate command : all of this in the e4xmiAsymptote
You didn't say what was your source of information about the tag :-)Florettaflorette
B
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
Blessington answered 20/2, 2020 at 20:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.