Changes for page Custom Project Templates
Last modified by Bastian Triller on 2009/04/11 21:03
From version 51.1
edited by David Avendasora
on 2009/04/11 20:52
on 2009/04/11 20:52
Change comment:
There is no comment for this version
To version 54.1
edited by David Avendasora
on 2009/04/07 05:47
on 2009/04/07 05:47
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -46,7 +46,7 @@ 46 46 47 47 For a static template, the simple process above is enough. However, it's a common requirement to have configuration options for project templates. The WOLips project template engine provides an easy way to declare these options. 48 48 49 -After creating a template using the directions in the above section, you can additionally create a file named "template.xml" inside your project template folder. For instance, in the example above, you would create the file ",,/Library/Application Support/WOLips/Project Templates/ MyApplicationTemplate/template.xml".,,49 +After creating a template using the directions in the above section, you can additionally create a file named "template.xml" inside your project template folder. For instance, in the example above, you would create the file ",,/Library/Application Support/WOLips/Project Templates/Wonder Application/template.xml".,, 50 50 51 51 An example template.xml is below: 52 52 ... ... @@ -53,24 +53,16 @@ 53 53 {{code value="xml"}} 54 54 55 55 <?xml version="1.0" encoding="UTF-8"?> 56 - <template name = " MyApplication">56 + <template name = "Wonder Application"> 57 57 <inputs> 58 - <input name = "basePackage" type = "Package"> 59 - <question>Base Package?</question> 60 - <default>your.app</default> 61 - </input> 62 - <input name = "componentsPackage" type = "Package"> 63 - <question>Components Package?</question> 64 - <default>your.app.components</default> 65 - </input> 66 - <input name = "servletDeployment" type = "Boolean"> 67 - <question>Deploy to Servlet Container?</question> 58 + <input name = "linkToWonderProjects" type = "Boolean"> 59 + <question>Link to Wonder Projects?</question> 68 68 <default>false</default> 69 69 </input> 70 - <input name = " webXML" type = "Boolean">71 - <question> Autogenerateweb.xml file?</question>72 - <default> false</default>73 - </input> 62 + <input name = "linkToWonderFrameworks" type = "Boolean"> 63 + <question>Link to Wonder Frameworks?</question> 64 + <default>true</default> 65 + </input> 74 74 <input name = "YourFavoriteColor" type = "String"> 75 75 <question>Your Favorite Color?</question> 76 76 <options> ... ... @@ -85,56 +85,42 @@ 85 85 86 86 {{/code}} 87 87 88 - If you don't seta"name" attributeinthe"template"tag,the name of theTemplate Folderwill be used. InthisexampletheTemplatewillshowup as"MyApplication"inthelist ofavailable templates.If"name"handn'tbeendefined,theit wouldshow up as thefoldername,whichwas"MyApplicationTemplate".80 +The "name" attribute of the template node overrides the name of the folder the templates are in. For instance, you could have the above template.xml inside a folder named "Template 1" and the template system would consider the name of the template to be "Wonder Application." 89 89 90 -Within a template, you can declare a single "inputs" node that can contain multiple "input" nodes. Each input node corresponds to a variable that will be presented to the user on the second page of the wizard. Each input specifies a "name" attribute, which will become the variable name of the input for later reference in the Velocity templates; and a "type" attribute which willdetermine the type of control presented to the user. They are:82 +Within a template, you can declare a single "inputs" node that can contain multiple "input" nodes. Each input node corresponds to a variable that will be presented to the user on the second page of the wizard. Each input specifies a "name" attribute, which will become the variable name of the input for later reference in the Velocity templates; and a "type" attribute which can be one of Boolean, String, Package, or Integer. The type value determines the control that will be used to display the input to the user (String = text field, Boolean = checkbox, Integer = spinner, Package = text field, etc). Each input also contains a "question" node, whose value corresponds to the label of the control when displayed to the user. In the above example, the "linkToWonderFrameworks" will display a checkbox to the user with the label "Link to Wonder Frameworks?". Additionally, you can provide a "default" node that defines the default value of the variable. If a default is not specified, the default value will be null for all input types. 91 91 92 -* Boolean -> Check Box 93 -* String -> Text Field 94 -* Package -> Text Field 95 -* Integer -> Spinner 84 +The package type is slight extension to the String type. For a variable declared as type Package, in addition to having your variable bound, you will also have a variable named "yourvariablename//folder" with replaces dots for slashes. For instance, if your variable is named "basePackage," you will also get a variable named "basePackage//folder." This is useful because you can use template variables in folder names on the filesystem. 96 96 97 -Each input also contains a "question" node, whose value corresponds to the label of the control when displayed to the user. In the above example, the "servletDeployment" will display a checkbox to the user with the label "Deploy to Servlet Container?". Additionally, you can provide a "default" node that defines the default value of the variable. If a default is not specified, the default value will be null for all input types. 98 - 99 -The package type is slight extension to the String type. For a variable declared as type Package, in addition to having your variable bound, you will also have a variable named "yourvariablename//folder" with replaces dots for slashes. For instance, if your variable is named "basePackage" you will also get a variable named "$basePackage//folder". If the user left the default of "your.app" in the basePackage field, then the two variables would be: 100 - 101 -* basePackage = "your.app" 102 -* basePackage//folder = "your/app"// 103 - 104 104 Finally, the input system supports the declaration of enumerated types. By declaring an "options" node that contains an ordered set of "option" nodes, you can define the possible values that the user can provide. In the above example, the "YourFavoriteColor" input defines three options: Red, Green, and Blue. Each option node has a "name" attribute, which will be the value displayed to the user, and a "value" attribute, which will be the actual backing value of the selection. The value of the option should be of the type specified in the "type" attribute of the input. For instance, if you declare the input type to be "Integer," your option values should be integer values (in quotes). 105 105 106 106 = Using Template Inputs = 107 107 108 -So now that you have template input sdefined, you needto be able to use them. The name used in the "name" attribute of your inputnode will be the name of the variableyou can usein yourtemplate'sfiles. For instance, in the example above, the Velocity variable "servletDeployment" will be bound to the boolean value corresponding to the user's selection, and can be used just like any other velocity variable. The Apache project provides a [[Velocity reference guide>>http://velocity.apache.org/engine/devel/vtl-reference-guide.html]].90 +So now that you have template input defined, you will want to be able to use them. The name use used in the "name" attribute of your input declaration will be the name of the variable in your Velocity context. For instance, in the example above, the Velocity variable "linkToWonderProjects" will be bound to the boolean value corresponding to the user's selection, and can be used just like any other velocity variable. The Apache project provides a [[Velocity reference guide>>http://velocity.apache.org/engine/devel/vtl-reference-guide.html]]. 109 109 110 -As an example, the .classpath file can be modifiedto automatically add a linkto theJavaWOJSPServlet.framework iftheuserselects"DeploytoServletContainer"inthethe wizard.92 +As an example, the Wonder Application template's .classpath file is defined as: 111 111 112 112 {{code value="xml"}} 113 113 114 114 <?xml version="1.0" encoding="UTF-8"?> 115 -<classpath> 116 - <classpathentry kind="src" path="Sources"/> 117 - <classpathentry kind="con" path="WOFramework/JavaEOAccess"/> 118 - <classpathentry kind="con" path="WOFramework/JavaEOControl"/> 119 - <classpathentry kind="con" path="WOFramework/JavaFoundation"/> 120 - <classpathentry kind="con" path="WOFramework/JavaJDBCAdaptor"/> 121 - <classpathentry kind="con" path="WOFramework/JavaWebObjects"/> 122 - <classpathentry kind="con" path="WOFramework/JavaXML"/> 123 - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 124 -#if ($servletDeployment) 125 - <classpathentry kind="con" path="WOFramework/JavaWOJSPServlet"/> 126 -#end 127 - <classpathentry kind="output" path="bin"/> 128 -</classpath> 97 + <classpath> 98 + <classpathentry kind="src" path="Sources"/> 99 + #if ($linkToWonderProjects) 100 + <classpathentry combineaccessrules="false" kind="src" path="/ERJars"/> 101 + <classpathentry combineaccessrules="false" kind="src" path="/ERExtensions"/> 102 + <classpathentry combineaccessrules="false" kind="src" path="/ERPrototypes"/> 103 + <classpathentry combineaccessrules="false" kind="src" path="/JavaWOExtensions"/> 104 + #end 105 + #if ($linkToWonderFrameworks) 106 + <classpathentry kind="con" path="org.objectstyle.wolips.WO_CLASSPATH/ERExtensions/ERJars/ERPrototypes/JavaWOExtensions/JavaEOAccess/JavaEOControl/JavaFoundation/JavaJDBCAdaptor/JavaWebObjects/JavaXML"/> 107 + #else 108 + <classpathentry kind="con" path="org.objectstyle.wolips.WO_CLASSPATH/JavaEOAccess/JavaEOControl/JavaFoundation/JavaJDBCAdaptor/JavaWebObjects/JavaXML"/> 109 + #end 110 + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 111 + <classpathentry kind="output" path="bin"/> 112 + </classpath> 129 129 130 130 {{/code}} 131 131 132 -In addition to variables inside of Velocity templates, you can also use template variables in folderand file names. However, because $ is not allowed on some filesystems, we instead surround the variable names with "" (for instance $someVariable would be"someVariable"in the filename or path). As an example, the templateabovehas an input named "basePackage" (of type Package) which,as we learned above,createstwovariables:"basePackage" and "basePackage//folder".Sincewearegoingto beusingthisvariable toname(anddefinethepath)ofafolderinthe Sourcesdirectory, we needto usethe alternateversionofthevariable. Createanew folderin the Sourcesdirectoryof theproject templaetandinsteadof using "${{basePackage_folder}}{{/basePackage_folder}}" asthe file name, we must use "basePackage//folder".116 +In addition to variables inside of Velocity templates, you can also use template inputs in folder names. However, because $ is not allowed on some filesystems, we instead surround the variable names with "//" (for instance $someVariable would be //someVariable in the filename or path). As an example, the Wonder Application template has an input named "basePackage" (of type Package), which creates a magic variable named "basePackage//folder" (where the dots are turned into slashes), and the Source folder on the filesystem is named "Wonder Application/Sources///basePackage//folder//". 133 133 134 -= Special Circumstances = 135 - 136 -===== Flagging files to be skipped by Velocity ===== 137 - 138 -===== Using keypaths ===== 139 - 140 140 Happy templating