4 import java
.awt
.GridBagConstraints
;
5 import java
.awt
.GridBagLayout
;
6 import java
.awt
.event
.ActionListener
;
7 import java
.awt
.event
.ActionEvent
;
9 import javax
.swing
.JButton
;
10 import javax
.swing
.JLabel
;
12 import com
.sun
.star
.accessibility
.AccessibleEventId
;
13 import com
.sun
.star
.accessibility
.AccessibleEventObject
;
14 import com
.sun
.star
.accessibility
.AccessibleStateType
;
15 import com
.sun
.star
.accessibility
.XAccessibleText
;
16 import com
.sun
.star
.accessibility
.XAccessibleContext
;
17 import com
.sun
.star
.accessibility
.XAccessibleStateSet
;
18 import com
.sun
.star
.uno
.UnoRuntime
;
21 extends ListeningObjectView
23 /** Create a TextView when the given object supports the
24 XAccessibleText interface.
26 static public ObjectView
Create (
27 ObjectViewContainer aContainer
,
28 XAccessibleContext xContext
)
30 XAccessibleText xText
= (XAccessibleText
)UnoRuntime
.queryInterface(
31 XAccessibleText
.class, xContext
);
33 return new TextView (aContainer
);
39 public TextView (ObjectViewContainer aContainer
)
43 setLayout (new GridBagLayout());
44 GridBagConstraints aConstraints
= new GridBagConstraints ();
46 JLabel aLabel
= new JLabel ("Text:");
47 aConstraints
.gridy
= 0;
48 aConstraints
.weightx
= 1;
49 aConstraints
.fill
= GridBagConstraints
.HORIZONTAL
;
50 add (aLabel
, aConstraints
);
52 maTextLabel
= new JLabel ("");
53 aConstraints
.gridx
= 1;
54 aConstraints
.fill
= GridBagConstraints
.NONE
;
55 aConstraints
.anchor
= GridBagConstraints
.WEST
;
56 add (maTextLabel
, aConstraints
);
58 aLabel
= new JLabel ("Caret position:");
59 aConstraints
.gridx
= 0;
60 aConstraints
.gridy
= 1;
61 aConstraints
.weightx
= 1;
62 aConstraints
.fill
= GridBagConstraints
.HORIZONTAL
;
63 add (aLabel
, aConstraints
);
65 maCaretPositionLabel
= new JLabel ("");
66 aConstraints
.gridx
= 1;
67 aConstraints
.fill
= GridBagConstraints
.NONE
;
68 aConstraints
.anchor
= GridBagConstraints
.WEST
;
69 add (maCaretPositionLabel
, aConstraints
);
73 /** Additionally to the context store a reference to the
74 XAccessibleText interface.
76 public void SetObject (XAccessibleContext xObject
)
78 mxText
= (XAccessibleText
)UnoRuntime
.queryInterface(
79 XAccessibleText
.class, xObject
);
80 super.SetObject (xObject
);
83 synchronized public void Destroy ()
88 synchronized public void Update ()
92 maTextLabel
.setText ("<null object>");
93 maCaretPositionLabel
.setText ("<null object>");
97 maTextLabel
.setText (mxText
.getText());
98 maCaretPositionLabel
.setText (Integer
.toString(mxText
.getCaretPosition()));
102 public String
GetTitle ()
107 public void notifyEvent (AccessibleEventObject aEvent
)
109 System
.out
.println (aEvent
);
110 switch (aEvent
.EventId
)
112 case AccessibleEventId
.TEXT_CHANGED
:
113 case AccessibleEventId
.CARET_CHANGED
:
121 maCaretPositionLabel
;
122 private XAccessibleText mxText
;