Adding patch from pteague for templates.
[phpeclipse.git] / net.sourceforge.phpeclipse.webbrowser / src / net / sourceforge / phpeclipse / webbrowser / internal / ExternalWebBrowser.java
index 10e5086..879aea1 100644 (file)
@@ -7,39 +7,50 @@ import net.sourceforge.phpeclipse.webbrowser.IExternalWebBrowserWorkingCopy;
 
 import org.eclipse.swt.program.Program;
 import org.eclipse.ui.IMemento;
+
 /**
  * 
  */
 public class ExternalWebBrowser implements IExternalWebBrowser {
        private static final String MEMENTO_NAME = "name";
+
        private static final String MEMENTO_LOCATION = "location";
+
        private static final String MEMENTO_PARAMETERS = "parameters";
 
        protected String name;
+
        protected String location;
+
        protected String parameters;
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see net.sourceforge.phpeclipse.webbrowser.IWebBrowser#getName()
         */
        public String getName() {
                return name;
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see net.sourceforge.phpeclipse.webbrowser.IExternalWebBrowser#getLocation()
         */
        public String getLocation() {
                return location;
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see net.sourceforge.phpeclipse.webbrowser.IExternalWebBrowser#getParameters()
         */
        public String getParameters() {
                return parameters;
        }
-       
+
        public void delete() {
                BrowserManager.getInstance().removeWebBrowser(this);
        }
@@ -58,12 +69,14 @@ public class ExternalWebBrowser implements IExternalWebBrowser {
                parameters = browser.getParameters();
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see net.sourceforge.phpeclipse.webbrowser.IWebBrowser#openURL(java.net.URL)
         */
        public void openURL(URL url) {
                String urlText = WebBrowserPreference.getHomePageURL();
-               
+
                if (url != null)
                        urlText = url.toExternalForm();
                else if (urlText.startsWith("file:") & urlText.length() > 6) {
@@ -75,12 +88,14 @@ public class ExternalWebBrowser implements IExternalWebBrowser {
                if (!WebBrowserUtil.isWindows()) {
                        int index = urlText.indexOf(" ");
                        while (index >= 0) {
-                               urlText = urlText.substring(0, index) + "%20" + urlText.substring(index + 1);
+                               urlText = urlText.substring(0, index) + "%20"
+                                               + urlText.substring(index + 1);
                                index = urlText.indexOf(" ");
                        }
                }
 
-               Trace.trace(Trace.FINEST, "Launching external Web browser: " + location + " - " + parameters + " - " + urlText);
+               Trace.trace(Trace.FINEST, "Launching external Web browser: " + location
+                               + " - " + parameters + " - " + urlText);
                if (location == null || location.length() == 0) {
                        try {
                                String extension = null;
@@ -94,31 +109,39 @@ public class ExternalWebBrowser implements IExternalWebBrowser {
                                Program program = Program.findProgram(extension);
                                program.execute(urlText);
                        } catch (Exception e) {
-                               Trace.trace(Trace.SEVERE, "Error launching default external browser", e);
-                               WebBrowserUtil.openError(WebBrowserUIPlugin.getResource("%errorCouldNotLaunchWebBrowser", urlText));
+                               Trace.trace(Trace.SEVERE,
+                                               "Error launching default external browser", e);
+                               WebBrowserUtil.openError(WebBrowserUIPlugin.getResource(
+                                               "%errorCouldNotLaunchWebBrowser", urlText));
                        }
                        return;
                }
-               
+
                String params = parameters;
                if (params == null)
                        params = "";
-               
+
                int urlIndex = params.indexOf(WebBrowserPreference.URL_PARAMETER);
                if (urlIndex >= 0)
-                       params = params.substring(0, urlIndex) + " " + urlText + " " + params.substring(urlIndex + WebBrowserPreference.URL_PARAMETER.length());
+                       params = params.substring(0, urlIndex)
+                                       + " "
+                                       + urlText
+                                       + " "
+                                       + params.substring(urlIndex
+                                                       + WebBrowserPreference.URL_PARAMETER.length());
                else {
                        if (!params.endsWith(" "))
                                params += " ";
                        params += urlText;
                }
-               
+
                try {
                        Trace.trace(Trace.FINEST, "Launching " + location + " " + params);
                        Runtime.getRuntime().exec(location + " " + params);
                } catch (Exception e) {
                        Trace.trace(Trace.SEVERE, "Could not launch external browser", e);
-                       WebBrowserUtil.openError(WebBrowserUIPlugin.getResource("%errorCouldNotLaunchWebBrowser", urlText));
+                       WebBrowserUtil.openError(WebBrowserUIPlugin.getResource(
+                                       "%errorCouldNotLaunchWebBrowser", urlText));
                }
        }
 
@@ -135,6 +158,7 @@ public class ExternalWebBrowser implements IExternalWebBrowser {
        }
 
        public String toString() {
-               return "External Web browser: " + getName() + " / " + getLocation() + " / " + getParameters();
+               return "External Web browser: " + getName() + " / " + getLocation()
+                               + " / " + getParameters();
        }
 }
\ No newline at end of file