Taylor

Customize Code Templates

From Taylor

Templates can be overridden by placing a new version in the directory you specify under Window/Preferences/Taylor. This is useful for overriding the copy right Header template or for fixing template bugs. The templates are found in plug-ins such as net.taylor.mda.ejb3gen.

I typically do the following:

  1. Create a templates folder next to the model folder.
  2. Set the preferences to point to this folder.
  3. Create a Header.jetinc file in this folder.
  4. Check in the custom template so everyone else has access.
  5. As the project progresses we will put additional customized templates here as well. NOTE: The path has to match the path specified in the particular plugin.xml file so that the engine finds them.


Custom Plugins

Additional templates can be added by placing them in your own plugin and adding the following extension point to its plugin.xml.

				
   <extension  
         point="net.taylor.mda.generator.templates">
      <template 
             id="Enum"
             path="/main/java/entity/Enumeration.javajet"
             templateClassName="net.taylor.mda.generator.template.main.java.entity.Enum"
             outputPattern="/src/main/java/{0}/{1}.java"
             ifExists="merge"
             modelElement="org.eclipse.uml2.uml.internal.impl.EnumerationImpl">
      </template> 
   </extension>

Additional information can be found under Architecture and Writing Custom Generators.

A good JET Template Editor can be found at http://www.eclipse.org/emft/projects/jeteditor/. This is included in the Taylor distribution.