UMLTemplateSuppliers
There are two types of supplier of code generation templates. The first supplier is a module writer. This supplier is partically important because the standard set of templates will be shipped with the UML modules. Also modules writers like Ruby, and C++ should be able to ship a standard set of code generation templates. The second supplier of code generation templates are users. Since as a tool vendor we will never be able to supply all of the code generation templates for every domain. So, it is very important that a user is able to create new code generation templates and share the templates with other users.
NetBeans already allows module developers to define new templates. Using the layer file a module developer can define a template under the Template folder. Currently a number of modules use the Template folder to define new templates. There are Project Templates, Template services, and New File Templates. The Templates folder can contain sub folders that are used to specify the category that should own the template. The layer file also has ability to be localized. A template file can also have a set of attributes associated with the template. The attributes can be used to describe the properties needed by the code generation mechanism. Example properties are Stereotype, Model Element Name, etc.
Requiring a user to create a new module everytime they want to add a template would be over kill. In NetBeans a user can instead use a context menu to save a file as a template. We should use a similar approach. We should allow the user to create a new template by either a context menu, or via the template manager. Since the UML code generation needs more properties than standard NetBeans templates, we will not be able to use the same context menu as the standard NetBeans templates.
To allow the user to share templates, we can add an export template action to our template manager UI. The template action would have to export the template file, as well as the template properties information into a format that can be easily imported into another NetBeans environment.
Technical Details
The NetBeans Template mechanism will handle most of our use cases. The Layer file can be used to register new templates .The template mechanism already has support for allowing the user to modify a template file. The only problem that remains is how to allow a user to share templates between NetBeans instances, and how to create new templates. Currently I am interested in the technical details of creating a new template file. So, I am not going to talk about the UI issues involved with creating a new template file.
When a new template is created, the template needs to be copied to the template file repositistory. The user must also also specify how values of the template properties. When a template is defined by a module, I believe NetBeans will copy the template file object to the template repository. When the template file is copied the properites should also be copied. Therefore if the user changes a template file property, the UI can update the properties.
Potential Problems
- Make sure NetBeans New File Wizard does not try to use a UML template.

