Integrated first version of new SWT Browser (MSIE under Windows; Mozilla under Linux)
authorkhartlage <khartlage>
Thu, 4 Mar 2004 19:36:28 +0000 (19:36 +0000)
committerkhartlage <khartlage>
Thu, 4 Mar 2004 19:36:28 +0000 (19:36 +0000)
21 files changed:
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/BrowserView.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/PHPBrowser.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/browser.properties [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/document.gif [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse01.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse02.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse03.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse04.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse05.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse06.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse07.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse08.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse09.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse10.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse11.bmp [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse12.bmp [new file with mode: 0644]

index d214c3d..d484cf9 100644 (file)
@@ -30,6 +30,7 @@ propertyPagePHPProject.name=PHP Project Properties
 #
 phpEditorName=PHP Editor
 phpConsoleView=PHP Console
+phpBrowserView=PHP Browser
 phpFileExtension=php
 php3FileExtension=php3
 php4FileExtension=php4
index adedc5e..1dce0ed 100644 (file)
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
 <plugin
    id="net.sourceforge.phpeclipse"
    name="%pluginName"
@@ -12,6 +13,7 @@
       </library>
    </runtime>
    <requires>
+      <import plugin="org.eclipse.core.runtime.compatibility"/>
       <import plugin="org.eclipse.ui"/>
       <import plugin="org.eclipse.ui.console"/>
       <import plugin="org.eclipse.core.resources"/>
      </wizard>
   </extension>
    <extension
-         point="org.eclipse.ui.projectNatureImages">
+         point="org.eclipse.ui.ide.projectNatureImages">
       <image
             icon="icons/obj16/php.gif"
             natureId="net.sourceforge.phpeclipse.phpnature"
       </page> -->
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%phpFileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%php3FileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%php4FileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%incFileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%phtmlFileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%htmlFileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%htmFileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%xmlFileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       </provider>
    </extension>
    <extension
-         point="org.eclipse.ui.documentProviders">
+         point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%tplFileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
       <view
             name="%phpConsoleView"
             icon="icons/obj16/php.gif"
+            category="net.sourceforge.phpeclipse.views.category"
             class="net.sourceforge.phpeclipse.views.PHPConsole"
             id="net.sourceforge.phpeclipse.views.phpconsoleview">
+      </view>  
+      <view
+            name="%phpBrowserView"
+            icon="icons/obj16/php.gif"
+            category="net.sourceforge.phpeclipse.views.category"
+            class="net.sourceforge.phpeclipse.views.browser.BrowserView"
+            id="net.sourceforge.phpeclipse.views.browser">
       </view>
    </extension>
 
index 364df7a..dcc15e4 100644 (file)
@@ -1,5 +1,7 @@
 package net.sourceforge.phpeclipse;
 
+import net.sourceforge.phpeclipse.views.browser.BrowserView;
+
 import org.eclipse.debug.ui.IDebugUIConstants;
 import org.eclipse.ui.IFolderLayout;
 import org.eclipse.ui.IPageLayout;
@@ -46,6 +48,7 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory {
 //    if (SWT.getPlatform().equals("win32")) {
 //        layout.addShowViewShortcut(UpdatePerspective.ID_BROWSER);
 //      }
+    layout.addShowViewShortcut(BrowserView.ID_BROWSER);
     // layout.addShowViewShortcut(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
 
     // views - standard workbench
index 72fb11f..dcc2a39 100644 (file)
@@ -1,45 +1,40 @@
 /**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
-    IBM Corporation - Initial implementation
-    Klaus Hartlage - www.eclipseproject.de
-**********************************************************************/
+ Copyright (c) 2000, 2002 IBM Corp. and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Common Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/cpl-v10.html
+
+ Contributors:
+ IBM Corporation - Initial implementation
+ Klaus Hartlage - www.eclipseproject.de
+ **********************************************************************/
 package net.sourceforge.phpeclipse.actions;
-
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.text.MessageFormat;
 import java.util.Iterator;
-
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.views.PHPConsole;
-
+import net.sourceforge.phpeclipse.views.browser.BrowserView;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
-import org.eclipse.help.IHelp;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
 import org.eclipse.ui.IObjectActionDelegate;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.help.WorkbenchHelp;
 //import org.eclipse.update.internal.ui.UpdatePerspective;
 //import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
-
 public class PHPEclipseShowAction implements IObjectActionDelegate {
   private IWorkbenchPart workbenchPart;
   /**
@@ -48,127 +43,107 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
   public PHPEclipseShowAction() {
     super();
   }
-
   /**
    * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
    */
   public void setActivePart(IAction action, IWorkbenchPart targetPart) {
     workbenchPart = targetPart;
   }
-
   public void run(IAction action) {
     ISelectionProvider selectionProvider = null;
     selectionProvider = workbenchPart.getSite().getSelectionProvider();
-
     StructuredSelection selection = null;
     selection = (StructuredSelection) selectionProvider.getSelection();
     PHPConsole console = PHPConsole.getInstance();
-
     IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-
     Shell shell = null;
     Iterator iterator = null;
     iterator = selection.iterator();
     while (iterator.hasNext()) {
       //  obj => selected object in the view
       Object obj = iterator.next();
-
       // is it a resource
       if (obj instanceof IResource) {
         IResource resource = (IResource) obj;
-
         // check if it's a file resource
         switch (resource.getType()) {
-
           case IResource.FILE :
             // single file:
             IFile file = (IFile) resource;
             String localhostURL;
             if ((localhostURL = getLocalhostURL(store, (IFile) resource)) == null) {
-              MessageDialog.openInformation(
-                shell,
-                "Couldn't create localhost URL",
-                "Please configure your localhost and documentRoot");
+              MessageDialog.openInformation(shell,
+                  "Couldn't create localhost URL",
+                  "Please configure your localhost and documentRoot");
               return;
             }
             try {
               if (store.getBoolean(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF)) {
-                String[] arguments = { localhostURL };
-                MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF));
-
+                String[] arguments = {localhostURL};
+                MessageFormat form = new MessageFormat(store
+                    .getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF));
                 Runtime runtime = Runtime.getRuntime();
                 String command = form.format(arguments);
                 console.write("External Browser command: " + command + "\n");
                 runtime.exec(command);
-                //                     runtime.exec(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF) + " " + fileName);
+                //                     runtime.exec(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF)
+                // + " " + fileName);
                 //                                                             runtime.exec("command.com /c start iexplore " + fileName);
               } else {
-                //    MessageDialog.openInformation(shell, "localhostURL", "localhostURL: " + localhostURL);
+                //    MessageDialog.openInformation(shell, "localhostURL",
+                // "localhostURL: " + localhostURL);
                 //  this doesn't work under win98 ?
                 //     Program.launch(localhostURL);
                 console.write("Internal Browser URL: " + localhostURL + "\n");
                 open(new URL(localhostURL), shell, localhostURL);
               }
             } catch (MalformedURLException e) {
-              MessageDialog.openInformation(shell, "MalformedURLException: ", e.toString());
+              MessageDialog.openInformation(shell, "MalformedURLException: ", e
+                  .toString());
             } catch (IOException e) {
-              MessageDialog.openInformation(shell, "IOException", "Cannot show: " + localhostURL);
-
+              MessageDialog.openInformation(shell, "IOException",
+                  "Cannot show: " + localhostURL);
             }
         }
       }
     }
   }
-
   /**
    * @see IActionDelegate#selectionChanged(IAction, ISelection)
    */
   public void selectionChanged(IAction action, ISelection selection) {
   }
-
   public static String getLocalhostURL(IPreferenceStore store, IFile file) {
     if (store == null) {
       store = PHPeclipsePlugin.getDefault().getPreferenceStore();
     }
-
     // IPath path = file.getFullPath();
-
     String localhostURL = file.getLocation().toString();
     String lowerCaseFileName = localhostURL.toLowerCase();
     String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
     documentRoot = documentRoot.replace('\\', '/');
     documentRoot = documentRoot.toLowerCase();
-
     if (lowerCaseFileName.startsWith(documentRoot)) {
       localhostURL = localhostURL.substring(documentRoot.length());
     } else {
       return null;
     }
-
     return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
-
   }
-
-  public static void open(final URL url, final Shell shell, final String dialogTitle) {
-    //    if (SWT.getPlatform().equals("win32")) {
-    //      IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
-    //      try {
-    //        IViewPart part = page.findView(UpdatePerspective.ID_BROWSER);
-    //        if (part == null) {
-    //          part = page.showView(UpdatePerspective.ID_BROWSER);
-    //        } else
-    //          page.bringToTop(part);
-    //        ((IEmbeddedWebBrowser) part).openTo(url.toExternalForm());
-    //      } catch (PartInitException e) {
-    //        PHPeclipsePlugin.log(e);
-    //      }
-    //    } else {
-    IHelp help = WorkbenchHelp.getHelpSupport();
-    if (help != null) {
-      WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
-    } else {
-      //   showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
+  
+  public static void open(final URL url, final Shell shell,
+      final String dialogTitle) {
+    IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
+    try {
+      IViewPart part = page.findView(BrowserView.ID_BROWSER);
+      if (part == null) {
+        part = page.showView(BrowserView.ID_BROWSER);
+      } else {
+        page.bringToTop(part);
+      }
+      ((BrowserView) part).setUrl(url.toExternalForm());
+    } catch (PartInitException e) {
+      PHPeclipsePlugin.log(e);
     }
   }
-  //  }
 }
index a3669ed..941829e 100644 (file)
@@ -1,22 +1,18 @@
 package net.sourceforge.phpeclipse.phpeditor;
-
-/**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
-    IBM Corporation - Initial implementation
-    Klaus Hartlage - www.eclipseproject.de
-**********************************************************************/
-
+/*******************************************************************************
+ * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Common Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors: IBM Corporation - Initial implementation Klaus Hartlage -
+ * www.eclipseproject.de
+ ******************************************************************************/
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.actions.PHPEclipseShowAction;
+import net.sourceforge.phpeclipse.views.browser.BrowserView;
 
 import org.eclipse.core.resources.IFile;
-import org.eclipse.swt.SWT;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.IViewPart;
@@ -26,16 +22,12 @@ import org.eclipse.ui.texteditor.ITextEditor;
 import org.eclipse.ui.texteditor.TextEditorAction;
 //import org.eclipse.update.internal.ui.UpdatePerspective;
 //import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
-
 /**
  * ClassDeclaration that defines the action for parsing the current PHP file
  */
 public class ShowExternalPreviewAction extends TextEditorAction {
-
   private static ShowExternalPreviewAction instance = new ShowExternalPreviewAction();
-
   protected IFile fileToParse;
-
   /**
    * Constructs and updates the action.
    */
@@ -43,11 +35,9 @@ public class ShowExternalPreviewAction extends TextEditorAction {
     super(PHPEditorMessages.getResourceBundle(), "ParserAction.", null); //$NON-NLS-1$
     update();
   }
-
   public static ShowExternalPreviewAction getInstance() {
     return instance;
   }
-
   /**
    * Code called when the action is fired.
    */
@@ -57,43 +47,35 @@ public class ShowExternalPreviewAction extends TextEditorAction {
       // should never happen
       return;
     }
-
-//    if (SWT.getPlatform().equals("win32")) {
-//      String localhostURL;
-//      if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, fileToParse)) == null) {
-//        return;
-//      }
-//      IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
-//      try {
-//        IViewPart part = page.findView(UpdatePerspective.ID_BROWSER);
-//        if (part == null) {
-//          part = page.showView(UpdatePerspective.ID_BROWSER);
-//        } else
-//          page.bringToTop(part);
-//        ((IEmbeddedWebBrowser) part).openTo(localhostURL);
-//      } catch (PartInitException e) {
-//        PHPeclipsePlugin.log(e);
-//      }
-//    }
-
+    String localhostURL;
+    if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, fileToParse)) == null) {
+      return;
+    }
+    IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
+    try {
+      IViewPart part = page.findView(BrowserView.ID_BROWSER);
+      if (part == null) {
+        part = page.showView(BrowserView.ID_BROWSER);
+      } else {
+        page.bringToTop(part);
+      }
+      ((BrowserView) part).setUrl(localhostURL);
+    } catch (PartInitException e) {
+      PHPeclipsePlugin.log(e);
+    }
   }
-
   /**
    * Finds the file that's currently opened in the PHP Text Editor
    */
   protected IFile getFile() {
     ITextEditor editor = getTextEditor();
-
     IEditorInput editorInput = null;
     if (editor != null) {
       editorInput = editor.getEditorInput();
     }
-
     if (editorInput instanceof IFileEditorInput)
       return ((IFileEditorInput) editorInput).getFile();
-
     // if nothing was found, which should never happen
     return null;
   }
-
 }
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/BrowserView.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/BrowserView.java
new file mode 100644 (file)
index 0000000..a0a6023
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpeclipse.views.browser;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+/**
+ * <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
+ * folder allows the user to interact with a control.
+ * 
+ * @see ViewPart
+ */
+public class BrowserView extends ViewPart {
+  public final static String ID_BROWSER = "net.sourceforge.phpeclipse.views.browser";
+  PHPBrowser instance = null;
+  /**
+   * Create the example
+   * 
+   * @see ViewPart#createPartControl
+   */
+  public void createPartControl(Composite frame) {
+    instance = new PHPBrowser(frame);
+  }
+  /**
+   * Called when we must grab focus.
+   * 
+   * @see org.eclipse.ui.part.ViewPart#setFocus
+   */
+  public void setFocus() {
+    instance.setFocus();
+  }
+  /**
+   * Called when the View is to be disposed
+   */
+  public void dispose() {
+    instance.dispose();
+    instance = null;
+    super.dispose();
+  }
+  public void setUrl(String url) {
+    instance.browser.setUrl(url);
+  }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/PHPBrowser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/PHPBrowser.java
new file mode 100644 (file)
index 0000000..3374fed
--- /dev/null
@@ -0,0 +1,358 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpeclipse.views.browser;
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.CloseWindowListener;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.browser.LocationListener;
+import org.eclipse.swt.browser.OpenWindowListener;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.ProgressListener;
+import org.eclipse.swt.browser.StatusTextEvent;
+import org.eclipse.swt.browser.StatusTextListener;
+import org.eclipse.swt.browser.TitleEvent;
+import org.eclipse.swt.browser.TitleListener;
+import org.eclipse.swt.browser.VisibilityWindowListener;
+import org.eclipse.swt.browser.WindowEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class PHPBrowser {
+  static ResourceBundle resourceBundle = ResourceBundle
+      .getBundle("net.sourceforge.phpeclipse.views.browser.browser");
+  int index;
+  boolean busy;
+  Image images[];
+  Text location;
+  Browser browser;
+  static final String[] imageLocations = {"eclipse01.bmp", "eclipse02.bmp",
+      "eclipse03.bmp", "eclipse04.bmp", "eclipse05.bmp", "eclipse06.bmp",
+      "eclipse07.bmp", "eclipse08.bmp", "eclipse09.bmp", "eclipse10.bmp",
+      "eclipse11.bmp", "eclipse12.bmp",};
+  static final String iconLocation = "document.gif";
+  /**
+   * Creates an instance of a ControlExample embedded inside the supplied
+   * parent Composite.
+   * 
+   * @param parent
+   *            the container of the example
+   */
+  public PHPBrowser(Composite parent) {
+    initResources();
+    final Display display = parent.getDisplay();
+    FormLayout layout = new FormLayout();
+    parent.setLayout(layout);
+    ToolBar toolbar = new ToolBar(parent, SWT.NONE);
+    final ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
+    itemBack.setText(getResourceString("Back"));
+    final ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
+    itemForward.setText(getResourceString("Forward"));
+    final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
+    itemStop.setText(getResourceString("Stop"));
+    final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
+    itemRefresh.setText(getResourceString("Refresh"));
+    final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
+    itemGo.setText(getResourceString("Go"));
+    location = new Text(parent, SWT.BORDER);
+    final Canvas canvas = new Canvas(parent, SWT.NO_BACKGROUND);
+    final Rectangle rect = images[0].getBounds();
+    canvas.addListener(SWT.Paint, new Listener() {
+      public void handleEvent(Event e) {
+        Point pt = canvas.getSize();
+        e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0,
+            pt.x, pt.y);
+      }
+    });
+    canvas.addListener(SWT.MouseDown, new Listener() {
+      public void handleEvent(Event e) {
+        browser.setUrl(getResourceString("Startup"));
+      }
+    });
+    display.asyncExec(new Runnable() {
+      public void run() {
+        if (canvas.isDisposed())
+          return;
+        if (busy) {
+          index++;
+          if (index == images.length)
+            index = 0;
+          canvas.redraw();
+        }
+        display.timerExec(150, this);
+      }
+    });
+    final Label status = new Label(parent, SWT.NONE);
+    final ProgressBar progressBar = new ProgressBar(parent, SWT.NONE);
+    FormData data = new FormData();
+    data.top = new FormAttachment(0, 5);
+    toolbar.setLayoutData(data);
+    data = new FormData();
+    data.left = new FormAttachment(0, 0);
+    data.right = new FormAttachment(100, 0);
+    data.top = new FormAttachment(canvas, 5, SWT.DEFAULT);
+    data.bottom = new FormAttachment(status, -5, SWT.DEFAULT);
+    try {
+      browser = new Browser(parent, SWT.NONE);
+      browser.setLayoutData(data);
+    } catch (SWTError e) {
+      /* Browser widget could not be instantiated */
+      Label label = new Label(parent, SWT.CENTER | SWT.WRAP);
+      label.setText(getResourceString("BrowserNotCreated"));
+      label.setLayoutData(data);
+    }
+    data = new FormData();
+    data.width = 24;
+    data.height = 24;
+    data.top = new FormAttachment(0, 5);
+    data.right = new FormAttachment(100, -5);
+    canvas.setLayoutData(data);
+    data = new FormData();
+    data.top = new FormAttachment(toolbar, 0, SWT.TOP);
+    data.left = new FormAttachment(toolbar, 5, SWT.RIGHT);
+    data.right = new FormAttachment(canvas, -5, SWT.DEFAULT);
+    location.setLayoutData(data);
+    data = new FormData();
+    data.left = new FormAttachment(0, 5);
+    data.right = new FormAttachment(progressBar, 0, SWT.DEFAULT);
+    data.bottom = new FormAttachment(100, -5);
+    status.setLayoutData(data);
+    data = new FormData();
+    data.right = new FormAttachment(100, -5);
+    data.bottom = new FormAttachment(100, -5);
+    progressBar.setLayoutData(data);
+    if (browser != null) {
+      itemBack.setEnabled(browser.isBackEnabled());
+      itemForward.setEnabled(browser.isForwardEnabled());
+      Listener listener = new Listener() {
+        public void handleEvent(Event event) {
+          ToolItem item = (ToolItem) event.widget;
+          if (item == itemBack)
+            browser.back();
+          else if (item == itemForward)
+            browser.forward();
+          else if (item == itemStop)
+            browser.stop();
+          else if (item == itemRefresh)
+            browser.refresh();
+          else if (item == itemGo)
+            browser.setUrl(location.getText());
+        }
+      };
+      browser.addLocationListener(new LocationListener() {
+        public void changed(LocationEvent event) {
+          busy = true;
+          if (event.top)
+            location.setText(event.location);
+        }
+        public void changing(LocationEvent event) {
+        }
+      });
+      browser.addProgressListener(new ProgressListener() {
+        public void changed(ProgressEvent event) {
+          if (event.total == 0)
+            return;
+          int ratio = event.current * 100 / event.total;
+          progressBar.setSelection(ratio);
+          busy = event.current != event.total;
+          if (!busy) {
+            index = 0;
+            canvas.redraw();
+          }
+        }
+        public void completed(ProgressEvent event) {
+          itemBack.setEnabled(browser.isBackEnabled());
+          itemForward.setEnabled(browser.isForwardEnabled());
+          progressBar.setSelection(0);
+          busy = false;
+          index = 0;
+          canvas.redraw();
+        }
+      });
+      browser.addStatusTextListener(new StatusTextListener() {
+        public void changed(StatusTextEvent event) {
+          status.setText(event.text);
+        }
+      });
+      if (parent instanceof Shell) {
+        final Shell shell = (Shell) parent;
+        browser.addTitleListener(new TitleListener() {
+          public void changed(TitleEvent event) {
+            shell.setText(event.title + " - "
+                + getResourceString("window.title"));
+          }
+        });
+      }
+      itemBack.addListener(SWT.Selection, listener);
+      itemForward.addListener(SWT.Selection, listener);
+      itemStop.addListener(SWT.Selection, listener);
+      itemRefresh.addListener(SWT.Selection, listener);
+      itemGo.addListener(SWT.Selection, listener);
+      location.addListener(SWT.DefaultSelection, new Listener() {
+        public void handleEvent(Event e) {
+          browser.setUrl(location.getText());
+        }
+      });
+      initialize(display, browser);
+      browser.setUrl(getResourceString("Startup"));
+    }
+  }
+  /**
+   * Gets a string from the resource bundle. We don't want to crash because of
+   * a missing String. Returns the key if not found.
+   */
+  static String getResourceString(String key) {
+    try {
+      return resourceBundle.getString(key);
+    } catch (MissingResourceException e) {
+      return key;
+    } catch (NullPointerException e) {
+      return "!" + key + "!";
+    }
+  }
+  /**
+   * Gets a string from the resource bundle and binds it with the given
+   * arguments. If the key is not found, return the key.
+   */
+  static String getResourceString(String key, Object[] args) {
+    try {
+      return MessageFormat.format(getResourceString(key), args);
+    } catch (MissingResourceException e) {
+      return key;
+    } catch (NullPointerException e) {
+      return "!" + key + "!";
+    }
+  }
+  static void initialize(final Display display, Browser browser) {
+    browser.addOpenWindowListener(new OpenWindowListener() {
+      public void open(WindowEvent event) {
+        Shell shell = new Shell(display);
+        shell.setLayout(new FillLayout());
+        Browser browser = new Browser(shell, SWT.NONE);
+        initialize(display, browser);
+        event.browser = browser;
+      }
+    });
+    browser.addVisibilityWindowListener(new VisibilityWindowListener() {
+      public void hide(WindowEvent event) {
+      }
+      public void show(WindowEvent event) {
+        Browser browser = (Browser) event.widget;
+        Shell shell = browser.getShell();
+        if (event.location != null)
+          shell.setLocation(event.location);
+        if (event.size != null) {
+          Point size = event.size;
+          shell.setSize(shell.computeSize(size.x, size.y));
+        }
+        shell.open();
+      }
+    });
+    browser.addCloseWindowListener(new CloseWindowListener() {
+      public void close(WindowEvent event) {
+        Browser browser = (Browser) event.widget;
+        Shell shell = browser.getShell();
+        shell.close();
+      }
+    });
+  }
+  /**
+   * Disposes of all resources associated with a particular instance of the
+   * BrowserExample.
+   */
+  public void dispose() {
+    freeResources();
+  }
+  /**
+   * Frees the resources
+   */
+  void freeResources() {
+    if (images != null) {
+      for (int i = 0; i < images.length; ++i) {
+        final Image image = images[i];
+        if (image != null)
+          image.dispose();
+      }
+      images = null;
+    }
+  }
+  /**
+   * Grabs input focus.
+   */
+  public void setFocus() {
+    location.setFocus();
+  }
+  /**
+   * Loads the resources
+   */
+  void initResources() {
+    final Class clazz = this.getClass();
+    if (resourceBundle != null) {
+      try {
+        if (images == null) {
+          images = new Image[imageLocations.length];
+          for (int i = 0; i < imageLocations.length; ++i) {
+            ImageData source = new ImageData(clazz
+                .getResourceAsStream(imageLocations[i]));
+            ImageData mask = source.getTransparencyMask();
+            images[i] = new Image(null, source, mask);
+          }
+        }
+        return;
+      } catch (Throwable t) {
+      }
+    }
+    String error = (resourceBundle != null)
+        ? getResourceString("error.CouldNotLoadResources")
+        : "Unable to load resources";
+    freeResources();
+    throw new RuntimeException(error);
+  }
+  public static void main(String[] args) {
+    Display display = new Display();
+    Shell shell = new Shell(display);
+    shell.setLayout(new FillLayout());
+    shell.setText(getResourceString("window.title"));
+    PHPBrowser instance = new PHPBrowser(shell);
+    Image icon = new Image(display, PHPBrowser.class
+        .getResourceAsStream(iconLocation));
+    shell.setImage(icon);
+    shell.open();
+    while (!shell.isDisposed()) {
+      if (!display.readAndDispatch())
+        display.sleep();
+    }
+    icon.dispose();
+    instance.dispose();
+    display.dispose();
+  }
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/browser.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/browser.properties
new file mode 100644 (file)
index 0000000..e3daf7c
--- /dev/null
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials 
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+# 
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+error.CouldNotLoadResources = Unable to load resources
+window.title = PHP Browser
+
+Back                           = Back
+BrowserNotCreated      = Error - The Browser widget could not be instantiated. Please check the Browser widget is supported on this platform. Supported platforms and software requirements for the Browser widget are listed on the SWT FAQ web page.
+Forward                                = Forward
+Stop                           = Stop
+Refresh                                = Refresh
+Go                                     = Go
+Startup                                = http://www.phpeclipse.de
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/document.gif b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/document.gif
new file mode 100644 (file)
index 0000000..895e221
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/document.gif differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse01.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse01.bmp
new file mode 100644 (file)
index 0000000..43116e6
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse01.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse02.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse02.bmp
new file mode 100644 (file)
index 0000000..8db04ef
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse02.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse03.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse03.bmp
new file mode 100644 (file)
index 0000000..5fc7b10
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse03.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse04.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse04.bmp
new file mode 100644 (file)
index 0000000..2140654
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse04.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse05.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse05.bmp
new file mode 100644 (file)
index 0000000..7e45a99
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse05.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse06.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse06.bmp
new file mode 100644 (file)
index 0000000..aaa888a
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse06.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse07.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse07.bmp
new file mode 100644 (file)
index 0000000..50e2222
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse07.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse08.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse08.bmp
new file mode 100644 (file)
index 0000000..b1ac29d
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse08.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse09.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse09.bmp
new file mode 100644 (file)
index 0000000..561f830
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse09.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse10.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse10.bmp
new file mode 100644 (file)
index 0000000..6ae79b2
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse10.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse11.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse11.bmp
new file mode 100644 (file)
index 0000000..a0c24a6
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse11.bmp differ
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse12.bmp b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse12.bmp
new file mode 100644 (file)
index 0000000..1cae71c
Binary files /dev/null and b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/browser/eclipse12.bmp differ