Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367816

Summary: [Keybinding] some bindings don't work with Juno 4.2
Product: [Eclipse Project] Platform Reporter: Vincent Lorenzo <vincent.lorenzo>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: cosmin.lazar, daniel_megert, dkratzmann, gautier.desaintmartinlacaze, heiko.boettger, marianocamarzana, mdev, per, pwebster, remy.suen, tom.schindl, torkildr, verawahler
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Bug Depends on:    
Bug Blocks: 382218    

Description Vincent Lorenzo CLA 2012-01-04 04:15:00 EST
I declared commands using org.eclipse.ui.commands and binding with org.eclipse.ui.bindings.
These bindings appears in the Eclipse Preference Page, but  : 
	- they don't work
	- they don't appear in the menus, on the right of the action
	
These commands and binding work with Eclipse 3.7 and 3.8, but not with Juno 4.2
Comment 1 Paul Webster CLA 2012-01-04 07:16:12 EST
Please attach and example command/handler/binding definition that doesn't work.

PW
Comment 2 Vincent Lorenzo CLA 2012-01-04 09:47:53 EST
I created an example and its works fine... Sorry for the bug. I'm looking for the error in my project.
Comment 3 Thomas Schindl CLA 2012-01-04 09:50:27 EST
if something works in 3.8 it is supposed to work in 4.2 as well so:
a) you are doing something illegal that only works by chance in 3.8
b) the compat layer is buggy
Comment 4 Vincent Lorenzo CLA 2012-06-11 09:01:51 EDT
After investigating, I found that that my keybinding was declared on a "parentContext". My editor contexts is declared as a children of this parentContext using parentId in the plugin.xml.
It seems me that the inheritance between the 2 contexts is not correctly managed. 
My binding works only when I active the editor context and the parentContext for my editor.
Comment 5 Vera Henneberger CLA 2012-07-05 15:11:33 EDT
It seems that I have some problems with my declared commands under Juno.

These are the command & key binding I declared:

<extension point="org.eclipse.ui.commands">
<command name="Choose Target"
	 defaultHandler="com.github.quick.launcher.ui.LaunchChooseAction"
	 description="Choose Target"
	 categoryId="org.eclipse.ui.category.views"
	 id="com.github.quick.launcher.ui.chooseaction">
</command>
</extension>
	
<extension point="org.eclipse.ui.bindings">
	<key sequence="CTRL+ALT+L"
	     commandId="com.github.quick.launcher.ui.chooseaction"
	     contextId="org.eclipse.ui.contexts.window"
	     schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
	</key>
</extension>

That works fine under Juno if I use the eclipse rcp bundle. 
But if I install my plugin under the "eclipse for java developers" the command does not show up in the preferences.

Everthing worked fine in eclipse 3.7.
Comment 6 Vera Henneberger CLA 2012-07-06 07:49:01 EDT
Sorry for my comment yesterday, I still don't know what causes the problems for my commands to work under Juno, but in a simple sample project I got it running under Juno. So it seems there is something different going wrong and has nothing to do with the command extension point.
Comment 7 Per Digre CLA 2012-07-10 11:22:55 EDT
Seems like I have a similar situation with keybindings not appearing in Juno. 
All my custom key-bindings are not bound when I start the runtime-workbench. I am guessing that I am confirming the same issue. 

1. Unbound keys would be the ones that are not normally bound by the Eclipse Workbench such as F6, or F3. Ctrl+V and standard keys however binds fine to my custom actions.

2. I do notice that if I switch perspective they will show up and work correctly, so I suspect there's a problem with the initialization of the workbench and restoring the perspective.

3. Also same behavior with Eclipse RCP and my plugins installed. Have not tested other Eclipse packages. My download is Build id: 20120614-1722, for 32-bit Windows, JDK 1.6. 

4. Additional... When I opened my perspective for first time after installing the plugins, then imported a project so that the keybindings would come into effect, then they were not bound. After closing and reopening the perspective they work ok again. 

5. There's nothing in the logs that indicates a problem.
Comment 8 Paul Webster CLA 2012-07-10 11:47:08 EDT
Per, I need you to open a new bug with the description of your problem please.  Vincent has a problem where activating a child context doesn't take the parent context into consideration in 4.2.

PW
Comment 9 Per Digre CLA 2012-07-11 02:22:28 EDT
Bug 384799 Submitted for my case...
Comment 10 Cosmin Lazar CLA 2012-08-24 04:36:43 EDT
(In reply to comment #8)
> Per, I need you to open a new bug with the description of your problem
> please.  Vincent has a problem where activating a child context doesn't take
> the parent context into consideration in 4.2.
> 
> PW

It sounds like I've got a similar problem: {{bugzilla|387951}}
Comment 11 Torkild Resheim CLA 2015-10-20 09:51:13 EDT
I believe what we are seeing is described in this blog post: http://techblog.ralph-schuster.eu/2013/10/13/eclipsee4-problem-with-key-bindings/comment-page-1/

Basically org.eclipse.ui.workbench throws away keybindings with certain contexts. I.e. org.eclipse.ui.contexts.window. If I create a new context inheriting from "org.eclipse.ui.contexts.window" the keybinding will work as expected.
Comment 12 Torkild Resheim CLA 2015-10-20 09:51:53 EDT
PS: I'm still seeing this issue on Eclipse 4.5
Comment 13 Daniela Kratzmann CLA 2016-10-24 04:44:30 EDT
I have the same problem as described in comment 4 with Eclipse 4.6.1. Bindings defined in a parentContext don't work.
Here is an example:

   <extension point="org.eclipse.ui.contexts">
        <context
            id="context.parent"
            name="Parent Context"
            parentId="org.eclipse.ui.contexts.window">
        </context>
        <context
            id="context.child1"
            name="Child 1 Context"
            parentId="context.parent">
        </context>
        <context
            id="context.child2"
            name="Child 2 Context"
            parentId="context.child1">
        </context>
    </extension>
   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="example.command"
            contextId="context.parent"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
            sequence="M1+1">
      </key>
   </extension>
   
If 'contexts.child1' or 'contexts.child2' is activated the key binding doesn't work, only if 'contexts.parent' is active it works.

After debugging the code I think the method org.eclipse.e4.ui.bindings.internal.BindingTableManager.getSequencesFor(...) must be changed. It ignores the parentContexts.
Something like that should be added:

	String parentId = c.getParentId();
	if (parentId != null) {
		table = callee.getTable(parentId);
		if (table != null) {
			Collection<Binding> sequences = table.getSequencesFor(parameterizedCommand);
			if (sequences != null) {
				bindings.addAll(sequences);
			}
		}
	}        

But with this it only works with contexts.child1 activated, not with contexts.child2. All parents must be found.
Comment 14 Andrey Loskutov CLA 2018-03-13 17:26:34 EDT
*** Bug 532009 has been marked as a duplicate of this bug. ***
Comment 15 Eclipse Genie CLA 2020-06-03 15:08:43 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.