01: package abbot.editor.editors;
02:
03: import java.awt.event.ActionEvent;
04: import javax.swing.*;
05: import abbot.*;
06: import abbot.i18n.Strings;
07: import abbot.script.Annotation;
08:
09: /** A Annotation only has its description available for editing. */
10:
11: public class AnnotationEditor extends StepEditor {
12:
13: private Annotation annotation;
14: private JTextArea text;
15: private JButton reposition;
16: private JCheckBox userDismiss;
17: private JComboBox relative;
18:
19: public AnnotationEditor(Annotation annotation) {
20: super (annotation);
21: this .annotation = annotation;
22: text = addTextArea(Strings.get("AnnotationText"), annotation
23: .getText());
24: relative = addComponentSelector(Strings.get("AnchorComponent"),
25: annotation.getRelativeTo(), annotation.getResolver(),
26: true);
27: reposition = addButton(Strings.get("Reposition"));
28: userDismiss = addCheckBox(Strings.get("UserDismiss"),
29: annotation.getUserDismiss());
30: }
31:
32: /** An editor component changed, respond to it by updating the step. */
33: public void actionPerformed(ActionEvent ev) {
34: Object src = ev.getSource();
35: if (src == text) {
36: annotation.setText(text.getText());
37: fireStepChanged();
38: } else if (src == relative) {
39: annotation.setRelativeTo((String) relative
40: .getSelectedItem());
41: fireStepChanged();
42: } else if (src == reposition) {
43: try {
44: annotation.showAnnotation();
45: fireStepChanged();
46: } catch (Exception e) {
47: // FIXME show a dialog instead
48: Log.warn(e);
49: }
50: } else if (src == userDismiss) {
51: annotation.setUserDismiss(userDismiss.isSelected());
52: if (annotation.isShowing())
53: annotation.showAnnotation();
54: fireStepChanged();
55: } else {
56: super.actionPerformed(ev);
57: }
58: }
59: }
|