Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to set input on browser widget synchronously?
How to set input on browser widget synchronously? [message #463103] Wed, 26 October 2005 13:45 Go to next message
Stefan   is currently offline Stefan Friend
Messages: 5
Registered: July 2009
Junior Member
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 #463116 is a reply to message #463103] Wed, 26 October 2005 20:42 Go to previous messageGo to next message
Gordon Hirsch is currently offline Gordon HirschFriend
Messages: 100
Registered: July 2009
Senior Member
Could you add a progress listener (through Browser.addProgressListener)
that waits for the load to complete?

http://help.eclipse.org/help31/nftopic/org.eclipse.platform. doc.isv/reference/api/org/eclipse/swt/browser/Browser.html#a ddProgressListener(org.eclipse.swt.browser.ProgressListener)

Stefan Mücke wrote:
> 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 17:42 Go to previous message
Stefan   is currently offline Stefan Friend
Messages: 5
Registered: July 2009
Junior Member
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.
Previous Topic:Finding the right parent for a SWT Shell
Next Topic:Content Assist help
Goto Forum:
  


Current Time: Fri Apr 19 06:09:55 GMT 2024

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

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

Back to the top