Editor Template

Identifier:
org.eclipse.ui.editors.templates

Since:
3.0

Description:
Templates are snippets of text or code which help the user enter reoccurring patterns into a text editor. Templates may contain variables which are resolved in the context where the template is inserted.

Configuration Markup:

<!ELEMENT extension (template* , resolver* , contextType* , include* , contextTypeRegistry*)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED

>


<!ELEMENT contextType EMPTY>

<!ATTLIST contextType

id         CDATA #REQUIRED

class      CDATA #REQUIRED

name       CDATA #IMPLIED

registryId IDREF #IMPLIED

>

A context type defines a context within which templates are evaluated. A context type uses its resolvers to resolve a template.



<!ELEMENT resolver EMPTY>

<!ATTLIST resolver

contextTypeId IDREF #REQUIRED

type          CDATA #REQUIRED

class         CDATA #REQUIRED

description   CDATA #IMPLIED

name          CDATA #IMPLIED

icon          CDATA #IMPLIED

>

A template variable resolver can resolve a template variable in a certain context.



<!ELEMENT template (pattern)>

<!ATTLIST template

id            CDATA #REQUIRED

contextTypeId IDREF #REQUIRED

name          CDATA #REQUIRED

description   CDATA #IMPLIED

icon          CDATA #IMPLIED

autoinsert    (true | false) "true"

>

A template is a snippet of code or text that will be evaluated in a given context. Variables which will be resolved in that context can be specified using the ${variable_type} notation.



<!ELEMENT pattern (#PCDATA)>

The template pattern.



<!ELEMENT include EMPTY>

<!ATTLIST include

file         CDATA #REQUIRED

translations CDATA #IMPLIED

>

A collection of templates encoded as XML can be included as a whole via this element.



<!ELEMENT contextTypeRegistry EMPTY>

<!ATTLIST contextTypeRegistry

id CDATA #IMPLIED

>

Defines a registry for context types. Context types which define a 'registryId' are automatically added to the registry which is created by new org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry(registryId). Since 3.5.



Examples:

   <extension
         point="org.eclipse.ui.editors.templates">
      <template
         name="%ant.tasks.javac.name"
         contextTypeId="org.eclipse.ui.examples.templateeditor.antcontext"
         id="org.eclipse.ui.examples.templateeditor.templates.javac"
         description="%ant.tasks.javac.description">
          <pattern>
             <javac srcdir="${src}"
               destdir="${dst}"
               classpath="${classpath}"
               debug="${debug}"/>
          </pattern>
      </template>
      
      <resolver
         contextTypeId="org.eclipse.ui.examples.templateeditor.antcontext"
         type="src"
         class="org.eclipse.ui.examples.templateeditor.editors.AntVariableResolver">
      </resolver>
      
      <resolver
         contextTypeId="org.eclipse.ui.examples.templateeditor.antcontext"
         type="dst"
         class="org.eclipse.ui.examples.templateeditor.editors.AntVariableResolver">
      </resolver>
   </extension>

API Information:
See the org.eclipse.jface.text.templates package in the org.eclipse.text plug-in for the relevant API.

Supplied Implementation:
See the org.eclipse.jface.text.templates package in the org.eclipse.text plug-in for the relevant classes.


Copyright (c) 2001, 2010 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html