Contributing new actions to the annotation toolbar
Typically, you produce an annotation by adding an action to the annotation toolbar. This action is represented as a toolbar button.
To contribute a new action to the annotation toolbar, complete these procedures:
- Declare a new annotation action in the plugin.xml file by using the
com.ibm.rational.test.lt.recorder.ui.annotationContribution
extension point and theannotationAction
element. - Assign a unique ID to the annotation action.
- Decide whether this action is visible by default or not. Actions that are visible by default are available in all recording sessions unless made unavailable by a client or recorder. Actions that are not visible by default are available only if a recorder or client requires the action.
- Define an implementation class for this action. The implementation class must extend the com.ibm.rational.test.lt.recorder.ui.actions.AbstractAnnotationAction abstract class.
Consider these facts about AbstractAnnotationAction implementations:
- This class extends the JFace Action class.
- In the constructor, set the name, tooltip text, and image descriptor of the action.
- Implement the run() method. This method can interact with the user. For example, this method can prompt the user for a text field. If there is any interaction with the user, the time in milliseconds spent interacting with the user must be measured.
- To create an annotation, create an instance of the com.ibm.rational.test.lt.recorder.core.annotations.RecorderAnnotation class, and then pass the annotation type as an argument. Set the annotation properties using the setter methods provided in this class.
- After the annotation has been built, forward the annotation by
sending an AnnotationMessage message to the annotation recorder. This
is typically a call of this form:
annotationRecorder.sendMessage(new AnnotationMessage(annotation, interactionTime));