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

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


Eclipse Platform
Release 3.5

Package org.eclipse.jface.text.templates

Application programming interfaces for interaction with the Eclipse text template support.

See:
           Description

Class Summary
ContextTypeRegistry A registry for context types.
DocumentTemplateContext Instances of this class describe the context of a template as a region of a document.
GlobalTemplateVariables Global variables which are available in any context.
GlobalTemplateVariables.Cursor The cursor variable determines the cursor placement after template edition.
GlobalTemplateVariables.Date The date variable evaluates to the current date.
GlobalTemplateVariables.Dollar The dollar variable inserts an escaped dollar symbol.
GlobalTemplateVariables.LineSelection The line selection variable determines templates that work on selected lines.
GlobalTemplateVariables.Time The time variable evaluates to the current time.
GlobalTemplateVariables.User The user variable evaluates to the current user.
GlobalTemplateVariables.WordSelection The word selection variable determines templates that work on a full lines selection.
GlobalTemplateVariables.Year The year variable evaluates to the current year.
SimpleTemplateVariableResolver A simple template variable resolver, which always evaluates to a defined string.
Template A template consisting of a name and a pattern.
TemplateBuffer A template buffer is a container for a string and variables.
TemplateCompletionProcessor A completion processor that computes template proposals.
TemplateContext Provides the context for a Template being resolved.
TemplateContextType A context type defines a context within which templates are resolved.
TemplateProposal A template completion proposal.
TemplateTranslator The template translator translates a string into a template buffer.
TemplateVariable A TemplateVariable represents a set of positions into a TemplateBuffer with identical content each.
TemplateVariableResolver A TemplateVariableResolver resolves TemplateVariables of a certain type inside a TemplateContext.
TemplateVariableType Value object that represents the type of a template variable.
 

Exception Summary
TemplateException Thrown when a template cannot be validated.
 

Package org.eclipse.jface.text.templates Description

Application programming interfaces for interaction with the Eclipse text template support.

Templates

Packages

  • org.eclipse.jface.text.templates
  • org.eclipse.ui.workbench.texteditor.templates
  • org.eclipse.ui.editors.templates

Introduction

Templates are shortcuts for frequently used fragments of text such as code patterns or complex text entities. They may contain variables which are only resolved at the time when the template is inserted within a context. Together with linked mode, inserting a template can create a on-the-fly edit mask within a text viewer.

Templates are specified as text, variables are defined using the ${variable} notation known from Ant, for example. The following snippet shows an example template for an instance check in Java:
if (${name} instanceof ${type}) {
    ${type} ${new_name} = (${type})${name};
    ${cursor}
}
In this template, the variables (name,type, ...) are resolved when inserted into java source and changing one variable instance will also change the other. When leaving linked mode, the caret is placed at the cursor variable.

Template functionality can be added to a custom text editor by offering TemplateProposals as content assist choices, which is simplified by using a subclass of TemplateCompletionProcessor. User template management can be offered by including a TemplatePreferencePage which uses a TemplateStore and ContextTypeRegistry as the underlying model to store templates. The org.eclipse.ui.editors.templates extension point can be used to allow other plug-ins to contribute templates to an editor. This is accomplished by using the ContributionTemplateStore and ContributionContextTypeRegistry subclasses of the above types.

Template variables are resolved by a TemplateVariableResolver. GlobalTemplateVariables offers some default variables such as date, user, and selection, but advanced features such as resolving to language constructs can be performed in subclasses.

Classes

  • Template a template consists of name, context type identifier, and a pattern.
  • TemplateTranslator and TemplateBuffer are used to parse the template grammar and don't need to be used usually.
  • A TemplateProposal can be offered in content assist, possibly created by a subclass of TemplateCompletionProcessor.
  • TemplateStore and ContextTypeRegistry manage a set of templates within a plug-in and offer ways to store them in the preferences or externally in XML streams via a TemplateReaderWriter.
  • ContributionTemplateStore and ContributionContextTypeRegistry add awareness for the org.eclipse.ui.editors.templates extension point.
  • TemplatePreferencePage allows the user to access the templates within a TemplateStore.

Example

See the Template Editor Example in the org.eclipse.ui.examples.javaeditor project.


Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


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