1 11 package org.eclipse.ui.internal.editors.text; 12 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 16 import org.eclipse.jface.text.IRegion; 17 18 import org.eclipse.ui.PartInitException; 19 import org.eclipse.ui.PlatformUI; 20 import org.eclipse.ui.browser.IWebBrowser; 21 import org.eclipse.ui.browser.IWorkbenchBrowserSupport; 22 23 24 29 final class URLHyperlink extends org.eclipse.jface.text.hyperlink.URLHyperlink { 30 31 private String fURLString; 32 33 39 public URLHyperlink(IRegion region, String urlString) { 40 super(region, urlString); 41 fURLString= urlString; 42 } 43 44 48 public void open() { 49 IWorkbenchBrowserSupport support= PlatformUI.getWorkbench().getBrowserSupport(); 51 IWebBrowser browser; 52 try { 53 browser= support.createBrowser(null); 54 } catch (PartInitException e) { 55 EditorsPlugin.logErrorStatus("Could not create Web browser for URLHyperlink", e.getStatus()); super.open(); 57 return; 58 } 59 60 try { 61 browser.openURL(new URL (fURLString)); 62 } catch (PartInitException e) { 63 super.open(); 64 } catch (MalformedURLException e) { 65 super.open(); 66 } 67 } 68 } 69 | Popular Tags |