[Previous] [Next]



How to develop templates

Templates form an important part of the drive to support automatic GUI generation of various user interface types as supported in Eclipse frame work. These templates are often referred as project templates, as they are used to support the creation of ready-made projects. For example, you can define a template to create a simple GUI based EXE application for a set of Build Configurations.

The project templates are simple XML files, which follow a structure or schema defined in the TemplateDescriptorSchema.xsd file. These templates define the inputs and processes required to create a project for a particular platform. Inputs define the type of inputs required such as, files, settings etc. The processes define what to do with those inputs to create a particular type of project.

The New Project wizard lists all the templates available based on the matching criteria defined by the templates. Once the user selects a template from the list, the Template Engine plug-in processes the selected template. The plug-in generates the subsequent wizard pages based on whether the template needs user input or not.

This document details the schema for writing project templates. The schema file TemplateDescriptorSchema.xsd, which defines the structure for the project templates, is part of org.eclipse.cdt.core plug-in.

The structure or schema for a project template is as follows:

<template
type="TemplateType"
version="Version"
supplier="Supplier"
revision="Revision"
author="Author"   
id="TemplateId"
label="Template label visible to the user"
description="A brief description of the template"
preview-icon="icon.gif">

<property-group
id="properyGroupId"
label="Property group label"
description="A simple description of the property group"
type=" Type of UIElement group"
branding-icon="icon.gif">
...
</property-group>

<process>
...
</process>

</template>

The root element for a project template is template, which provides the following properties or attributes to describe the template:

The template element includes the following child elements:

property-group

As mentioned earlier, a property-group includes the property elements that specify all the input fields required for a wizard page. A property-group can include any number of property elements. The following attributes can be used to describe a property group:

property

The syntax for the property elements included by the property-group element is as follows:

<property
id="propertyId"
label="User visible label of the property"
description="A brief description of the property"
type="type of the property"
pattern="Regular expression of the expected property"
default="Default value of the property"
size="size"
mandatory="true|false"
hidden="true|false"
persist="true|false">

     <item
     value="value of the item"
     label="User visible label of the item"
     ...
     </item>
</property>

Here is a list of attributes of the property element:

If the property type is select or stringlist, you can include the item element to specify the items to be listed. There is no limitation on the number of items that can be listed. Here is the syntax for the item element:

<item
value="value of the item"
label="User visible label of the item"
</item>

Here is a list of attributes of the item element:

process

The process element within the root element of a project template defines the processes to be followed to create a project, based on the inputs taken. Here is the syntax for this element:

<process type="org.eclipse.cdt.{core|managedbuilder.core}.<process type>">
    <simple name="name" value=""/>

    <complex name="name">
        ...
    </complex>

    <simple-array name="values">
        ...
    </simple-array>

    <complex-array name="name">
        ...
    </complex-array>

</process>

A process element defines a single process. A process is like a procedure with a set of parameters. In similar terms, the process element defines the procedure. You need to specify all the parameters expected by a process. In the project template, you need to specify arguments for the process matching their types and in the order specified.

You can specify the process type using the type attribute. For example, to add files to a project you can use org.eclipse.cdt.core.AddFiles as the process type.

A process element may include the following child elements:

Process types

A process type is a prototype of a process procedure. It defines the parameters required to complete a procedure. For example, to copy a file you need its source and destination information, which can be defined as parameters for the copy process.

The Template Engine plug-in provides a set of process types using the extension-point org.eclipse.cdt.core.templateProcessTypes. Using these process types you can describe a process in your template. For example, you can describe the copy process by providing the source and destination folder names.

The following is a list of process types provided by the Template Engine:

  • org.eclipse.cdt.managedbuilder.core.NewManagedProject: It defines all the parameters required for a new managed project and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.core.Copy: It defines all the parameters required to copy files and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.core.Append: It defines all the parameters required to append files to a project and provides the fully qualified name of the class, which processes these parameters. For more information about the parameters, refer to the Copy process type described above.

  • org.eclipse.cdt.core.AddFile: It defines all the parameters required to add a file to the project and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.core.AddFiles: It defines all the parameters required to add files to a project and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.core.CreateSourceFolder: It defines all the parameters required to create a folder for the source files in a project and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.core.AddLink: It defines all the parameters required to create a linked file and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.managedbuilder.core.CreateIncludeFolder: It defines all the parameters required to create a folder for the header files in a project and provides the fully qualified name of the class, which processes these parameters. For information about the parameters, refer to the CreateSourceFolder process type described above.

  • org.eclipse.cdt.managedbuilder.core.ExcludeResources: It defines all the parameters required to exclude resources from a CDT project and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue: It defines all the parameters required to create a string option value and provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.managedbuilder.core.SetMBSStringListOptionValues: It defines all the parameters required to create a string list of option values and provides the fully qualified name of the class, which processes these parameters. The parameters required are similar to that of SetMBSStringOptionValue process type, only difference is that each resource path will have a list of option values. For information about the parameters, refer to the SetMBSStringOptionValue process type described above.

  • org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue: It defines all the parameters required to create a boolean option value and provides the fully qualified name of the class, which processes these parameters. The parameters required are similar to that of SetMBSStringOptionValue process type, only difference is that this process type is used to create boolean option value. For information about the parameters, refer to the SetMBSStringOptionValue process type described above.

  • org.eclipse.cdt.managedbuilder.core.AppendToMBSStringOptionValue: It defines all the parameters required to append a string option value to an existing string option. It also provides the fully qualified name of the class, which processes these parameters. For information about the parameters, refer to the SetMBSStringOptionValue process type described above.

  • org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues: It defines all the parameters required to append a string list of option values to an existing string list of option value. It also provides the fully qualified name of the class, which processes these parameters. For information about the parameters, refer to the SetMBSStringListOptionValues process type described above.

  • org.eclipse.cdt.core.AppendCreate: It defines all the parameters required to append or create a file in a project. It also provides the fully qualified name of the class, which processes these parameters. For information about the parameters, refer to the AddFiles process type described above.

  • org.eclipse.cdt.core.CreateResourceIdentifier: It defines all the parameters required to append or create a resource identifier. It also provides the fully qualified name of the class, which processes these parameters.

    Here is a list of parameters defined by this process type:

  • org.eclipse.cdt.managedbuilder.core.GenerateMakefileWithBuildDescription:


    Once the project template has been written, register it with Eclipse to make it available for use. For more information on this, refer to How to register a template with Eclipse.


  • See also: