blob: a11dbad1be6ec107e8b3623a0d9d87af97ef338d [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE>
Commands
</TITLE>
<link rel="stylesheet" type="text/css" HREF="../book.css">
</HEAD>
<BODY BGCOLOR="#ffffff">
<h3>Commands</h3>
<p>A <b>command</b> is the declaration of a user action by <b>id</b>.&nbsp;
Commands are used to declare semantic actions so that action implementations defined
in action sets and editors can associate themselves with a particular semantic
command.&nbsp; The separation of the command from the action
implementation allows multiple plug-ins to define actions that implement the
same semantic command.&nbsp; The command is what gets associated with a
particular key binding.</p>
<p>The workbench defines many common commands in its <b>plugin.xml</b>
file, and plug-ins are encouraged to associate their own actions with these
commands where it makes sense.&nbsp; In this way, semantically similar
actions implemented in different plug-ins may share the same key binding.</p>
<h4>Defining a command</h4>
<p>Commands are defined using the <b><a href="../reference/extension-points/org_eclipse_ui_commands.html">org.eclipse.ui.commands</a></b>
extension point.&nbsp; The following comes from the workbench markup:</p>
<pre>
&lt;extension
point=&quot;org.eclipse.ui.commands&quot;&gt;
...
&lt;command
name="%command.save.name"
description="%command.save.description"
categoryId="org.eclipse.ui.category.file"
id="org.eclipse.ui.file.save"&gt;
&lt;/command&gt;
...
</pre>
<p>The command definition specifies a <b>name</b>, <b>description</b>, and <b>id</b> for
the action.&nbsp;&nbsp; It also specifies the id of a category for the command, which is
used to group commands in the preferences dialog.&nbsp; The categories are also
defined in the <b><a href="../reference/extension-points/org_eclipse_ui_commands.html">org.eclipse.ui.commands</a>
</b>
extension point:</p>
<pre>
...
&lt;category
name=&quot;%category.file.name&quot;
description=&quot;%category.file.description&quot;
id=&quot;org.eclipse.ui.category.file&quot;&gt;
&lt;/category&gt;
...
</pre><p>Note that there is no implementation specified for a
command.&nbsp; A command only becomes concrete when a plug-in
associates its action with the command id.</p>
</BODY>
</HTML>