Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » browser.setUrl freeze
browser.setUrl freeze [message #518368] Wed, 03 March 2010 21:59 Go to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hello,
I have swt.browser with xulrunner (swt-3.6M5-gtk-linux-x86_64, xulrunner-sdk-1.9.1.3-linux-x86_64 - my own build). I render the page and get all links from the page as String[]. Now I want to render all pages the links refer to. So I made my own ProgressListener which takes link one by one and calls browser.setUrl() in its completed method. The trouble is that the rendering freezes. The ProgressListener is not noticed again until I move with the cursor or invoke any other system event. What am I doing wrong? I am not sure if its swt-xulrunner or OS problem? I am using Ubuntu 9.10 x86_64.

Most important part of my code is attached.

Thanks a lot for any help.

My code:

public class Test {

//swt
private Shell shell;
private Display display;
private Label status;
private Browser browser;
private ExtractLocationListener extractLocListener;
private RebuildLocationListener rebuildLocListener;
private AdvancedStatusTextListener statusListener;
private Text url;
private Button backButton;
private Button refreshButton;
private Button forwardButton;
private Button stopButton;
private Button goButton;
private Button extractButton;
private Button rebuildButton;
private Label tabInfo;
private Label statusInfo;
private TabFolder tabFolder;
private Tree treeOfBlocks;
private Tree treeOfCritics;
private Tree treeOfRegularity;
private TreeViewer treeOfBlocksViewer;
private TreeViewer treeOfCriticsViewer;
private TreeViewer treeOfRegularityViewer;
//implementation
private Links links;

public Test() {

display = new Display();
shell = new Shell(display);
shell.setText("Test");
createContents(shell, "");
try {
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
} catch (SWTException ex) {
}
}

/**
* Creates the main window's contents
*
* @param shell the main window
* @param location the initial location
*/
private void createContents(Shell shell, String location) {

// Create the web browser
browser = new Browser(shell, SWT.MOZILLA);

// !!!!!!!!!!!!!!!!!!
// Here I create a button that gets all links from to rendered webpage
// and set them to the 'links'.

// Add browsers event handlers
extractLocListener = new AdvancedLocationListener(url, statusInfo);
statusListener = new AdvancedStatusTextListener(status);
browser.addLocationListener(extractLocListener);
browser.addProgressListener(new AdvancedProgressListener(links));
browser.addStatusTextListener(statusListener);

}

static class AdvancedLocationListener implements LocationListener {

private Text url;
private Label info;

public AdvancedLocationListener(Text url, Label info) {
// Store the address box for updates
this.url = url;
this.info = info;
}

public void changing(LocationEvent event) {
// Show the location that's loading
url.setText("Loading ... " + event.location);
}

public void changed(LocationEvent event) {
// Show the loaded location
url.setText(event.location);
info.setText("Loaded");
}
}

public class AdvancedProgressListener implements ProgressListener {

private Links links;

public AdvancedProgressListener(Links links) {
this.links = links;
}

public void changed(ProgressEvent event) {
}

public void completed(ProgressEvent event) {
if (links.hasLinks()) {
browser.setUrl(links.getLink());
}
}
}

static class AdvancedStatusTextListener implements StatusTextListener {

private Label status;

public AdvancedStatusTextListener(Label label) {
// Store the label on which to report status
status = label;
}

public void changed(StatusTextEvent event) {
// Report the status
status.setText(event.text);
}
}

public static void main(String[] args) {

new Test();
}
}

[Updated on: Wed, 03 March 2010 22:01]

Report message to a moderator

Re: browser.setUrl freeze [message #518423 is a reply to message #518368] Thu, 04 March 2010 05:01 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
Do you want the urls to be opened in same browser or in a seperate browser....

What you are doing is opening the url's in the same browser which is providing the urls...
this may result is recursive calls....



---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: browser.setUrl freeze [message #518545 is a reply to message #518423] Thu, 04 March 2010 12:42 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hi, I want to open all urls in the same browser. The loading of browser's content occurs asynchronously, so it shouldn't be recursive calls. The behaviour is weird, cos when I move the cursor browser loads 1-3 urls and freezes again and so on.. Any suggestions? Thanks.
Re: browser.setUrl freeze [message #518689 is a reply to message #518545] Thu, 04 March 2010 18:30 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hello,
I tried my code on win XP with xulrunner-sdk-1.9.1.3-win32 and swt-3.6M5-win32-x86 and it works fine, no freeze anymmore. All pages are loaded successfully. I dont know if it's OS, xulrunner or swt problem? I tried the snippet below that doesn't use xulrunner and it freezed on kubuntu too. So I guess it is OS or swt problem. What do u think?

public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
// pretend the following links were parsed out from the google.com page
final String[] links = {
"http://www.google.com/intl/en/ads/",
"http://www.google.com/services/",
"http://www.google.com/intl/en/about.html",
"http://www.google.com/intl/en/privacy.html"
};
final Browser browser = new Browser(shell, SWT.NONE);
browser.setUrl("google.com");
browser.addProgressListener(new ProgressAdapter() {
public void completed(ProgressEvent event) {
if (++linkIndex > 3) return; // done
String link = links[linkIndex];
System.out.println("changing to " + link);
browser.setUrl(link);
}
});
shell.setBounds(10,10,300,300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Re: browser.setUrl freeze [message #518717 is a reply to message #518689] Thu, 04 March 2010 19:41 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
It's difficult to know where the problem lies without being able to
reproduce the problem and investigate. I would suggest logging a report
with swt (
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT )
and including the snippet that hangs. An SWT.NONE-style Browser on Linux
actually does use XULRunner, to find out which one make the snippet's first
line "Device.DEBUG=true;". Be sure to specify your XULRunner version and
linux distro, as the snippet worked for me on 32-bit Ubuntu 9.10.

Grant


"Filip" <filip.pekarek@gmail.com> wrote in message
news:hmou7l$3as$1@build.eclipse.org...
> Hello,
> I tried my code on win XP with xulrunner-sdk-1.9.1.3-win32 and
swt-3.6M5-win32-x86 and it works fine, no freeze anymmore. All pages are
loaded successfully. I dont know if it's OS, xulrunner or swt problem? I
tried the snippet below that doesn't use xulrunner and it freezed on kubuntu
too. So I guess it is OS or swt problem. What do u think?
>
> public static void main(String[] args) {
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> // pretend the following links were parsed out from the google.com
page
> final String[] links = {
> "http://www.google.com/intl/en/ads/",
> "http://www.google.com/services/",
> "http://www.google.com/intl/en/about.html",
> "http://www.google.com/intl/en/privacy.html"
> };
> final Browser browser = new Browser(shell, SWT.NONE);
> browser.setUrl("google.com");
> browser.addProgressListener(new ProgressAdapter() {
> public void completed(ProgressEvent event) {
> if (++linkIndex > 3) return; // done
> String link = links[linkIndex];
> System.out.println("changing to " + link);
> browser.setUrl(link);
> }
> });
> shell.setBounds(10,10,300,300);
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
> }
Re: browser.setUrl freeze [message #518854 is a reply to message #518717] Fri, 05 March 2010 10:07 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Thanks for reply. So I guess it's my own xulrunner-sdk build problem. I haven't found any build for 64-bit linux so I builded it by myself. Here's the procedure:

1) download source code for xulrunner from http://releases.mozilla.org/pub/mozilla.org/xulrunner/releas es/
2) extract downloaded file to any directory
3) go to extracted directory
4) run: ./configure --enable-application=xulrunner --with-java-bin-path=/usr/lib/jvm/java-6-openjdk/bin/ --with-java-include-path=/usr/lib/jvm/java-6-openjdk/include / --enable-chrome-format=jar --disable-tests
5) install all mising dependencies
6) run: make

Could anybody try it or post me a link for 64bit linux xulrunner release? Thanks a lot.
Re: browser.setUrl freeze [message #518951 is a reply to message #518854] Fri, 05 March 2010 14:32 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
It's surprising that your linux distro doesn't come with one. Anyways,
mozilla.org doesn't build 64-bit versions for their releases (I think this
will change soon), but they do build them nightly. The 1.9.1.x stream
should be generally stable, so you're probably safe to try the latest
xulrunner-1.9.1.9 64-bit build from
http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/lat est-mozilla-1.9.1/ .

Grant


"Filip" <filip.pekarek@gmail.com> wrote in message
news:hmql5r$in5$1@build.eclipse.org...
> Thanks for reply. So I guess it's my own xulrunner-sdk build problem. I
haven't found any build for 64-bit linux so I builded it by myself. Here's
the procedure:
>
> 1) download source code for xulrunner from
http://releases.mozilla.org/pub/mozilla.org/xulrunner/releas es/
> 2) extract downloaded file to any directory
> 3) go to extracted directory
> 4) run:
../configure --enable-application=xulrunner --with-java-bin-path=/usr/lib/jvm
/java-6-openjdk/bin/ --with-java-include-path=/usr/lib/jvm/java-6-openjdk/i
nclude / --enable-chrome-format=jar --disable-tests
> 5) install all mising dependencies
> 6) run: make
>
> Could anybody try it or post me a link for 64bit linux xulrunner release?
Thanks a lot.
Re: browser.setUrl freeze [message #519519 is a reply to message #518951] Tue, 09 March 2010 08:02 Go to previous message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Using latest nightly xulrunner linux-x86_64 build helped. Now it works fine. Thanks a lot !

[Updated on: Tue, 09 March 2010 08:02]

Report message to a moderator

Previous Topic:Filtering lines in StyledText
Next Topic:SWT Combo and disable + colors
Goto Forum:
  


Current Time: Thu Apr 25 14:41:42 GMT 2024

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

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

Back to the top