Bug 491701 - [KeyBinding] get best active binding is not working
Summary: [KeyBinding] get best active binding is not working
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-14 10:15 EDT by Patrik Suzzi CLA
Modified: 2021-06-17 02:50 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrik Suzzi CLA 2016-04-14 10:15:27 EDT
the binding service not working as exprected when getting active binding, i.e. in in : IBindingService#getBestActiveBindingFor();

To reproduce: 

1. Fetch the following change from Gerrit: 
https://git.eclipse.org/r/#/c/70577/6/bundles/org.eclipse.ui.workbench/Eclipse+UI/org/eclipse/ui/internal/quickaccess/SearchField.java

2. Edit the method  updateQuickAccessTriggerSequenceFormat as follows: 

protected void updateQuickAccessTriggerSequenceFormat() {
	TriggerSequence triggerSequence = bindingService.getBestActiveBindingFor(QUICK_ACCESS_COMMAND_ID);
	this.quickAccessTriggerSequenceFormat = triggerSequence.format();
}

3. Launch and observe the buggy behavior:
getBestActiveBindingFor(QUICK_ACCESS_COMMAND_ID) returns null.

The expected behavior is: 
getBestActiveBindingFor(QUICK_ACCESS_COMMAND_ID) will return a non null triggerSequence, as the QuickAccess KeyBinding is active at the moment when the method is called.
Comment 1 Patrik Suzzi CLA 2016-04-14 13:07:35 EDT
Brian, hope you don't mind if I ask feedback to you

As a caller, I expect IBindingService#getBestActiveBindingFor() returns the best binding by searching in all the contexts of the application. 

With the current behavior the method is searching for the binding only in the active context. This is unclear, as is often unclear which is the active context. 

My plan is to simply change the implementation of getBestActiveBindingFor() to see the logic that searches in all the contexts, that I think should be replaced as you can see in the current method: 

ParameterizedCommand cmd = eCommandService.createCommand(MY_COMMAND_ID, null);
ContextSet contextSet = manager.createContextSet(Arrays.asList(contextService.getDefinedContexts()));
Binding binding = manager.getBestSequenceFor(contextSet, cmd);
triggerSequence = binding.getTriggerSequence();
Comment 2 Brian de Alwis CLA 2016-04-14 13:57:03 EDT
If we search through all contexts then it's not returning the active binding!
Comment 3 Brian de Alwis CLA 2016-04-14 16:36:47 EDT
I'm unable to reproduce this issue on Windows and Linux-GTK.
Comment 4 Brian de Alwis CLA 2016-04-14 16:37:54 EDT
Verified under Windows 10 and Ubuntu 14.04 with the patch at https://git.eclipse.org/r/70706
Comment 5 Eclipse Genie CLA 2020-03-01 17:44:47 EST
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.
Comment 6 Mickael Istria CLA 2021-06-17 02:50:45 EDT
Still relevant in parts of Eclipse Platform (eg Quick Access)