Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Why does DialogField.postSetFocusOnDialogField exist?
Why does DialogField.postSetFocusOnDialogField exist? [message #257243] Thu, 06 November 2008 08:12 Go to next message
Eclipse UserFriend
Hi all,

I've been looking at the JDT as a good source of examples when developing
my own plugin and come across something that I can't see explained
anywhere.

In org.eclipse.jdt.internal.ui.wizards.dialogfields, why does:

DialogField.postSetFocusOnDialogField(Display)

Set the focus of a field asynchronously?

It seems to work fine if you just call DialogField.setFocus() instead and
postSetFocusOnDialogField(Display) seems to be called from the main event
dispatch thread anyway, so I was wondering why this call even exists.

From my experiments so far, there seems to be no benefit but there is a
lot of "seems to" in what I've just written and my guess is it must be
done like that for a reason.

Can anyone enlighten me?

Thanks,
Mat
Re: Why does DialogField.postSetFocusOnDialogField exist? [message #257247 is a reply to message #257243] Thu, 06 November 2008 10:41 Go to previous message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

"Mat Booth" <eclipse@matbooth.co.uk> wrote in message
news:a2d6ff402c54c2ca669da8f6597d5d6e$1@www.eclipse.org...
> Hi all,
>
> I've been looking at the JDT as a good source of examples when developing
> my own plugin and come across something that I can't see explained
> anywhere.
>
> In org.eclipse.jdt.internal.ui.wizards.dialogfields, why does:
>
> DialogField.postSetFocusOnDialogField(Display)
>
> Set the focus of a field asynchronously?
>
> It seems to work fine if you just call DialogField.setFocus() instead and
> postSetFocusOnDialogField(Display) seems to be called from the main event
> dispatch thread anyway, so I was wondering why this call even exists.
>
> From my experiments so far, there seems to be no benefit but there is a
> lot of "seems to" in what I've just written and my guess is it must be
> done like that for a reason.
>
> Can anyone enlighten me?
>
> Thanks,
> Mat
>
I don't know specifically why this method exists. However, I can think of a
couple of reasons.

The method can be used by code that is runs on a thread other than the main
event dispatch thread for the specified Display.

The method will insure that focus events queued up on the event dispatch
thread don't shift the focus elsewhere. Platform differences can have an
effect on the order that related events are placed on the event dispatch
thread. Posting the setFocus call to the end of the event queue insures
that processing occurs after all related events are processed.
Previous Topic:Is there a way to "Replace the changes from right to Left" in the Compare editor
Next Topic:Preventing Eclipse from showing the currently opened file in the title
Goto Forum:
  


Current Time: Sat Apr 26 05:12:35 EDT 2025

Powered by FUDForum. Page generated in 0.03022 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top