Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: aac4b0215731adcfd7056bcf64995cd9b7a0e9ab (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>How to register a template with Eclipse in How to extend the user interface using templates</title>
<link href="_stock/sysdoc.css" type="text/css" rel="stylesheet" media="screen">
<link href="_stock/sysdoc.css" type="text/css" rel="stylesheet" media="print">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <style type="text/css" media="screen">
	   .ButtonBox { background-image: url(_stock/gradient.jpg); }
   </style>
   </head>
   <body>
   <table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr>
   </tr><tr><td class="DocSetBox" width="25%">
   <p>&nbsp;</p>
   </td>
   <td class="ButtonBox" align="right" width="40%">
	   <p> <A href="Howtodeveloptemplates.html"><IMG height=22 alt=[Previous] src="_stock/btn_prev_wt.gif" width=85 border=0 ></A> <A href="exampletemplate.html"><IMG height=22 alt=[Next] src="_stock/btn_next_wt.gif" width=58 border=0 ></A></p>
   </td>
   </tr></tbody></table>
   <hr noshade size="1">
   <p class="breadcrumbNav"><span class="separator">&#187;</span>
   <A href="index.html">How&nbsp;to&nbsp;extend&nbsp;the&nbsp;user&nbsp;interface&nbsp;using&nbsp;templates</A>&nbsp;<span class="separator">&#187;</span> 
How&nbsp;to&nbsp;register&nbsp;a&nbsp;template&nbsp;with&nbsp;Eclipse</p>

   <hr noshade size="1">
   <div class="AuthoredContent">
    

</div><div class="Head1">

<h1>How to register a project template with CDT</h1>
</div><div class="Bodytext">
<p>
Once the project template is ready, you need to register it with Eclipse
to make the template available for use. It is a good practice to group all the
files and resources related to the project template together in one folder. For
example, if you are writing a project template for a Hello World Application,
group all the resources required for this application in a folder
"HelloWorld". 
</p>
<p>
To register a project template with CDT follow the steps given below:
</p>
<ol>
<li>
<p>
Create an empty plug-in project from the Eclipse workbench without
the source folders. 
</p>
<li>
<p>
Create a new folder to contain the template project's content e.g. "MyExampleProject/templates/MyExampleTemplate".
Copy the project template.xml along with all the resources required to create the project. For example, all the
header files, source files, resource files etc. 
</p>
<li>
<p>
Open the plug-in manifest editor and select the
<code class="ProgramOutput">Dependencies</code> page. For more information on plug-in manifest
editor, refer to <i>PDE 
  Guide &gt; Getting Started  &gt; Basic  Plug-in Tutorial
&gt;  Plug-in manifest editor</i>. 
</p>
<li>
<p>
Click <code>Add</code> to select
<code class="filename">org.eclipse.cdt.core</code> and
<code class="filename">org.eclipse.cdt.ui</code>
plug-ins from the list.
</p>
<li>
<p>
Select the <code>Extensions</code> page in the plug-in manifest
editor. 
</p>
<li>
<p>
Click <code>Add</code> to create an extension to the extension-point.
</p>
<li>
<p>
Select the extension-point with ID
<code class="filename">org.eclipse.cdt.core.templates</code> from the list of
extension-points.
</p>
<li>
<p>
Right-click on the newly added extension, and select
<code class="ProgramOutput">New</code> &gt;  
<code class="ProgramOutput">template</code> from the context menu.
The first one has already been added for you, <code class="ProgramOutput">"(template)"</code>.
</p>
<li>
<p>
Select the new template added in the previous step from the <code class="ProgramOutput">All
Extensions</code> list.  Its name is initially <code class="ProgramOutput">"(template)"</code>.
</p>
<li>
<p>
Specify the <code class="ProgramOutput">id</code> attribute of this template contribution, for example
"<em>com.foobar.templates.contrib.MyTemplate1</em>". This attribute is mandatory. The id need not be
the same as the template id (from template.xml). This allows contributing the same template.xml multiple
times. It will replace <code class="ProgramOutput">"(template)"</code> in the list.
</p>
<li>
<p>
Specify the location of the template XML file, relative to the plug-in created
in step 1. This attribute is mandatory.
</p>
<li>
<p>
Specify a <code class="ProgramOutput">filterPattern</code> to indicate the build 
Configurations for which the template is created. It is a regular expression used 
to filter the build Configurations. If the template is designed for a particular 
Configuration, it is recommended to specify the filter pattern. For example, If 
the template is designed for GCC Configurations, the filter pattern can be ".*gcc".
 If the template is designed for multiple build Configurations, you can specify 
 the filter patterns delimited by "|" .
</p>
<p>
The New Project wizard filters the available build Configurations based on the filter
pattern for the selected template. The filter patterns are matched against the
available Configurations' ID to get a list of matching SDKs. This is an optional
attribute. 
</p>
<p>
For more information on regular expression patterns, refer to Java
API document for
<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html">java.util.regex.Pattern</a>.
</p>
<li>
<p>
Specify the project type you wish the template to be associated with. The project type id can be
found by looking at the project types contributed to the  buildDefinitions extension point.
For more information about project types, see <a href="../cdt_build_system/whats_new/4.0/whats_new_CBS_40.html#_TocSectionUIModel_2">
New project information in the What's New in CDT Build section</a>, especially the section "What are the general project type entries?".
<code class="ProgramOutput">projectType</code> drop-down list. This is an mandatory attribute.
</p>
<li>
<p>
Specify the <code class="ProgramOutput">pagesAfterTemplateSelectionProvider</code>,
which is a fully qualified name of the class that implements
<code class="filename">org.eclipse.cdt.ui.templateengine.IPagesAfterTemplateSelectionProvider</code>
interface. This is an optional attribute. 
</p>
</li>
</ol>
<p>
After creating the plug-ins and registering the templates, launch a
runtime workbench and invoke the New Project wizard to check that the template
you added is listed.
</p>
<a name="1.7"></a>
</div><div class="Head2">
<hr size="2" noshade>
<h2>See also:</h2>
</div><div class="Bodytext">
<ul>
<li>
<p>
<A href="Howtodeveloptemplates.html#howto%2edevelop%2etemplates">How to develop templates</A>
</p>
<li>
<p>
<A href="exampletemplate.html#Corona%2ecustomguide%2eexampletemplate">Example template</A>
</p>
</li>
</ul>

   </div><div class="Footer">
   <hr noshade size="1">
   <table cellpadding="0" cellspacing="0" border="0" width="100%">
     <tr>
       <td class="ButtonBottomBox" align="right" height="12" width="67%">
         <p>
	 <A href="Howtodeveloptemplates.html"><IMG height=22 alt=[Previous] src="_stock/btn_prev.gif" width=85 border=0></A>
	 <A href="#_top"><IMG alt=[Top] src="_stock/btn_top.gif" align=bottom border=0></A>
	 <A href="exampletemplate.html"><IMG height=22 alt=[Next] src="_stock/btn_next.gif" width=58 border=0 ></A>
         </p>
       </td>
     </tr>
   </table>
   </div>
   </body>
   </html>
   

Back to the top