| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <title> |
| Templates |
| </title> |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| </head> |
| <body> |
| <h1> |
| Templates |
| </h1> |
| <p> |
| The Templates preference page allows to create new and edit existing templates. A template is a convenience for the programmer to quickly insert often reoccurring source |
| code patterns. |
| </p> |
| <p> |
| The following buttons allow manipulation and configuration of templates: |
| </p> |
| <table border="1" cellspacing="0" cellpadding="5" width="100%"> |
| <thead> |
| <tr> |
| <th> |
| <p> |
| Action |
| </p> |
| </th> |
| <th> |
| <p> |
| Description |
| </p> |
| </th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>New...</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Opens a dialog to create a new template. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Edit...</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Opens a dialog to edit the currently selected template. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Remove</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Removes all selected templates. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Import...</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Imports templates from the file system. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Export...</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Exports all selected templates to the file system. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Export All...</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Exports all templates to the file system. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Enable All</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Enables all templates. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Disable All</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Disables all templates. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Use Code Formatter</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| If enabled, the template is formatted according to the code formatting rules specified in the <strong>Code Formatter</strong> preferences, prior to insertion. |
| Otherwise, the template is inserted as is, but correctly indented. |
| </p> |
| <p> |
| <a href="ref-17.htm">See Code Formatter preference page</a> |
| </p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <h2> |
| Template dialog |
| </h2> |
| <p> |
| Creating a new template and editing an existing template uses the same dialog, which is described here. |
| </p> |
| <p> |
| The following fields and buttons appear in the dialog: |
| </p> |
| <table border="1" cellspacing="0" cellpadding="5" width="100%"> |
| <thead> |
| <tr> |
| <th> |
| <p> |
| Option |
| </p> |
| </th> |
| <th> |
| <p> |
| Description |
| </p> |
| </th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Name</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| The name of the template. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Context</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| The context determines where the template can be used and the set of available pre-defined template variables. |
| </p> |
| <dl> |
| <dt> |
| Java |
| </dt> |
| <dd> |
| The Java context |
| </dd> |
| <dt> |
| Javadoc |
| </dt> |
| <dd> |
| The Javadoc context |
| </dd> |
| </dl> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Description</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| A description of the template, which is displayed to the user when choosing the template. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Pattern</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| The template pattern. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>Insert Variables...</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Displays a list of pre-defined context specific variables. |
| </p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <h2> |
| Template variables |
| </h2> |
| <p> |
| Both Java and Javadoc context define the following variables: |
| </p> |
| <table border="1" cellspacing="0" cellpadding="5" width="100%"> |
| <thead> |
| <tr> |
| <th> |
| <p> |
| Variable |
| </p> |
| </th> |
| <th> |
| <p> |
| Description |
| </p> |
| </th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${cursor}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Specifies the cursor position when the template edit mode is left. This is useful when the cursor should jump to another place than to the end of the template on |
| leaving template edit mode. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${date}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the current date. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${dollar}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the dollar symbol '$'. |
| </p> |
| <p> |
| Alternatively, two dollars can be used: '$$'. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${enclosing_method}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the name of the enclosing name. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${enclosing_method_arguments}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to a comma separated list of argument names of the enclosing method. This variable can be useful when generating log statements for many methods. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${enclosing_package}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the name of the enclosing package. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${enclosing_project}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the name of the enclosing project. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${enclosing_type}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the name of the enclosing type. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${file}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the name of the file. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${return_type}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the return type of the enclosing method. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${time}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the current time. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${user}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to the user name. |
| </p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <p> |
| The Java context additionally defines the following variables: |
| </p> |
| <table border="1" cellspacing="0" cellpadding="5" width="100%"> |
| <thead> |
| <tr> |
| <th> |
| <p> |
| Variable |
| </p> |
| </th> |
| <th> |
| <p> |
| Description |
| </p> |
| </th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${array}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to a proposal for a declared array name. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${array_element}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to a proposal for an element name of a declared array. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${array_type}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to a proposal for the element type of a declared array. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${collection}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to a proposal for a declared collection implementing <code>java.util.Collection</code>. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${index}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to a proposal for an undeclared array index iterator. |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"> |
| <p> |
| <strong>${iterator}</strong> |
| </p> |
| </td> |
| <td valign="top"> |
| <p> |
| Evaluates to a proposal for an undeclared collection iterator. |
| </p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <p> |
| <img src="../images/ngrelc.gif" alt="Related concepts" border="0" height="27" width="159"><br> |
| <a href="../concepts/ctemplates.htm">Templates</a><br> |
| </p> |
| <p> |
| <img src="../images/ngrelt.gif" alt="Related tasks" border="0" height="27" width="159"><br> |
| <a href="../tasks/tasks-171.htm">Using templates</a><br> |
| <a href="../tasks/tasks-203.htm">Writing your own templates</a><br> |
| </p> |
| <p> |
| <img border="0" width="159" height="27" src="../images/ngrelr.gif" alt="Related reference"><br> |
| <a href="../reference/ref-143.htm">Java Content Assist</a> |
| </p> |
| <p> |
| <a href="../hglegal2003.htm"></a><a href="../hglegal2003.htm"><img src="../images/ngibmcpy2003.gif" alt="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved." border="0" |
| width="324" height="14"></a> |
| </p> |
| </body> |
| </html> |
| |