Model

Model define file, class, folder... to select by user. Model type are :

  • xml : model to select is XML file.
  • class : model to select is JAVA class.
  • properties : model to select is properties file.
  • folder : model to select is folder.

Model is required into the case :

Model is composed by model elements which allow to define required files (for the template or dynamic XUL) et oblige the user to select required files.

Attributs of model/file

attribute nameDescriptionRequired ?
typexml: when XML document must be loded.
class: when JAVA class must be loaded.
properties: when properties file must be loded.
folder: when java.io.File folder must be loaded.
Yes
keyKeu used into the template or XUL dynamic.Yes
useIntoOutputtrue if file is used into the template.No
useIntoInputtrue if file is used into the XUL dynamic.No
omitDocumentTypetrue if DTD/Schema XML must be ignored when XML file is loaded (type=xml).No
pathpath of file/folderto use as data modelto avoid selecting the file/folder when it is already the same file/folder (see path section for more informations).No

Type

xml

Model type of xml can use XML file with template engine (Freemarker, XSL,..).

Here a sample with xml type Model used into the template with the key doc :

<models>
  <!-- This component requires selection of XML File which is used into 
       Template context (Output) -->
  <model type="xml" key="doc" useIntoOutput="true" omitDocumentType="true" />
</models>

Here sample of Freemarker template which use this model type of xml putted with doc key :

<#assign classElement = doc["hibernate-mapping"].class />  

<#list classElement.property as item>
        private ${item.@type} ${item.@name};    
</#list>

properties

Model type of properties can use properties file with template engine (Freemarker, XSL,..).

Here a sample with properties type Model used into the template with the key prop :

<models>
  <!-- This component requires selection of properties File which is used into 
       Template context (Output) -->
  <model type="properties" key="prop" useIntoOutput="true" />
</models>

Here sample of Freemarker template which use this model type of properties putted with prop key :

<#assign properties = prop.properties />

<#list properties?keys as key>
  key : ${key} value : ${properties[key]}
</#list>

class

Here a sample with JAVA class type Model used into the template with the key pojo :

<models>
  <!-- This component requires selection of Java class which is used into 
       Template context (Output) -->
  <model type="class" key="pojo" useIntoOutput="true" />
</models>

Here sample of Freemarker template which use this model type of JAVA class putted with pojo key :

<#list pojo.fields as f>
    <property
        name="${f.elementName}"
        type="${f.typeSignature?substring(1)}"
        column="${f.elementName}"
    />
</#list>

folder

You can use model type of folder to use java.io.File object as model. This model type can be used when you want navigate into directory and generate dynamic XUL switch files/directories of folder selected.

Here a sample with folder type Model used into the template with the key dir :

<models>
  <model type="folder" key="dir" useIntoInput="true" />
</models>

Here sample of Freemarker template with syntaxe square bracket which use this model type of folder putted with dir key :

...
[#list dir.listFiles() as f]
  <treeitem checked="true" >
<treerow>
  [#assign isDirectory = f.isDirectory() /]
  [#if isDirectory]
  <treecell label="DIRECTORY : ${f.name}" />
  [#else]
  <treecell label="FILE : ${f.name}" />
  [/#if]
</treerow>
</treeitem>
[/#list]             
...

Path

When xml, properties file,... or folder directory to use into model of XML component is the same whatever the project, it is interesting to fill path attribute. When you fill path, you avoid to select the data model file each time you open XML component.

For instance, into J2EE project, web.xml exist every time and it is often stored into web/WEB-INF directory of the Eclipse project. If you write XML component which require this file as model, it's interesting to fill path like this :

<models>
  ...
  <model type="xml" key="webxml" useIntoOutput="true" omitDocumentType="true" 
         path="project:/web/WEB-INF/web.xml" />
  ...
</models>

You can notice that path start with project:/. It means that root directory is the Eclipse project which is linked to catalogue. project:/ is not required, you can fill path like this :

<models>
  ...
  <model type="xml" key="webxml" useIntoOutput="true" omitDocumentType="true" 
         path="web/WEB-INF/web.xml" />
  ...
</models>

path can start with :

  • project:/ to search file/folder into Eclipse project.
  • catalogue:/ to search file/folder into catalog.
      path="catalogue:/myDataFile.xml"
  • file:/ to search file/folder into your disk.
      path="file:/C:/myDataFile.xml"

    refer myDataFile.xml file stored into C:/ folder.

You van use following patterns :

  • /*/ which means any folder. If there is several files founded, the first file will be used.
  • /**/ which means any sequece folder. If there is several files founded, the first file will be used.

For example, you can fill path like this :

  path="web/*/struts-config.xml"