1 11 package org.eclipse.ui.internal.browser; 12 13 import java.net.URL ; 14 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.swt.program.Program; 17 import org.eclipse.ui.PartInitException; 18 import org.eclipse.ui.browser.AbstractWebBrowser; 19 20 23 public class SystemBrowserInstance extends AbstractWebBrowser { 24 public SystemBrowserInstance(String id) { 25 super(id); 26 } 27 28 public void openURL(URL url) throws PartInitException { 29 String urlText = null; 30 31 if (url != null) 32 urlText = url.toExternalForm(); 33 34 if (urlText != null && !WebBrowserUtil.isWindows()) { 36 int index = urlText.indexOf(" "); while (index >= 0) { 38 urlText = urlText.substring(0, index) + "%20" + urlText.substring(index + 1); 40 index = urlText.indexOf(" "); } 42 } 43 Trace.trace(Trace.FINEST, "Launching system Web browser: " + urlText); Program program = Program.findProgram("html"); if (program != null) { 46 if (program.execute(urlText)) 47 return; 48 } 49 if (!Program.launch(urlText)) 50 throw new PartInitException(NLS.bind(Messages.errorCouldNotLaunchWebBrowser, url.toExternalForm())); 51 } 52 } | Popular Tags |