Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » New Platform Browser from Browser Widget
New Platform Browser from Browser Widget [message #449197] Wed, 19 January 2005 09:12 Go to next message
Grant Slender is currently offline Grant SlenderFriend
Messages: 14
Registered: July 2009
Junior Member
Greetings...

I'm trying to figure out how to cause a new platform specific browser to
launch when the user clicks on a link that results in a new window to be
normally shown in the Browser widget.

Currently, new windows targets are ignored in HTML HREF tags, but I'm keen
to cause a new version of IE (or Netscape whatever) to be opened.

Is that kind of API being considered ?

Grant
Re: New Platform Browser from Browser Widget [message #449268 is a reply to message #449197] Wed, 19 January 2005 21:51 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
If I understand your question correctly: you can look into the javadoc for
org.eclipse.swt.browser.WindowEvent. This event is used to handle new window
requests with the SWT Browser. Application needs to handle these events to
support commands like href target="_blank" or javascript window.open.

Or are you asking for something else?

Chris
Re: New Platform Browser from Browser Widget [message #449279 is a reply to message #449268] Thu, 20 January 2005 05:30 Go to previous messageGo to next message
Grant Slender is currently offline Grant SlenderFriend
Messages: 14
Registered: July 2009
Junior Member
Chris,

I'm aware of what you are describing - that does allow you to see the new
window events.

From this, I want to be able to tell the underlying OS to launch a system
browser window from this event.

Whilst I could create a new Shell and place a browser in it, I don't want to
emulate the entire IE browser - for situations where the underlying Browser
widget should show a normal OS browser, I would like to let that launch
occur and present as normal.

Thanks for any feedback or suggestions...

Regards,

Grant

"Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
news:csmkqm$rei$1@www.eclipse.org...
> If I understand your question correctly: you can look into the javadoc for
> org.eclipse.swt.browser.WindowEvent. This event is used to handle new
> window requests with the SWT Browser. Application needs to handle these
> events to support commands like href target="_blank" or javascript
> window.open.
>
> Or are you asking for something else?
>
> Chris
>
Re: New Platform Browser from Browser Widget [message #449291 is a reply to message #449279] Thu, 20 January 2005 16:49 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
Short answer is: not supported.

If you are willing to experiment, here is a - poor - hack below.
Program.launch is used to access an external native viewer (IE ..). It is
inefficient - document gets loaded twice - and fragile - Program.launch
could fail or be passed unsupported content. If you own the HTML content you
could verify it works in your situation otherwise it's probably wise not to
use it. To try the example below, go to a link that opens up in a new window
or right click and select "open in a new window" if you are on Windows.

Chris


import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.program.*;

public class PRBrowser {

public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setText("PRBrowser");
shell.setLayout(new FillLayout());

final Shell hiddenShell = new Shell(display);
final Browser hiddenBrowser = new Browser(hiddenShell, SWT.NONE);
hiddenBrowser.addVisibilityWindowListener(new VisibilityWindowListener() {
public void hide(WindowEvent e) {
}
public void show(WindowEvent e) {
/* ignore pop-ups and other windows with no all attributes */
if (e.addressBar && e.menuBar && e.statusBar && e.toolBar) {
hiddenBrowser.setData("EXTERNAL", "true");
}
}
});
hiddenBrowser.addLocationListener(new LocationListener() {
public void changing(LocationEvent event) {
}
public void changed(LocationEvent event) {
if (!event.top) return;
if (hiddenBrowser.getData("EXTERNAL") != null) {
hiddenBrowser.setData("EXTERNAL", null);
Program.launch(event.location);
}
}
});

Browser browser = new Browser(shell, SWT.NONE);
browser.addOpenWindowListener(new OpenWindowListener() {
public void open(WindowEvent e) {
e.browser = hiddenBrowser;
}
});
browser.setUrl("http://www.eclipse.org");
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
hiddenShell.close();
display.dispose();
}
}
Re: New Platform Browser from Browser Widget [message #449458 is a reply to message #449279] Mon, 24 January 2005 20:12 Go to previous message
Bernhard Fastenrath is currently offline Bernhard FastenrathFriend
Messages: 10
Registered: July 2009
Junior Member
http://browserlauncher.sourceforge.net/ is probably
what you want to start the system default browser.

If you need a feedback if the URL actually exists
you can use openURL(java.net.URL url, boolean verify)
in http://dolphin.sourceforge.net/docs/dolphin/util/web/WebUtil .html
This will throw an IOException if the url does not exist.

Grant Slender wrote:
> Chris,
>
> I'm aware of what you are describing - that does allow you to see the new
> window events.
>
> From this, I want to be able to tell the underlying OS to launch a system
> browser window from this event.
>
> Whilst I could create a new Shell and place a browser in it, I don't want to
> emulate the entire IE browser - for situations where the underlying Browser
> widget should show a normal OS browser, I would like to let that launch
> occur and present as normal.
>
> Thanks for any feedback or suggestions...
>
> Regards,
>
> Grant
>
> "Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
> news:csmkqm$rei$1@www.eclipse.org...
>
>>If I understand your question correctly: you can look into the javadoc for
>>org.eclipse.swt.browser.WindowEvent. This event is used to handle new
>>window requests with the SWT Browser. Application needs to handle these
>>events to support commands like href target="_blank" or javascript
>>window.open.
>>
>>Or are you asking for something else?
>>
>>Chris
>>
>
>
>
Previous Topic:Constrain a single instance of an SWT application!
Next Topic:CoolItem Unable to take entire space horizontally
Goto Forum:
  


Current Time: Tue Nov 19 20:43:00 GMT 2019

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

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

Back to the top