KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > actions > ControlAccessibleListener


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui.actions;
12
13 import org.eclipse.swt.accessibility.AccessibleAdapter;
14 import org.eclipse.swt.accessibility.AccessibleEvent;
15 import org.eclipse.swt.widgets.Control;
16
17 public class ControlAccessibleListener extends AccessibleAdapter {
18     private String JavaDoc controlName;
19     
20     public ControlAccessibleListener(String JavaDoc name) {
21         controlName = name;
22     }
23
24     public void getName(AccessibleEvent e) {
25         e.result = controlName;
26     }
27
28     public static void addListener(Control comp, String JavaDoc name) {
29         //strip mnemonic
30
String JavaDoc[] strs = name.split("&"); //$NON-NLS-1$
31
StringBuffer JavaDoc stripped = new StringBuffer JavaDoc();
32         for (int i = 0; i < strs.length; i++) {
33             stripped.append(strs[i]);
34         }
35         comp.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString()));
36     }
37 }
38
Popular Tags