Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Plug-in Developer Guide
Previous Page Home Next Page

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.

 

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire