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

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

Commands

A command is the declaration of a behaviour by id. Commands are used to declare semantic behaviour so that action implementations defined elsewhere by handlers, or linked to the action extension points (see Basic workbench extension points using actions) can associate themselves with a particular semantic command. The separation of the command from the action implementation allows multiple plug-ins to define actions that implement the same semantic command. The command is what gets associated with a particular key binding.

The workbench defines many common commands in its plugin.xml file, and plug-ins are encouraged to associate their own actions with these commands where it makes sense. In this way, semantically similar actions implemented in different plug-ins may share the same key binding.

Defining a command

Commands are defined using the org.eclipse.ui.commands extension point. The following comes from the Info example markup:

<extension
	point="org.eclipse.ui.commands">
	...
      <command
            categoryId="org.eclipse.ui.examples.contributions.commands.category"
            id="org.eclipse.ui.examples.contributions.view.count"
            description="%contributions.view.count.desc"
            name="%contributions.view.count.name">
      </command>
	...

The command definition specifies a name, description, and id for the action. It also specifies the id of a category for the command, which is used to group commands in the preferences dialog.  The categories are also defined in the org.eclipse.ui.commands extension point:

      ...
      <category
            name="%contributions.commands.category.name"
            description="%contributions.commands.category.desc"
            id="org.eclipse.ui.examples.contributions.commands.category">
      </category>
      ...

Note that there is no implementation specified for a command. A command only becomes concrete when a plug-in associates its handler or action with the command id. We'll talk about the different ways to associate handler implementations with commands in the org.eclipse.ui.handlers section. We'll talk about binding key sequences to commands in the org.eclipse.ui.bindings section.


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