1 33 34 package edu.rice.cs.drjava.ui; 35 36 import edu.rice.cs.drjava.CodeStatus; 37 import edu.rice.cs.drjava.platform.PlatformFactory; 38 39 import javax.swing.event.HyperlinkListener ; 40 import javax.swing.event.HyperlinkEvent ; 41 import java.net.URL ; 42 import java.net.MalformedURLException ; 43 44 48 public class HelpFrame extends HTMLFrame { 49 private static final String HELP_PATH = "/edu/rice/cs/drjava/docs/user/"; 50 protected static final String CONTENTS_PAGE = "index.html"; 51 protected static final String HOME_PAGE = "intro.html"; 52 private static final URL INTRO_URL = 53 HTMLFrame.class.getResource(HELP_PATH + HOME_PAGE); 54 protected static final String ICON = "DrJavaHelp.png"; 55 56 public HelpFrame() { 57 super("Help on using DrJava", INTRO_URL, HelpFrame.class.getResource(HELP_PATH + CONTENTS_PAGE), ICON); 58 addHyperlinkListener(_linkListener); 59 60 } 61 62 65 public HelpFrame(String frameName, URL introUrl, URL indexUrl, String iconString) { 66 super(frameName, introUrl, indexUrl, iconString); 67 } 68 69 70 protected String getErrorText(URL url) { 71 String errorText = "The Help files are currently unavailable."; 73 if (CodeStatus.DEVELOPMENT) { errorText += "\n\nTo generate the help files, run the \"ant docs\" target" + 75 " after compiling DrJava."; 76 } 77 return errorText; 78 } 79 80 82 private HyperlinkListener _linkListener = new HyperlinkListener () { 83 public void hyperlinkUpdate(HyperlinkEvent event) { 84 if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { 85 URL url = event.getURL(); 87 String protocol = url.getProtocol(); 88 89 if (!"file".equals(protocol) && !"jar".equals(protocol)) { 90 PlatformFactory.ONLY.openURL(url); 94 return; 95 } 96 97 String path = url.getPath(); 99 100 if (path.indexOf(HELP_PATH+CONTENTS_PAGE) >= 0) { 101 try { url = new URL (url,HOME_PAGE); } catch(MalformedURLException murle) { 103 104 } 105 } 106 else if (path.indexOf(HELP_PATH) < 0) return; 108 if (url.sameFile(_history.contents)) return; jumpTo(url); 110 } 111 } 112 }; 113 } 114 | Popular Tags |