Java 类org.eclipse.swt.accessibility.AccessibleAdapter 实例源码

项目:gef-gwt    文件:ToolBarManager.java   
/**
 * 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;
                    }
                }
            }
        }
    };

}
项目:birt    文件:ExpressionSyntaxColoringPage.java   
/**
 * 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;
                }
            } );
}
项目:termsuite-ui    文件:ProgressAnimationItem.java   
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;
        }
       });
}
项目:angular-eclipse    文件:HTMLAngularEditorSyntaxColoringPreferencePage.java   
/**
 * 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;
        }
    });
}
项目:bts    文件:SWTUtil.java   
/**
 * 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;
        }
    });
}
项目:eclipse-wtp-json    文件:JSONSyntaxColoringPage.java   
/**
 * 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;
        }
    });
}
项目:Eclipse-Postfix-Code-Completion    文件:SWTUtil.java   
/**
 * 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;
            }
        }
    });
}
项目:translationstudio8    文件:CustomMessageDialog.java   
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;
        }
    });
}
项目:gef-gwt    文件:IconAndMessageDialog.java   
/**
 * 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;
        }
    });
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SWTUtil.java   
/**
 * 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;
            }
        }
    });
}
项目:tmxeditor8    文件:CustomMessageDialog.java   
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;
        }
    });
}
项目:birt    文件:ChartUIUtil.java   
/**
 * 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$
                        }
                    } );
        }

    }
}
项目:birt    文件:BreadcrumbItemDropDown.java   
private void setAccessibilityText( Control control, final String text )
{
    control.getAccessible( )
            .addAccessibleListener( new AccessibleAdapter( ) {

                public void getName( AccessibleEvent e )
                {
                    e.result = text;
                }
            } );
}
项目:birt    文件:MarignSection.java   
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();
                            }
                        }
                    }

                } );
    }
}
项目:birt    文件:ComplexUnitSection.java   
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( );
                            }
                        }
                    }

                } );
    }
}
项目:birt    文件:ColorSection.java   
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( );
                            }
                        }
                    }

                } );
    }
}
项目:birt    文件:FontSizeSection.java   
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( );
                        }
                    }

                } );
    }
}
项目:birt    文件:OutputSection.java   
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$
                        }
                    }
                } );
    }
}
项目:Pydev    文件:SWTUtil.java   
/**
 * 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;
            }
        }
    });
}
项目:angularjs-eclipse    文件:HTMLAngularEditorSyntaxColoringPreferencePage.java   
/**
 * 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;
        }
    });
}
项目:eclipse-silverstripedt    文件:SilverStripeSyntaxColoringPage.java   
/**
 * 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;
        }
    });
}
项目:relations    文件:AboutDialog.java   
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;
}
项目:goclipse    文件:LangArgumentsBlock2.java   
@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());
}
项目:swt-bling    文件:Bubble.java   
private void addAccessibilityHooks(Control parentControl) {
  parentControl.getAccessible().addAccessibleListener(new AccessibleAdapter() {
    public void getHelp(AccessibleEvent e) {
      e.result = tooltipText;
    }
  });
}
项目:swt-bling    文件:SquareButton.java   
protected void setAccessibilityName(final String name) {
  getAccessible().addAccessibleListener
          (new AccessibleAdapter() {
            public void getName(AccessibleEvent e) {
              e.result = name;
            }
          });
}
项目:cft    文件:EnvironmentVariablesPart.java   
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;
}
项目:birt    文件:FontAlignPropertyDescriptor.java   
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;
}