Community
Participate
Working Groups
Bugzilla – Bug 293044
[QuickAccess] Ability to show bound keys in Quick Access list
Last modified: 2010-09-01 22:23:23 EDT
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 Build Identifier: 20090920-1017 I'd like to be able to show the bound keys in the Quick Access list. That way, whenever I control-3 something, I can more easily learn the shortcut and use that, instead of having to control-3 all the time. Reproducible: Always Steps to Reproduce: 1. Type control-3 (with default key bindings) 2. The Quick Access menu shows up 3. A list of available commands / links / whatevers comes up 4. Keyboard shortcuts aren't shown
Created attachment 150355 [details] A proposed patch for this enhancement request. The patch implements the request to show the available key bindings for a given command in the QuickAccessDialog. It does not change the API anyhow, and remains in the same spirit (ie, the key sequence is appened to the label, and not in a distinct field). I also had to change QuickAccessDialog to augment its context in order to have the IBindingService provide the global key shortcuts (this is inspired/copied from the KeyAssistDialog). It seems to work fine ; this is my first patch for Eclipse so please be nice :).
(In reply to comment #1) > Created an attachment (id=150355) [details] > A proposed patch for this enhancement request. This looks okay to me, Simon. Can you prepare a new patch that sets the 'Patch Root' to the workspace (on the second page of the patch creation wizard)? Also, please update the copyright notice of every file that you have changed with your credentials like the following example... Remy Suen <remysuen@ca.ibm.com> - Bug 12345 Summary blah blah blah
(In reply to comment #1) > Created an attachment (id=150355) [details] > A proposed patch for this enhancement request. Cool! Thanks for the patch, could you also attach a screenshot of how it looks with the key bindings displayed?
Created attachment 150494 [details] Patch revised according to Remy Suen's comment Thanks for the comment Remy. I have adapted the patch accordingly.
Created attachment 150495 [details] Screenshot of the patched Quickaccess (In reply to comment #3) > (In reply to comment #1) > > Created an attachment (id=150355) [details] [details] > > A proposed patch for this enhancement request. > > Cool! Thanks for the patch, could you also attach a screenshot of how it looks > with the key bindings displayed? Here it goes. In most cases we have to resize the Quickaccess popup to see the bindings, because some commands have a rather lengthy name. A nice bonus to adding the binding in the label is that one can filter on the key shortcut, which is quite nice to learn some shortcuts the other way around (maybe the KeyAssist popup is better for that though, since it only shows commands with key bindings). On a side note, there might be a bug to report with some commands (available in standard Eclipse distributions) that assume they're not called from outside and throw exceptions when called from the Quickaccess popup (the patch does not change anything there -- the bug exists in Galileo).
I wouldn't try and treat the quick access shell as a useful shell. Instead, you can use org.eclipse.jface.bindings.BindingManager.getActiveBindingsDisregardingContext() or org.eclipse.jface.bindings.BindingManager.getActiveBindingsDisregardingContextFlat() to work find the matching bindings. PW
Created attachment 150505 [details] Revision according to Paul Webster's comment (In reply to comment #6) > I wouldn't try and treat the quick access shell as a useful shell. > > Instead, you can use > org.eclipse.jface.bindings.BindingManager.getActiveBindingsDisregardingContext() > or > org.eclipse.jface.bindings.BindingManager.getActiveBindingsDisregardingContextFlat() > to work find the matching bindings. Thanks for the pointer. Here it goes. I take it I can safely assume the IBindingService will always be a BindingService from within the workbench (since it was registered in Workbench.java). If not, I can make a type check before using it and fallback on the regular, not context-disregarding IBindingService.getActiveBinding() method available. Also, there is no getBestActiveBindingsDisregardingContextXXX() family of methods, so in this patch I simply return the first binding if there is one. Maybe it would be refactorable into a getBestActiveBindingForCommandInContext(command, context) with context disregarded if null. Finally, I had adapted the registerShell() method from KeyAssistDialog.java which doesn't look more like an useful shell than the QuickAccessDialog to me. Maybe it should be adapted to use the BindingManager.getActiveBindindsDisregardingContext() methods too.
(In reply to comment #7) > I take it I can safely assume the IBindingService will always be a > BindingService from within the workbench (since it was registered in > Workbench.java). If not, I can make a type check before using it and fallback > on the regular, not context-disregarding IBindingService.getActiveBinding() > method available. Actually I can reply to myself: it is possible for third parties to call PlatformUI.getWorkbench().getServiceLocator().registerService(IBindingService.class, theirServiceImplementation); with theirServiceImplementation likely not inheriting BindingService which is internal. Obviously, this would result in a ClassCastException... However, to do that you must implement IBindingService.. which clearly states: * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. So I guess it's OK.
I'm happy with the functionality (looking up key bindings is cool) but not as happy yet with the look. I think the key binding has to be in its own column, or rendered in a way that is less distracting, perhaps in grey similar to the CVS decorations in the package explorer.
Remy is now responsible for watching bugs in the [QuickAccess] component area.
*** Bug 215178 has been marked as a duplicate of this bug. ***
(In reply to comment #9) > I'm happy with the functionality (looking up key bindings is cool) but not as > happy yet with the look. I think the key binding has to be in its own column, > or rendered in a way that is less distracting, perhaps in grey similar to the > CVS decorations in the package explorer. Susan, I would prefer colouring it differently over making another column, what do you think?
Created attachment 164579 [details] Show keybindings for QuicKAccess patch v4 This patch will use the JFace "qualifier" colour for decorating the keybinding.
Created attachment 164581 [details] Screenshot depicting the behaviour in question. This is on Windows XP.
(In reply to comment #14) > Created an attachment (id=164581) [details] > Screenshot depicting the behaviour in question. > > This is on Windows XP. I like it.
Created attachment 164692 [details] Show keybindings for QuicKAccess patch v5 Generalize the appending of "qualifier" information.
(In reply to comment #16) > Created an attachment (id=164692) [details] > Show keybindings for QuicKAccess patch v5 Patch released to HEAD. Thanks for the original patch, Simon!
Whoops.
In other places where we colorize qualifiers, we also colorize the separator. See e.g. a JAR in the 'JRE System Library' in the Package Explorer: '-' is also gray. In tooltips, we render key bindings as '<label> (<binding>)'. Do we really need a different notation here?
(In reply to comment #19) > In tooltips, we render key bindings as '<label> (<binding>)'. Do we really need > a different notation here? Mm, I see your point. I was initially thinking of dropping the " - " but kept it in the end. However, there's also the problem that other labels use the " - " string as a separator so I think I'll swap this so that the keybinding are contained within a pair of parentheses.
Fixed in HEAD. Thanks for the tip, Markus.
Looks good. One last problem: The parentheses should be externalized. Since you can't know where the shortcut will be rendered, you should implement the coloring like e.g. org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal.getStyledDisplayString(): StyledString str= new StyledString(getName()); String shortCutString= CorrectionCommandHandler.getShortCutString( getCommandId()); if (shortCutString != null) { String decorated= Messages.format( CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, new String[] { getName(), shortCutString }); return StyledCellLabelProvider.styleDecoratedString( decorated, StyledString.QUALIFIER_STYLER, str); }
Created attachment 165091 [details] Show keybindings for QuickAccess patch v6 (In reply to comment #22) > One last problem: The parentheses should be externalized. I decided to reuse CommandMessages.Tooltip_Accelerator here. > Since you can't know > where the shortcut will be rendered, you should implement the coloring like > e.g. > org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal.getStyledDisplayString(): I don't want to swap the code to completely use a StyledCellLabelProvider in M7. What do you think of this patch, Markus? I'm a little iffy about applying all the returned StyleRanges but since I don't know how the string will be externalized, I can't really "pick and choose".
(In reply to comment #23) > Created an attachment (id=165091) [details] > Show keybindings for QuickAccess patch v6 Markus, what do you think about this? I'd like to get this corrected for M7 if possible instead of pulling the feature out and then leaving it for 3.7.
(In reply to comment #24) > (In reply to comment #23) > > Created an attachment (id=165091) [details] [diff] [details] > > Show keybindings for QuickAccess patch v6 > > Markus, what do you think about this? I'd like to get this corrected for M7 if > possible instead of pulling the feature out and then leaving it for 3.7. Looks good, please release.
(In reply to comment #25) > Looks good, please release. Released to HEAD. Thank you very much, Markus.
Verified with I20100425-2000 on Windows XP. Thanks for the assistance, Simon and Markus.
Filed bug 314269 to follow-up on this.
*** Bug 324264 has been marked as a duplicate of this bug. ***