## Example - Template Editor

### Introduction

The Template Editor example demonstrates how to add template support to an editor. The example is based on the PDE example editor project that can be created using the new project wizard. The editor is a simple XML editor; it is only for demonstration purposes.

The code for this example is in the `org.eclipse.ui.examples.javaeditor` plug-in. To explore the code it is recommended to import that plug-in into your workspace.

### Features demonstrated in the template editor

- creating a template context for an editor
- setting up a content assist processor that will propose template completions
- contributing a context type and variable resolvers to an editor via plugin.xml
- contributing templates to a context type via plugin.xml
- adding a preference page for handling templates, both contributed and user-added

### Features not demonstrated

- template formatting

### Running the example Template editor

1. Create a project
2. Create a file with the file extension ".xml" in the newly created project.
3. Close the editor that opened automatically
4. Select the new file in the Navigator and from the context menu select Open With > Template Editor to open the Template example editor .

### Code organization of the template editor example

The example code is organized in three packages:

- `org.eclipse.ui.examples.templateeditor.editors` contains all the editor specific classes. See `XMLConfiguration` to see how the `TemplateCompletionProcessor` is added in the `getContentAssistant` method.
- `org.eclipse.ui.examples.templateeditor.preferences` contains the contributed template preference page.
- `org.eclipse.ui.examples.templateeditor.template` contains the example context type, the completion processor and the variable resolver that is contributed via plugin.xml.