cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

ProjectCodeGenerationTemplatesConfiguration

UML Project Code Generation Templates Configuration

Folder Location Field

The folder location field instructs the generate code process where to put the generated source files. This is typically the [[[src | [src]]] folder of a Java project, but could be any existing folder or even a folder that does not yet exist which will be created by the generate code process, assuming the folder is valid.

The default value of folder location field depends on the UML project's state of Java project association. If the UML project was created by reverse engineering a Java project, then the default folder location will be the first source root folder of that Java project (e.g. <java_project_folder>/src). If the UML project was created as a Java-Platform Model or Platform-Independent Model project, then the default will be the home directory of the current user of the local system with a derived folder name appended (for Windows, e.g. My Documents\<uml_project_name>_Sources\src). This derived folder obviously does not yet exist and so clicking the Browse button will take you to the first existing parent folder of the derived folder path. If you manually change the folder location, that location will be the new default for the generate code process.

Backup Existing Sources Option

When the generate code process creates new sources, you have the option to make backups of all existing sources that are affected. The backed sources will have a number appended to the end of the file extension. For example, Foo.java would be backed up with the name Foo.java1. The next time it is backed up, another file will be created named Foo.java2, assuming Foo.java1 already exists. Disabling this option will simply prevent backups from being created, but only changes to the sources are merged into the current source file.

Generate Markers for Source File Merging

When Java sources are generated, the code can be annotated with special code generation merge markers so that further code generation for these sources can be intelligently merged with existing code. It is advisable to keep this option enabled until you are confident that you are finished modeling and you would like to generate the sources without the markers, if so desired.

Attributes and operations that do not have any markers are ignored by the generate code process. You do have the option of manually adding a merge marker for attributes and operations that were manually created in the source files.

Prompt Before Generating Code Option

By default, the Generate Code dialog is prompted every time the Generate Code action is invoked. This provides you with the chance to change the generate code options (backup, merge markers or active templates) or to cancel out of the action before any sources are updated. Some may prefer to set the options once and never be prompted again. Disabling this option will prevent the dialog from displaying with each Generate Code execution.

Activating Templates for a UML Project

The domain templates that were configured in the UML Options are just the set of domain templates available for use in your UML projects. For each UML project, you can activate one or more of those available templates. The project customizer can be accessed by right-clicking on the project node and selecting the Properties action, then select the Code Generation node in the customizer panel. A list of the domain template categories are presented. Under each category is a list of the domain templates in summarized form (name, description, element type and stereotype) with a check box that allows you to activate the domain template. When activated, the domain template will be used for matching elements in the project when the Generate Code action is invoked. At least one domain template must be activated for the generate code process to be executed.