Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c566af278f9243c14ee00a6ac38746cab930a229 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html lang="en">
<HEAD>

<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. 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 behaviour by <b>id</b>.
Commands are used to declare semantic behaviour so that action implementations defined
elsewhere by handlers. The separation of the command from the behaviour
implementation allows multiple plug-ins to define implementations that implement the
same semantic command. 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 implementations with these
commands where it makes sense. In this way, semantically similar
behaviour 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. The following comes from the Info example markup:</p>


<pre>
&lt;extension
	point=&quot;org.eclipse.ui.commands&quot;&gt;
	...
      &lt;command
            categoryId=&quot;org.eclipse.ui.examples.contributions.commands.category&quot;
            id=&quot;org.eclipse.ui.examples.contributions.view.count&quot;
            description=&quot;%contributions.view.count.desc&quot;
            name=&quot;%contributions.view.count.name&quot;&gt;
      &lt;/command&gt;
	...
</pre>


<p>The command definition specifies a <b>name</b>, <b>description</b>, and <b>id</b> for
the behaviour. 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;%contributions.commands.category.name&quot;
            description=&quot;%contributions.commands.category.desc&quot;
            id=&quot;org.eclipse.ui.examples.contributions.commands.category&quot;&gt;
      &lt;/category&gt;
      ...
</pre>

<p>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
<a href="workbench_cmd_handlers.htm" 
class="XRef">org.eclipse.ui.handlers</a> section.  We'll talk about
binding key sequences to commands in the <a href="workbench_cmd_bindings.htm" 
class="XRef">org.eclipse.ui.bindings</a> section.
</p>



</BODY>
</HTML>

Back to the top