After a tricky way I explored how to attach the Accelerator Key Bindings to the RCP Application.
Following were the steps to do it:
1. An action to invoke => For eg. any of the actions like showF1HelpAction, undoAction, etc.
2. A command that invokes the action => this has to be done in plugin.xml => An example is as follows:
7. Register the actions to be invoked using key bindings for their own unique command identifiers as follows: a. Use a unique identifier string representing the command in the constructor of your action. Call the setId(), setActionDefinitionId() methods and pass this unique command identifier. b. In ApplicationActionBarAdvisor.makeActions(), register your action. When the command is invoked, RCP will look for a registered actions having the unique command identifier in action definition ID, and invoke it.
1. An action to invoke => For eg. any of the actions like showF1HelpAction, undoAction, etc.
2. A command that invokes the action => this has to be done in plugin.xml => An example is as follows:
<command category="com.somedomain.someproduct.commands.category" categoryId="com.somedomain.someproduct.commands.category"
defaultHandler="com.somedomain.someproduct.ui.handlers.UndoHandler" id="com.somedomain.someproduct.commands.undo" name="Undo">
</command>
3. A handler optionally to handle the command => this has to be done in plugin.xml => An example is as follows:
<handler class="com.somedomain.someproduct.ui.handlers.UndoHandler" commandId="com.somedomain.someproduct.commands.undo">
</handler>
4. A key binding that invokes the command (that invokes the action) => this has to be done in plugin.xml => An example is as follows:
<key commandId="com.somedomain.someproduct.commands.undo" schemeId="com.somedomain.someproduct.commands.key.binding.scheme" sequence="M1+Z">
</key>
5. Your own scheme which inherits from org.eclipse.ui.defaultAcceleratorConfiguration and overwriting the defaults
like Ctrl+S, Ctrl+C, Ctrl+V, etc. => this has to be done in plugin.xml => An example is as follows:
<scheme id="com.somedomain.someproduct.commands.key.binding.scheme" name="com.somedomain.someproduct.commands.key.binding.scheme"
parentId="org.eclipse.ui.defaultAcceleratorConfiguration">
</scheme>
6. A plug-in configuration file that enables your key bindings. => if not previously present, create a new
file plugin_customization.ini and enable the key binding as follows as follows:
a. Find your product extension under the org.eclipse.core.runtime.products extension point in the plugin.xml file.
b. Right click your product extension and select New > property.
c. In the name* field, enter preferenceCustomization. When RCP starts up your application, it will look up this
property to identify the plug-in configuration file to apply.
d. In the value* field, enter the name (and path, if appropriate) of your plug-in configuration file.
e. In the plugin_customization.ini file add an entry to enable key bindings as:
org.eclipse.ui/KEY_CONFIGURATION_ID=com.somedomain.someproduct.commands.key.binding.scheme7. Register the actions to be invoked using key bindings for their own unique command identifiers as follows: a. Use a unique identifier string representing the command in the constructor of your action. Call the setId(), setActionDefinitionId() methods and pass this unique command identifier. b. In ApplicationActionBarAdvisor.makeActions(), register your action. When the command is invoked, RCP will look for a registered actions having the unique command identifier in action definition ID, and invoke it.
1 comment:
Hey All, I just found another blog that will help you make these key-bindings context specific as well !!!!
For eg. depending upon what is selected if you wish to reuse the key-binding Ctrl+N for create new element; you will have to use it context-specific.
Finally, thanking to the blog author, I'm adding the url as follows:
http://sry-for-my-english.blogspot.com/2007/05/rcp-keybinding-issues.html
Post a Comment