StarUML Rozdział 8. Generowanie kodu i dokumentów

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.

Basic Concept

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.

Key Features

StarUML Generator provides following features.

User-definable Template

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

Generating Artifacts

To generate artifacts by template, it must be applicable to current working UML model.

  1. Select [Tools]->[StarUML Generator…] Menu

    ch08h5

  2. In the [Select templates for generation] Page, Check templates to generate in the ListBox and Click [Next] Button.

    ch08h501

  3. To bind values with parameters, Click ch08h6 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)

    ch08h601
  4. In the [Select target path] Page, Select a folder that generated artifacts will be placed and click [Next] button.

    ch08h602

    If you want to create a new folder, click [New Folder…] button and input name of the new folder.

    ch08h603

  5. 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.

    ch08h604

Registering a Template

Your own templates can be registered in StarUML Generator.

  1. In the [Select templates for generation] Page, click [Register Template] button.

    ch08h605

  2. In the [Register Template] Dialog, click ch08h606 button and select a folder that the template files will be placed.

    ch08h607
  3. Input template information on [Properties:] and click [OK] button to complete registering a template.

[Basic] property section

Basic properties for template registration.

<>
</>

<>
</>

Property Description
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.

<>
</>

<>
</>

Property Description
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
(e.g) 1.0
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.

[Parameters] property

  1. Click ch08h608 button in Parameters property.

    ch08h609

  2. In the [Parameters] Dialog, click ch08h7 button to create a new parameter and click ch08h701 button to delete a existing parameter.

    ch08h702

  3. In the [New Parameter] Dialog, specify Name, Type and Default Value for the parameter and click [OK] button.

    ch08h703

Default parameters are different according to the Translator Type. Following are the default parameters for each Translator Types.

<>
</>

<>
</>

<>
</>

<>
</>

Property Type Translator Type Description
TemplateFile FILENAME or STRING WORD,EXCEL,
POWERPOINT
Specify file name of the template document.
OutputFile FILENAME or STRING WORD,EXCEL,
POWERPOINT,
TEXT
Specify file name of the generated artifact.
Keep Comment BOOLEAN WORD,EXCEL,
POWERPOINT
Specify whether to remain the comment used for generation or to delete it.
ShowGenerationProcess BOOLEAN WORD,EXCEL,
POWERPOINT
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.

Note:

To specify file name in the parameters, environment variables is required of StarUML Generator. The variable is as follow.

<>
</>

<>
</>

Variable

Description

$PATH$ The path that the template files are placed.
(e.g.) $PATH$BusinessActorReport.doc
$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.

  1. 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.

    ch08h704
  2. Specify the name of cloned template and click [OK] button.

    ch08h705
  3. You can find the cloned template in the [List of templates]. You can edit more information of the cloned template (click [Template Properties] button).

Template Properties

You can edit properties of a registered template.

  1. 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.

    ch08h706
  2. 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)

    ch08h707

Opening a Template

You can open and edit a registered template.

  1. 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.

    ch08h708
  2. 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.

    ch08h709
  • Deleting a template causes deletion of the template folder and all files in the folder, so you must take care about deleting template.

Using Batch

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.

  1. 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.

    ch08h8

  2. In the [Register Batch] Dialog, specify [Batch Name], [Description] and click [OK] button.

    ch08h801
  3. You can find a new batch as a tab and selected templates in template list of the batch.

    ch08h802

Add templates to existing batch

You can add templates to an existing batch.

  1. 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.

    ch08h803

  2. In the [Select Batch] Dialog, select a batch and click [OK] button.

    ch08h804
  3. You can find templates added to existing batch.

    ch08h805

Executing a batch

You can generate many artifacts at once by using batch.

  1. In the [Select templates for generation] Page, select batch tab to execute.
  2. Check templates to generate and click [Next] button. (As default, all templates are checked in the batch.)

    ch08h806

  3. You can generate artifacts in the batch using different property values. If you want to do so, click ch08h6 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)

    ch08h807
  4. 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
  5. 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.
  6. 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.)

  1. In the [Select templates for generation] Page, go to the batch tab and check templates to remove, and click [Delete Item] button.

    ch08h808

  2. You can make a certain the deletion of the checked templates.

Creating an empty batch

You can create a batch that containing no template.

  1. In the [Select templates for generation] Page, click mouse right button on the any tab, and click [New Batch] menu.

    ch08h809

  2. In the [Register Batch] Dialog, specify [Batch Name], [Description] and click [OK] button.

    ch08h9
  3. In the [Select templates for generation] Page, you can find an empty batch tab.

    ch08h901

Modifying a batch

You can modify information about a batch.

  1. In the [Select templates for generation] Page, select batch tab to modify, and click mouse right button and click [Modify Batch] menu.

    ch08h902

  2. In the [Register Batch] Dialog, modify [Batch Name], [Description] and click [OK] button.

    ch08h903

Deleting a batch

You can delete a batch.

  1. In the [Select templates for generation] Page, select a batch tab to delete and click mouse right button and click [Delete Batch] menu.

    ch08h904

  2. 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.

staruml-generator
templates
template1
template1.tdf
template1.doc
template2
...
batches
batch1.btf
...

Installation and uninstallation of a template

Installing a template is very simple. Simply copy the template folder to the "<STARUML_INSTALL_PATH>modulesstaruml-generatortemplates".

ch08h905

Uninstalling a template is also very simple. Delete the template folder under the "<STARUML_INSTALL_PATH>modulesstaruml-generatortemplates". It?s all.

ch08h906

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".

ch08h907

To uninstall a batch, delete the batch file (.btf) in the "<STARUML_INSTALL_PATH>modulesstaruml-generatorbatches".

ch08h908

Podobne wpisy
StarUML Rozdział 11. Interfejs użytkownika

Ta sekcja opisuje szczegółowo okna w StarUML?. Okno główne Menu Paski narzędzi Okno Dialog Box Okno podręczneRozdział nie został przetłumaczony więcej

StarUML Rozdział 10. Drukowanie

Ten rozdział opisuje zagadnienia związane z drukowaniem diagramów: ustawienia strony, różne metody drukowania diagramów, oraz podglądu druku. Ustawienia Strony Drukowanie więcej

StarUML Rozdział 9. Weryfikacja Modelu

Ten rozdział opisuje kontrolę modelu oprogramowania: metody kontroli oraz przepisy używane przy kontroli. Weryfikacja Modelu Reguły Dobrego Formułowania Weryfikacja Modelu więcej

StarUML Rozdział 7. Zarządzanie modułami

W tym rozdziale dowiesz się jak zarządzać modułami. Między innymi jak instalować moduły, komponenty modułu oraz jak kasować moduły. Instalowanie więcej

Reklama
MODESTO - licencje Enterprise Architect
Scroll to Top