Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Plug-in Developer Guide
Previous Page Home Next Page

Key bindings

The association between a command and the key combinations that should invoke the command is called a key binding Plug-ins can define key bindings along with commands in the org.eclipse.ui.bindings extension point. From our InfoView example:

   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="org.eclipse.ui.examples.contributions.view.edit"
            contextId="org.eclipse.ui.examples.contributions.view.context"
            sequence="M1+O"
            schemeId="org.eclipse.ui.examples.contributions.scheme">
      </key>
   </extension>

The sequence attribute for a key binding defines the key combination that is used to invoke a command. As long as our InfoView context is active, we will try and execute the InfoView edit command when the user chooses CTRL+O and the scheme is set to org.eclipse.ui.examples.contributions.scheme. The mapping of M1 to CTRL is described in the extension point description for org.eclipse.ui.bindings.

The contextId indicates what active context this key binding will be active in. More information on defining contexts declaratively and activating them programmatically can be found in Contexts. In this case, this key binding will be active when the org.eclipse.ui.examples.contributions.view.context context is active.

In our InfoView we have code called from the end of createPartControl(Composite):

	private static final String VIEW_CONTEXT_ID = "org.eclipse.ui.examples.contributions.view.context"; //$NON-NLS-1$
	...
	/**
	 * Activate a context that this view uses. It will be tied to this view
	 * activation events and will be removed when the view is disposed.
	 */
	private void activateContext() {
		IContextService contextService = (IContextService) getSite()
				.getService(IContextService.class);
		contextService.activateContext(VIEW_CONTEXT_ID);
	}

As mentioned in org.eclipse.ui.handlers this context will be active only when the InfoView part is active. It will also be deactivated when the InfoView part is disposed.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire