2 * Copyright (c) 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM - Initial API and implementation
11 package net.sourceforge.phpeclipse.webbrowser;
13 //import java.net.URL;
14 //import java.util.List;
16 import net.sourceforge.phpeclipse.webbrowser.internal.BrowserManager;
17 //import net.sourceforge.phpeclipse.webbrowser.internal.ExternalWebBrowserWorkingCopy;
18 import net.sourceforge.phpeclipse.webbrowser.internal.Trace;
19 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserEditor;
20 //import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserUIPlugin;
21 //import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserUtil;
23 import org.eclipse.swt.widgets.Display;
26 * The main interface to the internal Web browser. If allows you to query the
27 * file types supported by the Web browser and open a URL.
29 public class WebBrowser {
31 * WebBrowser constructor comment.
33 private WebBrowser() {
38 * Returns true if the internal Web browser is supported on this platform
39 * and the user has chosen to use it.
43 public static boolean isUsingInternalBrowser() {
44 return (getCurrentWebBrowser() instanceof IInternalWebBrowser);
48 * Display the given URL in a Web browser. If the user has chosen not to use
49 * the internal browser, an external browser will be used. If not, a browser
50 * in the current page will be reused if forceNewPage is not true and the
51 * user preference is not set. Finally, showToolbar will decide when the
52 * toolbar should be shown in the internal browser.
56 public static void openURL(final IWebBrowserEditorInput input) {
57 Trace.trace(Trace.FINEST, "openURL() " + input);
61 Display.getDefault().asyncExec(new Runnable() {
63 if (!isUsingInternalBrowser()) {
64 IWebBrowser browser = getCurrentWebBrowser();
65 browser.openURL(input.getURL());
67 WebBrowserEditor.open(input);
73 * Return a list of all the installed Web browsers.
77 // public static List getWebBrowsers() {
78 // return BrowserManager.getInstance().getWebBrowsers();
82 * Return the current default web browser.
86 public static IWebBrowser getCurrentWebBrowser() {
87 return BrowserManager.getInstance().getCurrentWebBrowser();
91 * Set the current default web browser.
95 // public static void getCurrentWebBrowser(IWebBrowser browser) {
96 // BrowserManager.getInstance().setCurrentWebBrowser(browser);
100 * Create a new external Web browser.
104 // public static IExternalWebBrowserWorkingCopy createExternalWebBrowser() {
105 // return new ExternalWebBrowserWorkingCopy();
109 * Display the given URL in a Web browser.
114 // public static void openURL(URL url) {
115 // IWebBrowser browser = getCurrentWebBrowser();
116 // if (browser != null)
117 // browser.openURL(url);
119 // Display.getDefault().asyncExec(new Runnable() {
120 // public void run() {
121 // WebBrowserUtil.openError(WebBrowserUIPlugin
122 // .getResource("%errorNoBrowser"));