Templates

Like a rich client transformation, a rich client template is a Java™ class. It extends from the com.ibm.hats.rcp.ui.templates.RcpTemplate class, which extends from org.eclipse.swt.widgets.Composite. A template can contain SWT widgets, macro controls, and host and application keys. Because a template is an SWT composite, non-ZIETrans widgets can be added to the template.

A template cannot contain host components (ComponentRendering composites), default rendering composites, or global variable controls, while a transformation can contain them.

You can create a template by extending one of the predefined templates that ZIETrans provides. A template defines the basic layout and style of an application, such as:
  • Foreground and background colors used for transformations
  • Fonts to be used for transformations
  • Static labels, such as a logo image
  • Links, such as to a corporate home page
Table 1 lists the methods that can be overridden by the RcpTemplate class.
Table 1. RcpTemplate methods
Method Description
getDefaultFont() Returns the default font to be used by widgets.

getDefaultMonospacedFont()

Allows you to override the default monospaced font at the template level.
getDefaultBackgroundColor() Returns the default background color for the template.
getDefaultForegroundColor() Returns the default foreground color for the template.
getColorMapper() Returns an IColorMapper object that controls how host colors are mapped to colors on the view.
getTableColorProvider() Returns an ITableColorProvider object that controls what colors are used for table controls.
getContentContainer() Returns the composite that will be the parent of transformations or other composites displayed on the template.

Refer to the ZIETrans Rich Client Platform API reference for more information on these methods.

The ZIETrans runtime is responsible for constructing and disposing of templates. ZIETrans runtime performs the following steps:
  1. Constructs a new instance of the specified template class. This class must be a descendent of RcpTemplate, meaning that it must extend from RcpTemplate or from a class that extends from RcpTemplate.
  2. Constructs a new instance of the transformation class.
  3. Calls the setContent() method of the template instance, passing it the transformation instance. This method calls the applyStyleToComposite() method of the transformation instance
  4. Calls the setContent() method of the transformation view instance, passing it the template instance.