Previewing Object Code

Click the Preview tab in the property sheet of the model, packages, classes, and various other model objects in order to view the code that will be generated for it.

For example, if you have created EJB or servlet components in Java, the Preview tab displays the EJB or Web deployment descriptor files. If you have selected an XML family language, the Preview tab displays the Schema file that corresponds to the XML file to be generated.

If you have selected the Preview Editable option (available from Tools > Model Options), you can modify the code of a classifier directly from its Preview tab. The modified code must be valid and apply only to the present classifier or your modifications will be ignored. You can create generalization and realization links if their classifiers already exist in the model, but you cannot rename the classifier or modify the package declaration to move it to another package. You should avoid renaming attributes and operations, as any other properties that are not generated (such as description, annotation or extended attributes) will be lost. Valid changes are applied when you leave the Preview tab or click the Apply button.

In a model targeting PowerBuilder, this feature can be used to provide a global vision of the code of an object and its functions which is not available in PowerBuilder. You can use the Preview tab to check where instance variables are used in the code. You can also modify the body of a function or create a new function from an existing function using copy/paste.

You can use the following tools and keyboard shortcuts from the Preview toolbar:

Tool

Description

Editor Menu [Shift+F11] Provides access to various editor features, including the insertion of and navigation through bookmarks in the Preview tab:
  • Toggle Bookmark [Ctrl+F2] Inserts or removes a bookmark (a blue box) at the cursor position.
  • Next Bookmark [F2]
  • Previous Bookmark [Shift+F2]
Note that bookmarks are not printable and are lost if you refresh the tab, or use the Show Generation Options tool.

Refresh [F5] - Refreshes the Preview tab.

You can debug the GTL templates that generate the code shown in the Preview tab. To do so, open the target or extension resource file, select the Enable Trace Mode option, and click OK to return to your model. You may need to click the Refresh tool to display the templates.

Select Generation Targets [Ctrl+F6] - Lets you select additional generation targets (defined in extensions), and adds a sub-tab for each selected target. For information about generation targets, see "Specifying Additional Generation Targets" in Chapter 1, Resource Files and the Public Metamodel in Customizing and Extending PowerDesigner .

Show Generation Options [Ctrl+W] - Opens the Generation Options dialog, allowing you to modify the generation options and to see the impact on the code. This feature is especially useful when you are working with Java. For other object languages, generation options do not influence the code.