How to set input on browser widget synchronously? [message #463103] |
Wed, 26 October 2005 09:45  |
Eclipse User |
|
|
|
Hi,
I am calling the execute method on a browser widget after calling its
input method. As the excute methods depends on the DOM tree, I have to
wait for the browser to complete loading the input. So far I've used a
LocationChangedListener to achieve this.
public void showSomeInfo() {
browser.setInput("<html>...</html>")
isLoading = true;
waitForBrowser();
browser.execute(highlightScript);
}
private void waitForBrowser() {
while (isLoading) {
if (!display.readAndDispatch())
display.sleep();
}
}
public void changed(LocationEvent event) {
isLoading = false;
}
The problem here is that waitForBrowser() reads the event loop, causing
some others
events to be processed too early.
(My scenario: A listener list is iterated, with one listener calling
showSomeInfo(). The call to showSomeInfo() results in some messages
being processed. When showSomeInfo() returns, the listener list has been
changed by some event, resulting in a ConcurrentModificationException
being thrown.)
Is there any other way (or trick) to wait for the setInput(..) method to
complete without using display.readAndDispatch()?
Many thanks in advance,
Stefan Mücke
|
|
|
|
Re: How to set input on browser widget synchronously? [message #463132 is a reply to message #463116] |
Thu, 27 October 2005 13:42  |
Eclipse User |
|
|
|
Thanks for your reply.
> Could you add a progress listener (through Browser.addProgressListener)
> that waits for the load to complete?
Unfortunately this does not work because both types of listeners are notified/triggered through the same mechanism, namely messages fetched via Display.readAndDispatch(). So I need a
solution to wait for the browser to complete without reading any messages from the message queue. Presumably there's no solution without the SWT code being changed. :-(
Thanks anyhow.
|
|
|
Powered by
FUDForum. Page generated in 0.03743 seconds