blob: 9fcb72bdf99440047c5ede3dfa8eced18729f3eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import javax.swing.event.TreeModelListener;
import javax.swing.event.TreeModelEvent;
import java.util.Vector;
import java.util.HashMap;
import java.util.Enumeration;
import drafts.com.sun.star.accessibility.*;
import com.sun.star.uno.*;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.uno.Any;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.XServiceName;
/** Objects of this class (usually one, singleton?) listen to accessible
events of all objects in all trees.
*/
public class EventListener
{
public boolean mbVerbose = false;
public EventListener (AccessibilityTreeModel aTreeModel)
{
maTreeModel = aTreeModel;
}
private static String objectToString(Object aObject)
{
if (aObject == null)
return null;
else
return aObject.toString();
}
/** This method handles accessibility objects that are being disposed.
*/
public void disposing (XAccessibleContext xContext)
{
if (mbVerbose)
System.out.println("disposing " + xContext);
maTreeModel.removeNode (xContext);
}
/** This method is called from accessible objects that broadcast
modifications of themselves or from their children. The event is
processed only, except printing some messages, if the tree is not
locked. It should be locked during changes to its internal
structure like expanding nodes.
*/
public void notifyEvent (AccessibleEventObject aEvent)
{
EventHandler aHandler;
switch (aEvent.EventId)
{
case AccessibleEventId.ACCESSIBLE_CHILD_EVENT:
aHandler = new ChildEventHandler (aEvent, maTreeModel);
break;
case AccessibleEventId.ACCESSIBLE_BOUNDRECT_EVENT:
case AccessibleEventId.ACCESSIBLE_VISIBLE_DATA_EVENT:
aHandler = new GeometryEventHandler (aEvent, maTreeModel);
break;
case AccessibleEventId.ACCESSIBLE_NAME_EVENT:
case AccessibleEventId.ACCESSIBLE_DESCRIPTION_EVENT:
case AccessibleEventId.ACCESSIBLE_STATE_EVENT:
case AccessibleEventId.CONTROLLED_BY_EVENT:
case AccessibleEventId.CONTROLLER_FOR_EVENT:
case AccessibleEventId.LABEL_FOR_EVENT:
case AccessibleEventId.LABELED_BY_EVENT:
case AccessibleEventId.MEMBER_OF_EVENT:
case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
aHandler = new ContextEventHandler (aEvent, maTreeModel);
break;
case AccessibleEventId.ACCESSIBLE_TABLE_MODEL_EVENT:
case AccessibleEventId.ACCESSIBLE_TABLE_CAPTION_EVENT:
case AccessibleEventId.ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_EVENT:
case AccessibleEventId.ACCESSIBLE_TABLE_COLUMN_HEADER_EVENT:
case AccessibleEventId.ACCESSIBLE_TABLE_ROW_DESCRIPTION_EVENT:
case AccessibleEventId.ACCESSIBLE_TABLE_ROW_HEADER_EVENT:
case AccessibleEventId.ACCESSIBLE_TABLE_SUMMARY_EVENT:
aHandler = new TableEventHandler (aEvent, maTreeModel);
break;
case AccessibleEventId.ACCESSIBLE_ACTION_EVENT:
aHandler = new EventHandler (aEvent, maTreeModel);
break;
case AccessibleEventId.ACCESSIBLE_HYPERTEXT_EVENT:
aHandler = new EventHandler (aEvent, maTreeModel);
break;
case AccessibleEventId.ACCESSIBLE_ACTIVE_DESCENDANT_EVENT:
case AccessibleEventId.ACCESSIBLE_CARET_EVENT:
case AccessibleEventId.ACCESSIBLE_TEXT_EVENT:
case AccessibleEventId.ACCESSIBLE_VALUE_EVENT:
aHandler = new EventHandler (aEvent, maTreeModel);
break;
default:
aHandler = null;
break;
}
if (aHandler == null)
System.out.println (" unhandled event");
else
{
if (mbVerbose)
aHandler.Print (System.out);
aHandler.Process ();
}
}
private AccessibilityTreeModel maTreeModel;
}
|