/** * Get the accessible listener for the tool bar. * * @return AccessibleListener * * @since 3.1 */ private AccessibleListener getAccessibleListener() { return new AccessibleAdapter() { public void getName(AccessibleEvent e) { if (e.childID != ACC.CHILDID_SELF) { ToolItem item = toolBar.getItem(e.childID); if (item != null) { String toolTip = item.getToolTipText(); if (toolTip != null) { e.result = toolTip; } } } } }; }
/** * Specifically set the reporting name of a control for accessibility */ private void setAccessible( Control control, String name ) { if ( control == null ) return; final String n = name; control.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { if ( e.childID == ACC.CHILDID_SELF ) e.result = n; } } ); }
private void initButton(Image im, final String tt) { toolButton.setImage(im); toolButton.setToolTipText(tt); toolbar.setVisible(true); toolbar.getParent().layout(); // must layout toolbar.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = tt; } }); }
/** * Specifically set the reporting name of a control for accessibility */ private void setAccessible(Control control, String name) { if (control == null) return; final String n = name; control.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { if (e.childID == ACC.CHILDID_SELF) e.result = n; } }); }
/** * Adds an accessibility listener returning the given fixed name. * * @param control * the control to add the accessibility support to * @param text * the name */ public static void setAccessibilityText(Control control, final String text) { control.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = text; } }); }
/** * Adds an accessibility listener returning the given fixed name. * * @param control the control to add the accessibility support to * @param text the name */ public static void setAccessibilityText(Control control, final String text) { control.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { if (e.childID == ACC.CHILDID_SELF) { e.result= text; } } }); }
private void addAccessibleListeners(Label label, final Image image) { label.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent event) { final String accessibleMessage = getAccessibleMessageFor(image); if (accessibleMessage == null) { return; } event.result = accessibleMessage; } }); }
/** * Add an accessible listener to the label if it can be inferred from the * image. * * @param label * @param image */ private void addAccessibleListeners(Label label, final Image image) { label.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent event) { final String accessibleMessage = getAccessibleMessageFor(image); if (accessibleMessage == null) { return; } event.result = accessibleMessage; } }); }
/** * Add specified description to composite to support Screen Reader tool. * * @param composite composite * @param description description */ public static void addScreenReaderAccessbility( Control composite, final String description ) { if ( composite == null ) { // if control component is null, do nothing. return; } if ( description != null ) { if ( composite instanceof Spinner ) { addSpinnerScreenReaderAccessbility( (Spinner) composite, description ); } else { composite.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { e.result = description.replaceAll( "&", IConstants.EMPTY_STRING ) //$NON-NLS-1$ .replaceAll( ":", IConstants.EMPTY_STRING ) //$NON-NLS-1$ .replaceAll( "\\*", IConstants.EMPTY_STRING ); //$NON-NLS-1$ } } ); } } }
private void setAccessibilityText( Control control, final String text ) { control.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { e.result = text; } } ); }
private void setAccessible (final Control control) { if ( control instanceof Composite ) { Composite parent = (Composite)control; if ( parent != null && parent.getTabList( ) != null ) { Control[] children = parent.getTabList( ); for ( int i = 0; i < children.length; i++ ) { setAccessible( children[i] ); } } } else { control.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { Label lbl = getLabelControl( ); if ( lbl != null ) { if (control instanceof Text) { e.result = UIUtil.stripMnemonic( getLabelControl( ).getText( )) + ((Text) control).getText(); } } } } ); } }
private void setAccessible( final Control control ) { if ( control instanceof Composite ) { Composite parent = (Composite) control; if ( parent != null && parent.getTabList( ) != null ) { Control[] children = parent.getTabList( ); for ( int i = 0; i < children.length; i++ ) { setAccessible( children[i] ); } } } else { control.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { Label lbl = getLabelControl( ); if ( lbl != null ) { if (control instanceof Text) { e.result = UIUtil.stripMnemonic( getLabelControl( ).getText( ) ) + ((Text) control).getText( ); } } } } ); } }
private void setAccessible (final Control control) { if ( control instanceof Composite ) { Composite parent = (Composite)control; if ( parent != null && parent.getTabList( ) != null ) { Control[] children = parent.getTabList( ); for ( int i = 0; i < children.length; i++ ) { setAccessible( children[i] ); } } } else { control.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { Label lbl = getLabelControl( ); if ( lbl != null ) { if (control instanceof Button) { e.result = UIUtil.stripMnemonic( getLabelControl( ).getText( )) + JFaceResources.getString( "ColorSelector.Name" ); //$NON-NLS-1$ } else if (control instanceof Text) { e.result = UIUtil.stripMnemonic( getLabelControl( ).getText( )) + ((Text) control).getText( ); } } } } ); } }
private void setAccessible( Control control ) { if ( control instanceof Composite ) { Composite parent = (Composite)control; if ( parent != null && parent.getTabList( ) != null ) { Control[] children = parent.getTabList( ); for ( int i = 0; i < children.length; i++ ) { setAccessible( children[i] ); } } } else { control.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { Label lbl = getLabelControl( ); if ( lbl != null ) { e.result = UIUtil.stripMnemonic( getLabelControl( ).getText( )) + fontSize.getFontSizeValue( ); } } } ); } }
private void setAccessible(final Control control) { if ( control instanceof Composite ) { Composite parent = (Composite)control; if ( parent != null && parent.getTabList( ) != null ) { Control[] children = parent.getTabList( ); for ( int i = 0; i < children.length; i++ ) { setAccessible( children[i] ); } } } else { control.getAccessible( ) .addAccessibleListener( new AccessibleAdapter( ) { public void getName( AccessibleEvent e ) { if ( control instanceof Text && control.getParent( ) instanceof ExpressionComposite ) { e.result = UIUtil.stripMnemonic(Messages.getString( "VisibilityPage.Label.Expression" )) + ((Text)control).getText( ); //$NON-NLS-1$ } } } ); } }
/** * Adds an accessibility listener returning the given fixed name. * * @param control the control to add the accessibility support to * @param text the name */ public static void setAccessibilityText(Control control, final String text) { control.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { if (e.childID == ACC.CHILDID_SELF) { e.result = text; } } }); }
private Button createFeatureButton(Composite parent, final AboutBundleGroupData info) { if (!buttonManager.add(info)) { return null; } final ImageDescriptor desc = info.getFeatureImage(); Image featureImage = null; final Button button = new Button(parent, SWT.FLAT | SWT.PUSH); button.setData(info); featureImage = desc.createImage(); images.add(featureImage); button.setImage(featureImage); button.setToolTipText(info.getProviderName()); button.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = info.getProviderName(); } }); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { final AboutBundleGroupData[] groupInfos = buttonManager .getRelatedInfos(info); final AboutBundleGroupData selection = (AboutBundleGroupData) event.widget .getData(); final AboutFeaturesDialog d = new AboutFeaturesDialog( getShell(), productName, groupInfos, selection); d.open(); } }); return button; }
@Override protected void createContents_all(Composite topControl) { super.createContents_all(topControl); text.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = LangUIMessages.LangArgumentsTab_Program_Arguments; } }); // need to strip the mnemonic from buttons: ControlAccessibleListener.addControlAccessibleListener(button, button.getText()); }
private void addAccessibilityHooks(Control parentControl) { parentControl.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getHelp(AccessibleEvent e) { e.result = tooltipText; } }); }
protected void setAccessibilityName(final String name) { getAccessible().addAccessibleListener (new AccessibleAdapter() { public void getName(AccessibleEvent e) { e.result = name; } }); }
public Control createPart(Composite parent) { Composite commonArea = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(commonArea); GridDataFactory.fillDefaults().grab(true, true).applyTo(commonArea); Composite tableParent = new Composite(commonArea, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tableParent); GridDataFactory.fillDefaults().grab(true, true).applyTo(tableParent); Table table = new Table(tableParent, SWT.BORDER | SWT.MULTI); GridDataFactory.fillDefaults().grab(true, true).applyTo(table); envVariablesViewer = new TableViewer(table); Listener actionEnabler = new Listener() { @Override public void handleEvent(Event event) { setEnabledDisabled(); } }; table.addListener(SWT.Selection, actionEnabler); table.addListener(SWT.FocusOut, actionEnabler); envVariablesViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { if (inputElement instanceof Collection) { return ((Collection<?>) inputElement).toArray(new Object[0]); } return null; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); envVariablesViewer.setLabelProvider(new EnvVarLabelProvider(envVariablesViewer)); table.setHeaderVisible(true); new TableResizeHelper(envVariablesViewer).enableResizing(); int columnIndex = 0; ViewColumn[] columns = ViewColumn.values(); String[] columnProperties = new String[columns.length]; for (ViewColumn column : columns) { columnProperties[columnIndex] = column.name(); TableColumn tableColumn = new TableColumn(table, SWT.NONE, columnIndex++); tableColumn.setData(column); tableColumn.setText(column.getUserFacingName()); tableColumn.setWidth(column.getWidth()); } envVariablesViewer.setColumnProperties(columnProperties); // Add accessibility listener to the table, so screen reader can provide a good description // of what is selected (in this case, an environment variable and its name) envVariablesViewer.getControl().getAccessible ().addAccessibleListener (new AccessibleAdapter() { @Override public void getName (AccessibleEvent e) { if (e.childID >= 0) { if (e.result != null) { e.result = NLS.bind(Messages.EnvironmentVariablesPart_TEXT_TABLE_ACC_LABEL, e.result); } else { e.result = Messages.COMMONTXT_ENV_VAR; } } } }); addEditButtons(commonArea); return commonArea; }
public Control createControl( Composite parent ) { container = new Composite( parent, SWT.NONE ); RowLayout layout = new RowLayout( SWT.HORIZONTAL ); layout.marginBottom = 0; layout.marginHeight = 0; layout.marginLeft = 0; layout.marginRight = 0; layout.marginTop = 0; layout.marginWidth = 0; layout.spacing = 0; container.setLayout( layout ); left = FormWidgetFactory.getInstance( ).createButton( container, SWT.TOGGLE, false ); left.setToolTipText( Messages.getString( "TextAlignPropertyDescriptor.0" ) ); //$NON-NLS-1$ center = FormWidgetFactory.getInstance( ).createButton( container, SWT.TOGGLE, false ); center.setToolTipText( Messages.getString( "TextAlignPropertyDescriptor.1" ) ); //$NON-NLS-1$ right = FormWidgetFactory.getInstance( ).createButton( container, SWT.TOGGLE, false ); right.setToolTipText( Messages.getString( "TextAlignPropertyDescriptor.2" ) ); //$NON-NLS-1$ justify = FormWidgetFactory.getInstance( ).createButton( container, SWT.TOGGLE, false ); justify.setToolTipText( Messages.getString( "TextAlignPropertyDescriptor.3" ) ); //$NON-NLS-1$ Button[] btns = { left, center, right, justify, }; // The value is used to present active value and image key. String[] values = { DesignChoiceConstants.TEXT_ALIGN_LEFT, DesignChoiceConstants.TEXT_ALIGN_CENTER, DesignChoiceConstants.TEXT_ALIGN_RIGHT, DesignChoiceConstants.TEXT_ALIGN_JUSTIFY, }; for ( int i = 0; i < btns.length; i++ ) { btns[i].setData( values[i] ); btns[i].addSelectionListener( listener ); btns[i].getAccessible( ).addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { Accessible accessible = (Accessible) e.getSource(); Button item = (Button) accessible.getControl(); if (item != null) { e.result = item.getToolTipText(); } } }); } return container; }