You can create custom pages for transformation
configurations. You might create these pages so that users can specify
values for the properties that you add to a transformation extension.
When a transformation user creates a transformation configuration
for the extended transformation, the new pages are displayed in the
transformation configuration editor or wizard.
Before you begin
A transformation author must register the target transformation
with the transformation service. The transformation extension 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 extension.
Note: The example
in this topic assumes that you define the custom pages in a different
plug-in from the transformation extension.
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.
About this task
To add pages to a transformation configuration:
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.AbstractExtensionGUI
class
- For each page that you contribute to the transformation configuration,
a class that extends the com.ibm.xtools.transform.ui.AbstractTransformExtensionConfigTab
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.AbstractExtensionGUI class.
- In the Java file
editor, specify the Java code
to override the method named getConfigurationTabs(ITransformationDescriptor
descriptor, ITransformExtension extension). 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 AbstractTransformExtensionConfigTab[] getConfigurationTabs(
ITransformationDescriptor descriptor, ITransformExtension extension ) {
AbstractTransformExtensionConfigTab[] superTabs =
super.getConfigurationTabs(descriptor, extension);
AbstractTransformExtensionConfigTab[] myTabs =
new AbstractTransformExtensionConfigTab[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", extension);
return myTabs;
}
- For each class that you created in step 1 that extends the
com.ibm.xtools.transform.ui.AbstractTransformExtensionConfigTab class,
implement the inherited 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 extension for which you are creating
the custom pages.
- In the META-INF folder of the project that contains the
transformation extension, click the TransformationExtension element
to which to add the custom pages.
- On the Extensions page, in the All Extensions section,
click the TransformationExtension element to which to add the custom
pages.
- In the Extension Element Details section,
in the extensionGUI 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,
ITransformExtension extension) method. If the class that
extends the com.ibm.xtools.transform.ui.AbstractExtensionGUI class
is located in the same plug-in as the transformation extension, do
not specify the plug-in ID. A parameter named extensionGUI
is added to the MANIFEST.MF file, as in the following
example:
<TransformationExtension
enabled="true"
extensionGUI="com.myTransform.ui/com.myTransform.ui.MyGUI"
id="MyTransformation.TransformationExtension"
readonly="false"
targetTransformation="com.target.transformation/transformation1"
version="1.0.0">
</TransformationExtension>
- Click .
Results
To test the custom pages, start a runtime workbench and create
a transformation configuration for the extended transformation.
The
transformation configuration editor and wizard display the pages that
are in the list that the getConfigurationTabs method returns.