Rozdział ten opisuje podstawy generowania kodu źródłowego i dokumentów.
- Podstawowe założenia
- Generowanie przy pomocy szablonów
- Instalowanie i odinstalowywanie szablonów
Rozdział nie jest przetłumaczony na język polski.
What is Generator?
StarUML Generator is platform module to generate various artifacts (like as Microsoft Word, Excel, PowerPoint, and Text-based artifacts) by templates depending on UML model elements in StarUML. User can define his/her own templates and can apply many different kinds of templates to the same UML model, so user can get various artifacts automatically, easily and in fast.
StarUML Generator provides following features.
Template can be defined by user. You can write templates for .doc, .xls, .ppt directly using MS Word, MS Excel, MS PowerPoint without extra template designer.
Parameters for Template
Template provides parameters for variations of user environments, objectives, and so on. Through parameterized template, you can eliminate inconvenience and can avoid defining a new template caused by a little difference.
Batch processing to generate many artifacts at once
You can generate many kinds of artifacts at once using Batch feature. You can register many templates as a Batch and can generate it at once. Using Batch, a large amount of artifacts can be generated without waiting so you can take a rest.
Support native-styles of MS Word like as Header/Footer
You can put generation commands in Header/Footer in MS Word template and can use MS Word?s native styles in the template.
Support MS Excel Sheets
You can collect various data from UML model and can insert the data into the Cells of Excel Sheet. Using it, you can get good reports by using Graph, Filtering, Sorting and other functions in the Excel.
Support MS PowerPoint Slides
It is allowed to generate slides by hierarchical structure in MS PowerPoint. There is no restriction making PowerPoint slides, so you can generate various slides for presentation automatically with reduction of writing efforts.
Support Anything of text-based artifacts
You can generate any text-based artifacts like as XML, HTML, Source Codes (Java, C#, C++, …), DB Schema, and so on.
Generating by Template
To generate artifacts by template, it must be applicable to current working UML model.
- Select [Tools]->[StarUML Generator…] Menu
- In the [Select templates for generation] Page, Check templates to generate in the ListBox and Click [Next] Button.
- To bind values with parameters, Click Button of each template item in the ListBox, and set values of parameter as you want. (Refer to Registering Template for more information about template parameters)
- In the [Select target path] Page, Select a folder that generated artifacts will be placed and click [Next] button.
If you want to create a new folder, click [New Folder…] button and input name of the new folder.
- In the [Generating…] Page, click [Generate] button. You can check the progress of generation and it will be logged on Logs. If you want to cancel the generation process, click [Cancel] button. When all artifacts are successfully generated, [Finish] will be enabled and clicking it will finish the artifact generation. To see generated artifacts, double-click the item that want to see in the [Generation List] then the generated artifact will be opened.
Registering a Template
Your own templates can be registered in StarUML Generator.
- In the [Select templates for generation] Page, click [Register Template] button.
- In the [Register Template] Dialog, click button and select a folder that the template files will be placed.
- Input template information on [Properties:] and click [OK] button to complete registering a template.
[Basic] property section
Basic properties for template registration.
|Template Name||Name for the template to register.|
|Group||Group name for the template. There is no restriction to name a group but to group a set of template, give the same group name for the set of templates. (it is used for horizontal classification like as RUP, CBD, <ModuleName>, <CompanyName>, …)|
|Category||Category name for the template. There is no restriction to name a category but to categorize a set of template, give the same category name for the set of templates. (it is used for vertical classification like as Requirements, Design, Code, Analysis, …)|
|Description||Brief description of the template.|
[Detail] property section
Detailed properties for template registration.
|Document Type||Type of the template. Select DOCUMENT or CODE.|
|Format||Type of generated artifact. Input the format name or select one of the already defined formats (TXT, DOC, PPT, XLS)|
|Version||Version of the template
|Related Profile||Profiles related to the template.|
|Related Approach||Approach related to the template. (it is a declarative property, so it will not effect anything)|
|Translator Type||Kind of translator for the template. Select one of the following: WORD, EXCEL, POWERPOINT, TEXT, COM(user-defined COM-based generator), SCRIPT(user-defined scripts like as JScript, VBScript, …), EXE(user-defined .EXE-based generator).|
|Translator||Specify filename of user-defined translator. It is used only for user want to use his/her own translator not built-in translators(WORD, EXCEL, POWERPOINT, TEXT)|
|Example||If any, specify an example model for the template.|
|Parameters||Parameters required for the template.|
|Related files||If any, specify all related files to the template.|
- Click button in Parameters property.
- In the [Parameters] Dialog, click button to create a new parameter and click button to delete a existing parameter.
- In the [New Parameter] Dialog, specify Name, Type and Default Value for the parameter and click [OK] button.
Default parameters are different according to the Translator Type. Following are the default parameters for each Translator Types.
|TemplateFile||FILENAME or STRING||WORD,EXCEL,
|Specify file name of the template document.|
|OutputFile||FILENAME or STRING||WORD,EXCEL,
|Specify file name of the generated artifact.|
|Specify whether to remain the comment used for generation or to delete it.|
|Specify whether to show the progress of generation or not. It may affect the performance of the generation.|
|Normal Generation||BOOLEAN||WORD||If true, the template is applied to top-level package (Project). if false, the template is applied to the package (or element) that is currently selected in StarUML.|
|Generate Index||BOOLEAN||WORD||Specify whether to generate Index or not.|
|intermediate||STRING||TEXT||Specify file name of intermediate file used for generation.|
|target||STRING||TEXT||If more than two artifacts are generated, specify the pathname the artifacts are placed.|
To specify file name in the parameters, environment variables is required of StarUML Generator. The variable is as follow.
|$PATH$||The path that the template files are placed.
|$GROUP$||Group name of the template.|
|$CATEGORY$||Category name of the template.|
|$NAME$||Name of the template.|
|$TARGET$||Output path that the user selected.|
Cloning a Template
You can start to define a template by cloning an existing template without defining from the scratch.
- In the [Select templates for generation] Dialog, select a template to clone and click [Clone Template] button, or click mouse right button on the template to clone and then click [Clone Template] menu on the popup menu.
- Specify the name of cloned template and click [OK] button.
- You can find the cloned template in the [List of templates]. You can edit more information of the cloned template (click [Template Properties] button).
You can edit properties of a registered template.
- In the [Select templates for generation] Dialog, select a template want to edit properties and click [Template properties] button, or click mouse right button on the template to edit properties and then click [Show Template Properties] menu on the popup menu.
- Edit properties in the[Modify Template] Dialog and click [OK] button. (Please refer to Registering Template > Basic/Detail Parameters for detailed information of each property)
Opening a Template
You can open and edit a registered template.
- In the [Select templates for generation] Dialog, select a template to open and click [Open Template] button, or click mouse right button on the template to open and then click [Open Template] menu on the popup menu.
- And then, the default application associated with each file extension (.cot, .doc, .xls, .ppt) will be executed and you can edit in the application. (Please refer to StarUML 5.0 Developer Guides > Chapter 11. Writing Template for how to write template)
Deleing a Template
- In the [Select templates for generation] Dialog, select a template to delete and click mouse right button and click [Delete Template] menu in the popup menu.
- Deleting a template causes deletion of the template folder and all files in the folder, so you must take care about deleting template.
In the [List of templates] tab, registered templates are listed. If you want to generate a set of artifacts at once, you can make a batch that used to generate a set of artifacts and can run the batch without selecting a set of templates.
Creating a new batch
Create a new batch containing selected templates.
- In the [Select templates for generation] Page, check templates, to make as a batch, in [List of templates] tab, and click [Register to Batch] button.
- In the [Register Batch] Dialog, specify [Batch Name], [Description] and click [OK] button.
- You can find a new batch as a tab and selected templates in template list of the batch.
Add templates to existing batch
You can add templates to an existing batch.
- In the [Select templates for generation] Page, check templates, to add to existing batch, in the [List of templates] tab and click [Add to Batch] button.
- In the [Select Batch] Dialog, select a batch and click [OK] button.
- You can find templates added to existing batch.
Executing a batch
You can generate many artifacts at once by using batch.
- In the [Select templates for generation] Page, select batch tab to execute.
- Check templates to generate and click [Next] button. (As default, all templates are checked in the batch.)
- You can generate artifacts in the batch using different property values. If you want to do so, click button of each template and set the value of the each property. The change of the properties are applied only once. (Please refer to Registering Template > property for more information about properties of template)
- When [Select target path] page is appeared on the screen, selects a folder to save generate a document to generate, and click [Next]. If you want to add a folder under the present selected folder, click [New Folder] button on left bottom and write a name for adding folder on name configuration dialog
- When [Generating] page is appeared on the screen, clicks [Generate] button. You can check the statue of each template generating through statue bar as generating documents from the template. And the log of generating process is recorded to [Logs:] window. If you want to cancel the present generating document, click [Cancel] button. And clicks OK button on Confirm cancel dialog.
- Log(Document Creation is done) on log window is recorded, and is activated [Finish] button after completing document generation. If you want to finish document generation, close the document generation process as clicking [Finish] button. Or you can check the generated document as double-clicking document list in [Generation List].
Deleting templates in a batch
You can delete templates in the batch. (The deletion in the batch, the template is not remove and only deleted from the batch.)
- In the [Select templates for generation] Page, go to the batch tab and check templates to remove, and click [Delete Item] button.
- You can make a certain the deletion of the checked templates.
Creating an empty batch
You can create a batch that containing no template.
- In the [Select templates for generation] Page, click mouse right button on the any tab, and click [New Batch] menu.
- In the [Register Batch] Dialog, specify [Batch Name], [Description] and click [OK] button.
- In the [Select templates for generation] Page, you can find an empty batch tab.
Modifying a batch
You can modify information about a batch.
- In the [Select templates for generation] Page, select batch tab to modify, and click mouse right button and click [Modify Batch] menu.
- In the [Register Batch] Dialog, modify [Batch Name], [Description] and click [OK] button.
Deleting a batch
You can delete a batch.
- In the [Select templates for generation] Page, select a batch tab to delete and click mouse right button and click [Delete Batch] menu.
- You can make a certain that the deletion of the batch tab (Deleting batch not cause deletion of the templates contained by the template)
Installing and Uninstalling Templates
Organization of templates
Templates are installed under the folder "<STARUML_INSTALL_PATH>modulesstaruml-generatortemplates" and batches are under the folder "<STARUML_INSTALL_PATH>modulesstaruml-generatorbatches". In general, one template matches one folder and the folder contains all files associated to the template. A template includes at least two files. The first is template description file (.tdf) and the second is the template document (.cot, .doc, .xls, .ppt, …). Batch includes one file that is batch file (.btf).
Directory structure of staruml-generator module is as follow.
Installation and uninstallation of a template
Installing a template is very simple. Simply copy the template folder to the "<STARUML_INSTALL_PATH>modulesstaruml-generatortemplates".
Uninstalling a template is also very simple. Delete the template folder under the "<STARUML_INSTALL_PATH>modulesstaruml-generatortemplates". It?s all.
Installation and uninstallation of a batch
Installing a batch is very simple. Simply copy the batch file (.btf) to the "<STARUML_INSTALL_PATH>modulesstaruml-generatorbatches".
To uninstall a batch, delete the batch file (.btf) in the "<STARUML_INSTALL_PATH>modulesstaruml-generatorbatches".