1 /*******************************************************************************
2  * Copyright (c) 2003, 2011 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.jdt.internal.debug.ui.actions;
15 
16 import org.eclipse.swt.accessibility.AccessibleAdapter;
17 import org.eclipse.swt.accessibility.AccessibleEvent;
18 import org.eclipse.swt.widgets.Control;
19 
20 public class ControlAccessibleListener extends AccessibleAdapter {
21 	private String controlName;
22 
ControlAccessibleListener(String name)23 	public ControlAccessibleListener(String name) {
24 		controlName = name;
25 	}
26 
27 	@Override
getName(AccessibleEvent e)28 	public void getName(AccessibleEvent e) {
29 		e.result = controlName;
30 	}
31 
addListener(Control comp, String name)32 	public static void addListener(Control comp, String name) {
33 		//strip mnemonic
34 		StringBuilder stripped = new StringBuilder();
35 		for (String str : name.split("&")) { //$NON-NLS-1$
36 			stripped.append(str);
37 		}
38 		comp.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString()));
39 	}
40 }
41