You can create custom pages for transformation
configurations. You might create these pages so that transformation
users can specify values for the properties that you add to a transformation.
When a transformation user creates a transformation configuration,
the new pages are displayed in the transformation configuration editor
or wizard.
Before you begin
A
transformation author must register the transformation with the transformation
service. The transformation must define the properties that are associated
with the new configuration tabs.
As the
author of custom transformation configuration pages, you must identify
a project in the workspace that contains these user interface artifacts. You
can create a project that contains the Java™ code
that implements the new pages, or you can define the pages in an existing
project that contains a transformation.
Note: The example in this topic
assumes that you define the custom pages in a different plug-in from
the transformation.
For more information
about the user interface classes listed in this topic, see the "Transformation
UI" section of the
Rational® Transformation
Developer Guide.
Note: Some information, such as links to Eclipse
documentation or to developer guides, is available only from the help
topics that are installed with the product.
Procedure
- In the project
that you have identified to contain the custom pages, create the following Java classes:
- A class that extends the com.ibm.xtools.transform.ui.AbstractTransformGUI
class
- For each page that you contribute to the transformation configuration,
a class that extends the com.ibm.xtools.transform.ui.AbstractTransformConfigTab
class
- Switch to the Java perspective: Click .
- In the Package Explorer view, double-click
the Java class that you created
in step 1, which
extends the com.ibm.xtools.transform.ui.AbstractTransformGUI class.
- In the Java file
editor, specify the Java code
to override the method named getConfigurationTabs(ITransformationDescriptor
descriptor). This method returns the
list of pages to display in the transformation configuration editor
or wizard. You can use the following code fragment as an example:
public AbstractTransformConfigTab[] getConfigurationTabs(
ITransformationDescriptor descriptor) {
AbstractTransformConfigTab[] superTabs =
super.getConfigurationTabs(descriptor);
AbstractTransformConfigTab[] myTabs =
new AbstractTransformConfigTab[superTabs.length + 1];
for (int i = 0; i < superTabs.length; i++) {
myTabs[i] = superTabs[i];
}
myTabs[myTabs.length - 1] = new MyTab(descriptor, "My tab ID", "My tab label");
return myTabs;
}
- For each class that you created in step 1 that extends the com.ibm.xtools.transform.ui.AbstractTransformConfigTab
class, implement the methods named populateContext, populateTab, and
createContents, as in the following example:
public Control createContents(Composite parent) {
Composite contents = new Composite(parent, SWT.None);
contents.setLayout(new GridLayout());
text = new Text(contents, SWT.None);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
setDirty();
}
});
return contents;
}
public void populateContext(ITransformContext context) {
context.setPropertyValue("MyPropertyId", text.getText());
}
public void populateTab(ITransformContext context) {
String newText = (String) context.getPropertyValue("MyPropertyId");
if (newText == null) {
newText = "";
}
text.setText(newText);
}
- Click ; then rebuild the project.
- Open the Plug-in Development perspective:
Click .
- In the Package Explorer view,
expand the name of the project that contains the transformation for
which you are creating the custom pages.
- In the META-INF folder of the transformation
project, double-click the MANIFEST.MF file.
- On the Extensions page, in the All Extensions section,
click the Transformation element to which to add the custom pages.
- In the Extension Element Details section,
in the transformGUI field, specify the plug-in
identifier (ID) and the name of the Java package
and class that you created in step 1, which overrides the getConfigurationTabs(ITransformationDescriptor
descriptor) method. If the class that extends the com.ibm.xtools.transform.ui.AbstractTransformGUI
class is located in the same plug-in as the transformation, do not
specify the plug-in ID. A parameter named transformGUI
is added to the MANIFEST.MF file, as in the following
example:
<Transformation
groupPath="myTrans"
id="myTrans.transformation"
name="Transformation"
sourceModelType="resource"
targetModelType="resource"
transformGUI="com.myTransform.ui/com.myTransform.ui.MyGUI"</Transformation>
</Transformation>
- Click .
Results
To test the custom pages, start a runtime workbench and create
a transformation configuration for the transformation.
The
transformation configuration editor and wizard display the pages that
are in the list that the getConfigurationTabs method returns.