name = items[childID].getText(); int index = name.indexOf('&'); if (index > 0) { name = name.substring(0, index) + name.substring(index + 1); }
name = stripMnemonic(items[childID].getText());
void initAccessible() {	final Accessible accessible = getAccessible();	accessible.addAccessibleListener(new AccessibleAdapter() {		public void getName(AccessibleEvent e) {			String name = null;			int childID = e.childID;			if (childID >= 0 && childID < items.length) {				name = items[childID].getText();				int index = name.indexOf('&');				if (index > 0) {					name = name.substring(0, index) + name.substring(index + 1);				}			} else if (childID == items.length + CHEVRON_CHILD_ID) {				name = SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$			} else if (childID == items.length + MINIMIZE_CHILD_ID) {				name = minimized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Minimize"); //$NON-NLS-1$ //$NON-NLS-2$			} else if (childID == items.length + MAXIMIZE_CHILD_ID) {				name = maximized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Maximize"); //$NON-NLS-1$ //$NON-NLS-2$			}			e.result = name;		}		public void getHelp(AccessibleEvent e) {			String help = null;			int childID = e.childID;			if (childID == ACC.CHILDID_SELF) {				help = getToolTipText();			} else if (childID >= 0 && childID < items.length) {				help = items[childID].getToolTipText();			}			e.result = help;		}				public void getKeyboardShortcut(AccessibleEvent e) {			String shortcut = null;			int childID = e.childID;			if (childID >= 0 && childID < items.length) {				String text = items[childID].getText();				if (text != null) {					char mnemonic = _findMnemonic(text);						if (mnemonic != '\0') {						shortcut = "Alt+"+mnemonic; //$NON-NLS-1$					}				}			}			e.result = shortcut;		}	});		accessible.addAccessibleControlListener(new AccessibleControlAdapter() {		public void getChildAtPoint(AccessibleControlEvent e) {			Point testPoint = toControl(e.x, e.y);			int childID = ACC.CHILDID_NONE;			for (int i = 0; i < items.length; i++) {				if (items[i].getBounds().contains(testPoint)) {					childID = i;					break;				}			}			if (childID == ACC.CHILDID_NONE) {				if (showChevron && chevronRect.contains(testPoint)) {					childID = items.length + CHEVRON_CHILD_ID;				} else if (showMin && minRect.contains(testPoint)) {					childID = items.length + MINIMIZE_CHILD_ID;				} else if (showMax && maxRect.contains(testPoint)) {					childID = items.length + MAXIMIZE_CHILD_ID;				} else {					Rectangle location = getBounds();					location.height = location.height - getClientArea().height;					if (location.contains(testPoint)) {						childID = ACC.CHILDID_SELF;					}				}			}			e.childID = childID;		}				public void getLocation(AccessibleControlEvent e) {			Rectangle location = null;			int childID = e.childID;			if (childID == ACC.CHILDID_SELF) {				location = getBounds();			} else if (childID >= 0 && childID < items.length) {				location = items[childID].getBounds();			} else if (showChevron && childID == items.length + CHEVRON_CHILD_ID) {				location = chevronRect;			} else if (showMin && childID == items.length + MINIMIZE_CHILD_ID) {				location = minRect;			} else if (showMax && childID == items.length + MAXIMIZE_CHILD_ID) {				location = maxRect;			}			if (location != null) {				Point pt = toDisplay(location.x, location.y);				e.x = pt.x;				e.y = pt.y;				e.width = location.width;				e.height = location.height;			}		}				public void getChildCount(AccessibleControlEvent e) {			e.detail = items.length + EXTRA_CHILD_ID_COUNT;		}				public void getDefaultAction(AccessibleControlEvent e) {			String action = null;			int childID = e.childID;			if (childID >= 0 && childID < items.length) {				action = SWT.getMessage ("SWT_Switch"); //$NON-NLS-1$			}			if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT) {				action = SWT.getMessage ("SWT_Press"); //$NON-NLS-1$			}			e.result = action;		}		public void getFocus(AccessibleControlEvent e) {			int childID = ACC.CHILDID_NONE;			if (isFocusControl()) {				if (selectedIndex == -1) {					childID = ACC.CHILDID_SELF;				} else {					childID = selectedIndex;				}			}			e.childID = childID;		}		public void getRole(AccessibleControlEvent e) {			int role = 0;			int childID = e.childID;			if (childID == ACC.CHILDID_SELF) {				role = ACC.ROLE_TABFOLDER;			} else if (childID >= 0 && childID < items.length) {				role = ACC.ROLE_TABITEM;			} else if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT) {				role = ACC.ROLE_PUSHBUTTON;			}			e.detail = role;		}				public void getSelection(AccessibleControlEvent e) {			e.childID = (selectedIndex == -1) ? ACC.CHILDID_NONE : selectedIndex;		}				public void getState(AccessibleControlEvent e) {			int state = 0;			int childID = e.childID;			if (childID == ACC.CHILDID_SELF) {				state = ACC.STATE_NORMAL;			} else if (childID >= 0 && childID < items.length) {				state = ACC.STATE_SELECTABLE;				if (isFocusControl()) {					state |= ACC.STATE_FOCUSABLE;				}				if (selectedIndex == childID) {					state |= ACC.STATE_SELECTED;					if (isFocusControl()) {						state |= ACC.STATE_FOCUSED;					}				}			} else if (childID == items.length + CHEVRON_CHILD_ID) {				state = showChevron ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;			} else if (childID == items.length + MINIMIZE_CHILD_ID) {				state = showMin ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;;			} else if (childID == items.length + MAXIMIZE_CHILD_ID) {				state = showMax ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;;			}			e.detail = state;		}				public void getChildren(AccessibleControlEvent e) {			int childIdCount = items.length + EXTRA_CHILD_ID_COUNT;			Object[] children = new Object[childIdCount];			for (int i = 0; i < childIdCount; i++) {				children[i] = new Integer(i);			}			e.children = children;		}	});		addListener(SWT.Selection, new Listener() {		public void handleEvent(Event event) {			if (isFocusControl()) {				if (selectedIndex == -1) {					accessible.setFocus(ACC.CHILDID_SELF);				} else {					accessible.setFocus(selectedIndex);				}			}		}	});	addListener(SWT.FocusIn, new Listener() {		public void handleEvent(Event event) {			if (selectedIndex == -1) {				accessible.setFocus(ACC.CHILDID_SELF);			} else {				accessible.setFocus(selectedIndex);			}		}	});}