Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363218

Summary: AbstractHyperlink should call setFocus before calling linkActivated listeners
Product: [Eclipse Project] Platform Reporter: Carolyn MacLeod <carolynmacleod4>
Component: User AssistanceAssignee: platform-ua-inbox <platform-ua-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Carolyn MacLeod CLA 2011-11-08 14:30:32 EST
In the ui.forms.widgets.AbstractHyperlink.handleActivate() method, triggerAccessible() is called after calling the linkActivated listeners.

This is causing the problem described in this IBM Forums thread: http://ibmforums.ibm.com/forums/message.jspa?messageID=2002027&tstart=0

i.e. the AbstractHyperlink is stealing the accessibility focus back from a dialog that is opened in a linkActivated listener.

I think triggerAccessible() should be called before calling the listeners.
Comment 1 Carolyn MacLeod CLA 2011-11-15 11:15:53 EST
Here is a simple JFace snippet for testing.
This fails in the manner described in the forum post.

import org.eclipse.jface.dialogs.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Snippet012BasicPopupDialogAccessibility {
	
	public static void main(String[] args) {
		
		Display display = new Display ();
		final Shell shell = new Shell(display);
		shell.setLayout(new GridLayout());
		Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
		text.setText("This is a text edit field.");
		Button button = new Button(shell, SWT.PUSH);
		button.setText("Open");
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				PopupDialog testDialog = new PopupDialog(shell,PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE,false,false,false,false,false,"Testing!","This is a test");
				testDialog.open();
			}
		});
		shell.pack();
		shell.open ();
		
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		
		display.dispose ();
	}
}
Comment 2 Carolyn MacLeod CLA 2011-11-15 11:44:03 EST
This is a user error. Changing false to true in the following line fixes this:

                PopupDialog testDialog = new
PopupDialog(shell,PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE,true,false,false,false,false,"Testing!","This is a test");

This is because the third parameter to the PopupDialog constructor is:
	 * @param takeFocusOnOpen
	 *            A boolean indicating whether focus should be taken by this
	 *            popup when it opens.

Closing this bug as "Works for me".