new Preferences tree
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / views / browser / BrowserView.java
index ebc76fe..f97ae34 100644 (file)
@@ -9,8 +9,13 @@
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
 package net.sourceforge.phpeclipse.views.browser;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.part.ViewPart;
+import org.eclipse.webbrowser.internal.WebBrowser;
+import org.eclipse.webbrowser.internal.WebBrowserUIPlugin;
+import org.eclipse.webbrowser.internal.WebBrowserUtil;
 /**
  * <code>BrowserView</code> is a simple demonstration of the SWT Browser
  * widget. It consists of a workbench view and tab folder where each tab in the
@@ -20,14 +25,20 @@ import org.eclipse.ui.part.ViewPart;
  */
 public class BrowserView extends ViewPart {
   public final static String ID_BROWSER = "net.sourceforge.phpeclipse.views.browser";
-  PHPBrowser instance = null;
+  WebBrowser instance = null;
   /**
    * Create the example
    * 
    * @see ViewPart#createPartControl
    */
   public void createPartControl(Composite frame) {
-    instance = new PHPBrowser(frame);
+    try {
+      if (WebBrowserUtil.canUseInternalWebBrowser() ) {
+        instance = new WebBrowser(frame, true, true);
+      }
+    } catch(Exception e) {
+      instance = null;
+    }
   }
   /**
    * Called when we must grab focus.
@@ -35,20 +46,28 @@ public class BrowserView extends ViewPart {
    * @see org.eclipse.ui.part.ViewPart#setFocus
    */
   public void setFocus() {
-    instance.setFocus();
+    if (instance!=null) {
+      instance.setFocus();
+    }
   }
   /**
    * Called when the View is to be disposed
    */
   public void dispose() {
-    instance.dispose();
-    instance = null;
+    if (instance!=null) {
+      instance.dispose();
+      instance = null;
+    }
     super.dispose();
   }
   public void setUrl(String url) {
-    instance.browser.setUrl(url);
+    if (instance!=null) {
+      instance.setURL(url);
+    }
   }
   public void refresh() {
-    instance.browser.refresh();
+    if (instance!=null) {
+      instance.refresh();
+    }
   }
 }