When building an Eclipse facet, I found the need to pop up a new browser window. The idea was, the user would use the facet, then upon finishing the wizard, a browser would open directly to the documentation they needed to continue working. This way, they didn’t have to search around for ‘next steps’ documentation. The following code snippet pops up a URL in the default system browser, in my case at work, this is Internet Explorer (company standard).
int style = IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.STATUS;
IWebBrowser browser = WorkbenchBrowserSupport.getInstance().createBrowser(style, "MyBrowserID", "MyBrowserName", "MyBrowser Tooltip");
browser.openURL(new URL("http://www.google.com"));
This creates a browser instance of whatever type the developer has configured for the Eclipse install. Word of caution, if you need to popup multiple browser instances, be sure to change the ‘ID’ attribute, or pass ‘null’ to have a unique ID generated each time. If you use the same ID, Eclipse will attempt to use the same browser instance.
March 14th, 2009 at 11:20 am
Thanks, this was just the example I was looking for!
March 26th, 2009 at 12:09 pm
Nice one, Dave! This saved me quite a bit of hunting about in the help files, and worked straight off the page. Many thanks, Mark.
July 8th, 2009 at 10:59 pm
Thank you so much. It really helped a lot
December 7th, 2009 at 5:17 am
This uses internal code.
check the following from SWT Class..
Program.launch(url);