All icons in toolbars include the associated shortcut in the tooltip.
Examples of tooltips for icons:
New File... (Ctrl+N)
File Selection (Ctrl+F3)
Last edit (Ctrl+Q) Note: To follow convention the e should be capitalized.
However, the Run SQL icon does 'not' include the shortcut. Consider changing the tooltip for the Run SQL icon from:
Hint for fixing: make sure openide.loaders/Toolbar.addImpl() processes this button.
I guess it's caused by fix issue 152576, a keystroke for this action found but won't be propagated as Action.ACCERELERATOR_KEY into action.
Jirko, if you suspect bug 152576 to be responsible for this problem, then you can assign or CC author of that change directly.
org.openide.awt.Toolbar is not involved; this is an editor toolbar, processed using different infrastructure. It needs to set an accelerator the same way o.o.a.T would. While it would be possible to simply copy the method that does so, it relies on a hack to communicate with core which I would not want to spread into the editor module, so it is better to clean this up with a new small API - please review.
By the way, in this case it would be better to just delete the shortcut registration for this action, since it can be invoked more naturally now by the standard S-F6. (You could probably just add Run File to the editor toolbar, though I have not tried it.)
Created attachment 94137 [details]
Start of patch incl. new API; missing tests, usage in editor, apichanges
Y01 Rather than the javadoc warning, throw exception if instantiated by improper subclass.
Y02 keyStrokeForAction shall be protected to clearly state it is supposed to be implemented and not called (except by the infrastructure)
VS1: What would be the intended usage in the editor? Do we have to register our own AcceleratorBinding? This may potentially collide with MainMenuAction and its subclasses.
VS2: I assume that AcceleratorBinding is purely for UI purposes, it does not actually bind a shortcut to an action (at least so it seems in the patch).
VS3: In some cases the binding for an action may change - eg. when user selects a different keybinding profile or (not so common) when the action has different shortcuts for different editors (eg. file types) and user switches from one editor to another. How do these changes propagate through the AcceleratorBinding?
VS1 - no, the static method will be called from the editor's toolbar code. There is only one impl of the service, associated with NbKeymap.
VS2 - correct.
VS3 - they don't; NbKeymap handles this on its own, since the action has already been loaded.
Created attachment 94259 [details]
Probably final patch