Model-to-text transformations setup instructions

To run the transformations, you must import the plug-in into your workspace, start the runtime workbench, and invoke the transformations.

About this task

Importing the sample transformations

To import the sample:

Procedure

  1. On the Model-to-text transformation sample overview page, click Import the sample.
  2. In the Sample Model-to-Text Transformations wizard, in the Project Name field, specify a name for the sample project.
  3. Click Finish.
  4. If you are prompted to switch to the Plug-in Development perspective, click OK. The wizard creates the new project in your workspace. The Package Explorer view displays the new plug-in project. You can now browse the sample UML modeling plug-in code.

Results

The imported plug-in contains three transformations:
  • Class to Text > Console
  • Class to Text > File
  • State to JSP

Running the Class to Text -> Console transformation

About this task

To run the transformation:

Procedure

  1. Start the runtime workbench.
  2. Switch to the Modeling perspective.
  3. In the runtime workbench, create a UML model that contains a package with one or more classes.
  4. Click File > New > Transformation Configuration to create a transformation configuration file.
  5. In the Name field, specify a filename.
  6. In the navigation hierarchy, click Sample Transformations > Class to Text > Console.
  7. In the Configuration file, specify a destination project or folder, and click Next.
  8. On the Source page, select a class, a package, or the model in the source model as the source.
  9. Click Finish to create the transformation configuration file.
  10. Right-click the transformation configuration file; then click Transform > Class to Text > Console. The transform results are displayed in the Console view where the sample is imported.

Running the Class-to-Text > File transformation

About this task

To run the transformation:

Procedure

  1. Start the runtime workbench.
  2. Switch to the Modeling perspective.
  3. In the runtime workbench, create a UML model that contains a package with one or more classes.
  4. Click File > New > Transformation Configuration to create a transformation configuration file.
  5. In the Name field, specify a filename.
  6. In the navigation hierarchy, click Sample Transformations > Class to Text > File.
  7. In the Configuration file, specify a destination project or folder, and click Next.
  8. On the Source page, select a class, a package, or the model in the source model as the source.
  9. Press the Finish button to create the transformation configuration file.
  10. Right click on the transformation configuration file; then click Transform > Class to Text > File.

    By default, the transformation stores the results in an output file named class2text.txt, in a folder named ClassToTextOutput. To view the file, open a Navigator view, if it is not already open.

    To specify a different name for the output file, in the transformation configuration editor, click the Properties tab. On the Properties page, in the Target File Name field, specify a new name and save the configuration.

Running the State-to-JSP transformation

About this task

To run the transformation:

Procedure

  1. Start the runtime workbench.
  2. Switch to the Modeling perspective.
  3. In the runtime workbench, create a UML model that contains a package with one or more classes.
  4. Apply the ScreenFlow profile to the model.
  5. Mark up one or more states by applying a stereotype from the ScreenFlow profile to each state.
  6. Set the values of the stereotype attributes to the appropriate stereotype value.
  7. To create a transformation configuration file, click File -> New -> Transformation Configuration .
  8. In the Name field, specify a filename.
  9. In the navigation hierarchy, click Sample Transformations > Class to text> State to Jsp.
  10. In the Configuration file, specify a destination project or folder, and click Next.
  11. On the Source page, select a class, a package, or the model in the source model as the source.
  12. Press the Finish button to create the transformation configuration file.
  13. Right-click the transformation configuration file and select Transform -> Class to Text ->State to Jsp.

    The transformation generates the JSP files and places them in the specified project in a folder named web. To view the file, open a Navigator view, if it is not already open.

    The State-to-JSP transformation does not overwrite the JSP files that already exist. To overwrite existing JSP files, in the Run Transform window, click the Properties tab. On the Properties page, set the Overwrite Output Files property to true.


Feedback