Java源码示例:org.eclipse.swt.accessibility.Accessible

示例1
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;
}
 
示例2
/**
 * Returns the accessible object for the receiver.
 * If this is the first time this object is requested,
 * then the object is created and returned.
 *
 * @return the accessible object
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 * 
 * @see Accessible#addAccessibleListener
 * @see Accessible#addAccessibleControlListener
 * 
 * @since 3.3
 */
@Override
public Accessible getAccessible() {
    return fList.getAccessible();
}