Open topic with navigation
In this part of the lesson, you implement the label_attr method in the ImageLabelCS class to return the name of the image file used for the ImageLabel. This enables UFT to use the ImageLabel's label property as attached text for adjacent controls. In addition, implementing the ImageLabel's label property provides the ImageLabel test object with a more specific name.
Implement the label_attr method in the ImageLabelCS class.
In Eclipse, in the ImageLabelCS.java file, in the label_attr method stub, replace
return super.label_attr(obj); with the following code:
ImageLabel il = (ImageLabel)obj; String res = il.getText(); if(res != null && res.length() > 0) return res; res = il.getImageString(); if(res == null || res.length() == 0) return null; int last = res.lastIndexOf('/'); if(last == -1) return res; return res.substring(last+1);
The label identification property returns the text on the label (if it exists) or the name of the image file used for the ImageLabel (without the full path).
Click the Save button, or select File > Save to save your changes.
Note: You do not have to deploy the toolkit support to UFT again because you changed only Java class files and not configuration files.
Test the new custom support.
Run the application and view the ImageLabel control and the text box with the UFT Object Spy, as described in Planning Support for the ImageLabel Control.
Note: You did not modify the test object configuration file. Therefore, you can use an open UFT session (running with the ImageControls custom toolkit support loaded). However, you must close the SampleApp application and run it again, for the changes you made in the custom support to take effect.
UFT now recognizes the ImageLabel as a JavaStaticText test object named UFT Java(st), with the label property UFT Java.
UFT now recognizes the text box as a JavaEdit test object named UFT Java. The label property of the JavaEdit test object is empty. The ImageLabel's label property provides the text for the JavaEdit's attached text property, which is used as the test object name:
Note: If you modify the SampleApp application and remove the line
imageLb.setText("QuickTest Java");, the ImageLabel will not display any text. UFT will then recognize the ImageLabel as a JavaStaticText test object named mercury.gif(st), with the label property mercury.gif. UFT will recognize the text box as a JavaEdit test object named mercury.gif.
The ImageLabel static-text custom control is now fully supported, according to the specifications you determined when planning your custom support. The support for the ImageControls toolkit is now complete. You can find a ready-made example of this support in the <UFT Java Add-in Extensibility SDK installation folder>\samples\ImageControlsSupport folder. (If you deploy this example manually, you must compile the Java classes before deploying.)