I have created some swt text controls in eclipse RCP forms in an editor.When
i save the contents in the editor , if there is an error in some entered
value in texts controls then an error code is returned depending upon type
of error. Each error code corresponds to specific text control.I show a info
dialog box showing description of the error and then depending upon error
code i want to set the focus to appropriate text control.
When i save the editor , editor saves its state ie.control on which last
focus is.After saving the editor ,the editor state is restored ie.focus is
set again on the control which has last focus.When i use setFocus() method
to my control it doesnt work ie.it returns false.Editor sets its focus again
to last focus control.
How do i manually set focus to a control so that editor won't set it to last
I had the same problem as you.
I think the problem is that your text control runs in a different thread than your validation method. Probably you try to set the focus from within that validation method. So if you try to change the state of the control you access a different thread.
To set the focus as desired you should do the following to "enter" the thread of the Control:
final Text txtCtrlWithInvalidContent = get...
if (txtCtrlWithInvalidContent != null)
public void run()