1 11 package org.eclipse.jface.text.hyperlink; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.program.Program; 15 16 import org.eclipse.core.runtime.Assert; 17 18 import org.eclipse.jface.text.IRegion; 19 20 21 26 public class URLHyperlink implements IHyperlink { 27 28 private String fURLString; 29 private IRegion fRegion; 30 31 37 public URLHyperlink(IRegion region, String urlString) { 38 Assert.isNotNull(urlString); 39 Assert.isNotNull(region); 40 41 fRegion= region; 42 fURLString= urlString; 43 } 44 45 48 public IRegion getHyperlinkRegion() { 49 return fRegion; 50 } 51 52 55 public void open() { 56 if (fURLString != null) { 57 String platform= SWT.getPlatform(); 58 if ("motif".equals(platform) || "gtk".equals(platform)) { Program program= Program.findProgram("html"); if (program == null) 61 program= Program.findProgram("htm"); if (program != null) 63 program.execute(fURLString); 64 } else 65 Program.launch(fURLString); 66 fURLString= null; 67 return; 68 } 69 } 70 71 74 public String getTypeLabel() { 75 return null; 76 } 77 78 81 public String getHyperlinkText() { 82 return null; 83 } 84 85 91 public String getURLString() { 92 return fURLString; 93 } 94 95 } 96 | Popular Tags |