1 /*************************************************************************
2  *
3  *  The Contents of this file are made available subject to the terms of
4  *  the BSD license.
5  *
6  *  Copyright 2000, 2010 Oracle and/or its affiliates.
7  *  All rights reserved.
8  *
9  *  Redistribution and use in source and binary forms, with or without
10  *  modification, are permitted provided that the following conditions
11  *  are met:
12  *  1. Redistributions of source code must retain the above copyright
13  *     notice, this list of conditions and the following disclaimer.
14  *  2. Redistributions in binary form must reproduce the above copyright
15  *     notice, this list of conditions and the following disclaimer in the
16  *     documentation and/or other materials provided with the distribution.
17  *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18  *     contributors may be used to endorse or promote products derived
19  *     from this software without specific prior written permission.
20  *
21  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  *************************************************************************/
34 
35 import java.util.HashMap;
36 import com.sun.star.accessibility.AccessibleStateType;
37 import com.sun.star.accessibility.AccessibleEventId;
38 import com.sun.star.accessibility.AccessibleRole;
39 import com.sun.star.accessibility.AccessibleRelationType;
40 
41 
42 /** Provide names for several accessibility constants groups.
43 */
44 public class NameProvider
45 {
46     /** Return the name of the specified state.
47         @param nStateId
48             Id of the state for which to return its name.  This is one of
49             the ids listed in the <type>AccessibleStateType</const>
50             constants group.
51         @return
52             Returns the name of the specified state or an empty string if an
53             invalid / unknown state id was given.
54      */
55     public static String getStateName (int nStateId)
56     {
57         return (String)maStateMap.get (new Integer(nStateId));
58     }
59 
60 
61     /** Return the name of the specified event.
62         @param nEventId
63             Id of the event type for which to return its name.  This is one
64             of the ids listed in the <type>AccessibleEventId</const>
65             constants group.
66         @return
67             Returns the name of the specified event type or an empty string
68             if an invalid / unknown event id was given.
69      */
70     public static String getEventName (int nEventId)
71     {
72         return (String)maEventMap.get (new Integer(nEventId));
73     }
74 
75 
76     /** Return the name of the specified role.
77         @param nRole
78             Id of the role for which to return its name.  This is one of
79             the ids listed in the <type>AccessibleRole</const>
80             constants group.
81         @return
82             Returns the name of the specified role or an empty string if an
83             invalid / unknown role id was given.
84      */
85     public static String getRoleName (int nRole)
86     {
87         return (String)maRoleMap.get (new Integer(nRole));
88     }
89 
90 
91     /** Return the name of the specified relation.
92         @param nRelation
93             Id of the relation for which to return its name.  This is one of
94             the ids listed in the <type>AccessibleRelationType</const>
95             constants group.
96         @return
97             Returns the name of the specified relation type or an empty
98             string if an invalid / unknown role id was given.
99      */
100     public static String getRelationName (int nRelation)
101     {
102         return (String)maRelationMap.get (new Integer(nRelation));
103     }
104 
105 
106     private static HashMap maStateMap = new HashMap();
107     private static HashMap maEventMap = new HashMap();
108     private static HashMap maRoleMap = new HashMap();
109     private static HashMap maRelationMap = new HashMap();
110 
111     static {
112         maStateMap.put (new Integer (AccessibleStateType.INVALID), "INVALID");
113         maStateMap.put (new Integer (AccessibleStateType.ACTIVE), "ACTIVE");
114         maStateMap.put (new Integer (AccessibleStateType.ARMED), "ARMED");
115         maStateMap.put (new Integer (AccessibleStateType.BUSY), "BUSY");
116         maStateMap.put (new Integer (AccessibleStateType.CHECKED), "CHECKED");
117         maStateMap.put (new Integer (AccessibleStateType.DEFUNC), "DEFUNC");
118         maStateMap.put (new Integer (AccessibleStateType.EDITABLE), "EDITABLE");
119         maStateMap.put (new Integer (AccessibleStateType.ENABLED), "ENABLED");
120         maStateMap.put (new Integer (AccessibleStateType.EXPANDABLE), "EXPANDABLE");
121         maStateMap.put (new Integer (AccessibleStateType.EXPANDED), "EXPANDED");
122         maStateMap.put (new Integer (AccessibleStateType.FOCUSABLE), "FOCUSABLE");
123         maStateMap.put (new Integer (AccessibleStateType.FOCUSED), "FOCUSED");
124         maStateMap.put (new Integer (AccessibleStateType.HORIZONTAL), "HORIZONTAL");
125         maStateMap.put (new Integer (AccessibleStateType.ICONIFIED), "ICONIFIED");
126         maStateMap.put (new Integer (AccessibleStateType.MODAL), "MODAL");
127         maStateMap.put (new Integer (AccessibleStateType.MULTI_LINE), "MULTI_LINE");
128         maStateMap.put (new Integer (AccessibleStateType.MULTI_SELECTABLE), "MULTI_SELECTABLE");
129         maStateMap.put (new Integer (AccessibleStateType.OPAQUE), "OPAQUE");
130         maStateMap.put (new Integer (AccessibleStateType.PRESSED), "PRESSED");
131         maStateMap.put (new Integer (AccessibleStateType.RESIZABLE), "RESIZABLE");
132         maStateMap.put (new Integer (AccessibleStateType.SELECTABLE), "SELECTABLE");
133         maStateMap.put (new Integer (AccessibleStateType.SELECTED), "SELECTED");
134         maStateMap.put (new Integer (AccessibleStateType.SENSITIVE), "SENSITIVE");
135         maStateMap.put (new Integer (AccessibleStateType.SHOWING), "SHOWING");
136         maStateMap.put (new Integer (AccessibleStateType.SINGLE_LINE), "SINGLE_LINE");
137         maStateMap.put (new Integer (AccessibleStateType.STALE), "STALE");
138         maStateMap.put (new Integer (AccessibleStateType.TRANSIENT), "TRANSIENT");
139         maStateMap.put (new Integer (AccessibleStateType.VERTICAL), "VERTICAL");
140         maStateMap.put (new Integer (AccessibleStateType.VISIBLE), "VISIBLE");
141         maStateMap.put (new Integer (AccessibleStateType.MANAGES_DESCENDANTS),
142             "MANAGES_DESCENDANTS");
143         //        maStateMap.put (new Integer (AccessibleStateType.INCONSISTENT),"INCONSISTENT");
144 
145 
146         maEventMap.put (new Integer (0),
147             "[UNKNOWN]");
148         maEventMap.put (new Integer (AccessibleEventId.NAME_CHANGED),
149             "NAME_CHANGED");
150         maEventMap.put (new Integer (AccessibleEventId.DESCRIPTION_CHANGED),
151             "DESCRIPTION_CHANGED");
152         maEventMap.put (new Integer (AccessibleEventId.ACTION_CHANGED),
153             "ACTION_CHANGED");
154         maEventMap.put (new Integer (AccessibleEventId.STATE_CHANGED),
155             "STATE_CHANGED");
156         maEventMap.put (new Integer (AccessibleEventId.ACTIVE_DESCENDANT_CHANGED),
157             "ACTIVE_DESCENDANT_CHANGED");
158         maEventMap.put (new Integer (AccessibleEventId.BOUNDRECT_CHANGED),
159             "BOUNDRECT_CHANGED");
160         maEventMap.put (new Integer (AccessibleEventId.CHILD),
161             "CHILD");
162         maEventMap.put (new Integer (AccessibleEventId.INVALIDATE_ALL_CHILDREN),
163             "INVALIDATE_ALL_CHILDREN");
164         maEventMap.put (new Integer (AccessibleEventId.SELECTION_CHANGED),
165             "SELECTION_CHANGED");
166         maEventMap.put (new Integer (AccessibleEventId.VISIBLE_DATA_CHANGED),
167             "VISIBLE_DATA_CHANGED");
168         maEventMap.put (new Integer (AccessibleEventId.VALUE_CHANGED),
169             "VALUE_CHANGED");
170         maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_FROM_RELATION_CHANGED),
171             "CONTENT_FLOWS_FROM_RELATION_CHANGED");
172         maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_TO_RELATION_CHANGED),
173             "CONTENT_FLOWS_TO_RELATION_CHANGED");
174         maEventMap.put (new Integer (AccessibleEventId.CONTROLLED_BY_RELATION_CHANGED),
175             "CONTROLLED_BY_RELATION_CHANGED");
176         maEventMap.put (new Integer (AccessibleEventId.CONTROLLER_FOR_RELATION_CHANGED),
177             "CONTROLLER_FOR_RELATION_CHANGED");
178         maEventMap.put (new Integer (AccessibleEventId.LABEL_FOR_RELATION_CHANGED),
179             "LABEL_FOR_RELATION_CHANGED");
180         maEventMap.put (new Integer (AccessibleEventId.LABELED_BY_RELATION_CHANGED),
181             "LABELED_BY_RELATION_CHANGED");
182         maEventMap.put (new Integer (AccessibleEventId.MEMBER_OF_RELATION_CHANGED),
183             "MEMBER_OF_RELATION_CHANGED");
184         maEventMap.put (new Integer (AccessibleEventId.SUB_WINDOW_OF_RELATION_CHANGED),
185             "SUB_WINDOW_OF_RELATION_CHANGED");
186         maEventMap.put (new Integer (AccessibleEventId.CARET_CHANGED),
187             "CARET_CHANGED");
188         maEventMap.put (new Integer (AccessibleEventId.TEXT_SELECTION_CHANGED),
189             "TEXT_SELECTION_CHANGED");
190         maEventMap.put (new Integer (AccessibleEventId.TEXT_CHANGED),
191             "TEXT_CHANGED");
192         maEventMap.put (new Integer (AccessibleEventId.TEXT_ATTRIBUTE_CHANGED),
193             "TEXT_ATTRIBUTE_CHANGED");
194         maEventMap.put (new Integer (AccessibleEventId.HYPERTEXT_CHANGED),
195             "HYPERTEXT_CHANGED");
196         maEventMap.put (new Integer (AccessibleEventId.TABLE_CAPTION_CHANGED),
197             "TABLE_CAPTION_CHANGED");
198         maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_DESCRIPTION_CHANGED),
199             "TABLE_COLUMN_DESCRIPTION_CHANGED");
200         maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_HEADER_CHANGED),
201             "TABLE_COLUMN_HEADER_CHANGED");
202         maEventMap.put (new Integer (AccessibleEventId.TABLE_MODEL_CHANGED),
203             "TABLE_MODEL_CHANGED");
204         maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_DESCRIPTION_CHANGED),
205             "TABLE_ROW_DESCRIPTION_CHANGED");
206         maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_HEADER_CHANGED),
207             "TABLE_ROW_HEADER_CHANGED");
208         maEventMap.put (new Integer (AccessibleEventId.TABLE_SUMMARY_CHANGED),
209             "TABLE_SUMMARY_CHANGED");
210 
211         maRoleMap.put (new Integer(AccessibleRole.UNKNOWN), "UNKNOWN");
212         maRoleMap.put (new Integer (AccessibleRole.UNKNOWN), "UNKNOWN");
213         maRoleMap.put (new Integer (AccessibleRole.ALERT), "ALERT");
214         maRoleMap.put (new Integer (AccessibleRole.COLUMN_HEADER), "COLUMN_HEADER");
215         maRoleMap.put (new Integer (AccessibleRole.CANVAS), "CANVAS");
216         maRoleMap.put (new Integer (AccessibleRole.CHECK_BOX), "CHECK_BOX");
217         maRoleMap.put (new Integer (AccessibleRole.CHECK_MENU_ITEM), "CHECK_MENU_ITEM");
218         maRoleMap.put (new Integer (AccessibleRole.COLOR_CHOOSER), "COLOR_CHOOSER");
219         maRoleMap.put (new Integer (AccessibleRole.COMBO_BOX), "COMBO_BOX");
220         maRoleMap.put (new Integer (AccessibleRole.DESKTOP_ICON), "DESKTOP_ICON");
221         maRoleMap.put (new Integer (AccessibleRole.DESKTOP_PANE), "DESKTOP_PANE");
222         maRoleMap.put (new Integer (AccessibleRole.DIRECTORY_PANE), "DIRECTORY_PANE");
223         maRoleMap.put (new Integer (AccessibleRole.DIALOG), "DIALOG");
224         maRoleMap.put (new Integer (AccessibleRole.DOCUMENT), "DOCUMENT");
225         maRoleMap.put (new Integer (AccessibleRole.EMBEDDED_OBJECT), "EMBEDDED_OBJECT");
226         maRoleMap.put (new Integer (AccessibleRole.END_NOTE), "END_NOTE");
227         maRoleMap.put (new Integer (AccessibleRole.FILE_CHOOSER), "FILE_CHOOSER");
228         maRoleMap.put (new Integer (AccessibleRole.FILLER), "FILLER");
229         maRoleMap.put (new Integer (AccessibleRole.FONT_CHOOSER), "FONT_CHOOSER");
230         maRoleMap.put (new Integer (AccessibleRole.FOOTER), "FOOTER");
231         maRoleMap.put (new Integer (AccessibleRole.FOOTNOTE), "FOOTNOTE");
232         maRoleMap.put (new Integer (AccessibleRole.FRAME), "FRAME");
233         maRoleMap.put (new Integer (AccessibleRole.GLASS_PANE), "GLASS_PANE");
234         maRoleMap.put (new Integer (AccessibleRole.GRAPHIC), "GRAPHIC");
235         maRoleMap.put (new Integer (AccessibleRole.GROUP_BOX), "GROUP_BOX");
236         maRoleMap.put (new Integer (AccessibleRole.HEADER), "HEADER");
237         maRoleMap.put (new Integer (AccessibleRole.HEADING), "HEADING");
238         maRoleMap.put (new Integer (AccessibleRole.HYPER_LINK), "HYPER_LINK");
239         maRoleMap.put (new Integer (AccessibleRole.ICON), "ICON");
240         maRoleMap.put (new Integer (AccessibleRole.INTERNAL_FRAME), "INTERNAL_FRAME");
241         maRoleMap.put (new Integer (AccessibleRole.LABEL), "LABEL");
242         maRoleMap.put (new Integer (AccessibleRole.LAYERED_PANE), "LAYERED_PANE");
243         maRoleMap.put (new Integer (AccessibleRole.LIST), "LIST");
244         maRoleMap.put (new Integer (AccessibleRole.LIST_ITEM), "LIST_ITEM");
245         maRoleMap.put (new Integer (AccessibleRole.MENU), "MENU");
246         maRoleMap.put (new Integer (AccessibleRole.MENU_BAR), "MENU_BAR");
247         maRoleMap.put (new Integer (AccessibleRole.MENU_ITEM), "MENU_ITEM");
248         maRoleMap.put (new Integer (AccessibleRole.OPTION_PANE), "OPTION_PANE");
249         maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB), "PAGE_TAB");
250         maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB_LIST), "PAGE_TAB_LIST");
251         maRoleMap.put (new Integer (AccessibleRole.PANEL), "PANEL");
252         maRoleMap.put (new Integer (AccessibleRole.PARAGRAPH), "PARAGRAPH");
253         maRoleMap.put (new Integer (AccessibleRole.PASSWORD_TEXT), "PASSWORD_TEXT");
254         maRoleMap.put (new Integer (AccessibleRole.POPUP_MENU), "POPUP_MENU");
255         maRoleMap.put (new Integer (AccessibleRole.PUSH_BUTTON), "PUSH_BUTTON");
256         maRoleMap.put (new Integer (AccessibleRole.PROGRESS_BAR), "PROGRESS_BAR");
257         maRoleMap.put (new Integer (AccessibleRole.RADIO_BUTTON), "RADIO_BUTTON");
258         maRoleMap.put (new Integer (AccessibleRole.RADIO_MENU_ITEM), "RADIO_MENU_ITEM");
259         maRoleMap.put (new Integer (AccessibleRole.ROW_HEADER), "ROW_HEADER");
260         maRoleMap.put (new Integer (AccessibleRole.ROOT_PANE), "ROOT_PANE");
261         maRoleMap.put (new Integer (AccessibleRole.SCROLL_BAR), "SCROLL_BAR");
262         maRoleMap.put (new Integer (AccessibleRole.SCROLL_PANE), "SCROLL_PANE");
263         maRoleMap.put (new Integer (AccessibleRole.SHAPE), "SHAPE");
264         maRoleMap.put (new Integer (AccessibleRole.SEPARATOR), "SEPARATOR");
265         maRoleMap.put (new Integer (AccessibleRole.SLIDER), "SLIDER");
266         maRoleMap.put (new Integer (AccessibleRole.SPIN_BOX), "SPIN_BOX");
267         maRoleMap.put (new Integer (AccessibleRole.SPLIT_PANE), "SPLIT_PANE");
268         maRoleMap.put (new Integer (AccessibleRole.STATUS_BAR), "STATUS_BAR");
269         maRoleMap.put (new Integer (AccessibleRole.TABLE), "TABLE");
270         maRoleMap.put (new Integer (AccessibleRole.TABLE_CELL), "TABLE_CELL");
271         maRoleMap.put (new Integer (AccessibleRole.TEXT), "TEXT");
272         maRoleMap.put (new Integer (AccessibleRole.TEXT_FRAME), "TEXT_FRAME");
273         maRoleMap.put (new Integer (AccessibleRole.TOGGLE_BUTTON), "TOGGLE_BUTTON");
274         maRoleMap.put (new Integer (AccessibleRole.TOOL_BAR), "TOOL_BAR");
275         maRoleMap.put (new Integer (AccessibleRole.TOOL_TIP), "TOOL_TIP");
276         maRoleMap.put (new Integer (AccessibleRole.TREE), "TREE");
277         maRoleMap.put (new Integer (AccessibleRole.VIEW_PORT), "VIEW_PORT");
278         maRoleMap.put (new Integer (AccessibleRole.WINDOW), "WINDOW");
279 
280         maRelationMap.put (new Integer (AccessibleRelationType.INVALID), "INVALID");
281         maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_FROM), "CONTENT_FLOWS_FROM");
282         maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_TO), "CONTENT_FLOWS_TO");
283         maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLED_BY), "CONTROLLED_BY");
284         maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLER_FOR), "CONTROLLER_FOR");
285         maRelationMap.put (new Integer (AccessibleRelationType.LABEL_FOR), "LABEL_FOR");
286         maRelationMap.put (new Integer (AccessibleRelationType.LABELED_BY), "LABELED_BY");
287         maRelationMap.put (new Integer (AccessibleRelationType.MEMBER_OF), "MEMBER_OF");
288         maRelationMap.put (new Integer (AccessibleRelationType.SUB_WINDOW_OF), "SUB_WINDOW_OF");
289     }
290 }
291