Template Editor
Common template properties:
- Name - template name which is displayed in the templates list.
- Description - description text.
- Directory name - name of a directory where the template will be stored. All custom templates are located under the
studio-templates
directory of the project.
- Platform version range - an optional property that allows you to specify a range of platform versions for which the template is applicable for. If the field is empty, the template will be shown in any project. A range must be specified by two values separated by "-". A value must be a full version number containing three numbers, or the word "unbounded". Examples of ranges:
6.4.2-6.4.5
, 6.4.0-unbounded
.
In the Properties list you can create properties that will be entered by users and passed to the template. A property can have the following parameters:
- Code - property code for use in the template scripts.
- Caption - property caption that is displayed to the user.
- Required - if selected, the property will be required to enter.
- Advanced - if selected, the property will be displayed in the Advanced section.
- Property type - the property type that affects what field will be presented to the user. It can be one of the following:
- Entity - a drop-down list with existing entities. An object with the following properties will be passed to the scripts:
packageName: String
className: String
name: String
uncapitalizedClassName: String
fqn: String
genericIdType: String ("UUID", "String", "Integer", "Long", "IdProxy", "Embedded")
- View - a drop-down list with views of a related entity. The entity should be selected in the Related property parameter. An object with the following properties will be passed to the scripts:
name: String
allProperties: List<Property>
Each property contains:
name: String
view: View
entity: Entity
isClass: boolean
getSubProperty(String: propertyName): Property
- String - a text field. A value passed to the scripts will be of type
java.lang.String
.
- Boolean - a checkbox. A value passed to the scripts will be of type
java.lang.Boolean
.
- Integer - a text field. A value passed to the scripts will be of type
java.lang.Integer
.
- Option - a drop-down list of options. A value passed to the scripts will be of type
java.lang.String
.
- Multi option - a set of checkboxes. A default value can be set as a comma-separated list. A value passed to the scripts will be of type
Collection<String>
.
- Px size - a text field with an additional validator. A value passed to the scripts will be of type
java.lang.String
.
- Table type - a drop-down list with the following values:
table
, groupTable
, treeTable
. If treeTable
is selected, an additional Hierarchical property field will be shown. An entity should be selected in the Related property parameter. An object with the following properties will be passed to the scripts:
xmlName : String
- table XML element name
dsName : String
- datasource XML element name
- Screen - a drop-down list with existing screens. An object with the following properties will be passed to the scripts:
id : String
agent : String
reference : String
ancestorScreen : Screen
ancestorRef: Screen
controllerClassName : String
controllerFqn: String
- Agent type - a drop-down list with three options: PHONE, TABLET, DESKTOP. The created screen will be registered for the specified agent.
- Menu item - a drop-down list with existing menu items. The created screen will be registered in the menu under the specified item.
A template contains a set of source items. Source items are generated by Groovy SimpleTemplateEngine scripts. The following common properties will be passed to the scripts along with custom properties specified for the template:
xmlNamespace_window
- xmlns attribute value for screen XML
copyright: String
classComment: String
api
- a api object with the following methods:
The descriptor script runs first and can define shared variables that can be used in other scripts. For example:
<% sharedVar = 'some value' %>