1 36 37 38 import javax.help.*; 39 import java.util.*; 40 import java.net.*; 41 import javax.swing.*; 42 import java.awt.event.ActionEvent ; 43 import javax.jnlp.DownloadService; 44 import javax.jnlp.DownloadServiceListener; 45 import javax.jnlp.ServiceManager; 46 import javax.jnlp.UnavailableServiceException; 47 48 public class HelpHandler { 49 50 static private DownloadService _ds = null; 51 52 static public final String helpsetName = "HolidayHistory.hs"; 53 54 static public HelpBroker _hb = null; 55 56 static public void showHelp(final ActionEvent evt) { 57 new Thread () { 58 public void run() { 59 showHelpHelper(evt); 60 } 61 }.start(); 62 } 63 64 static public void showHelpHelper(ActionEvent evt) { 65 checkForDownload(); 66 initializeHelpSystem(); 67 new CSH.DisplayHelpFromSource(_hb).actionPerformed(evt); 68 } 69 70 static public synchronized void initializeHelpSystem() { 71 if (_hb != null) return; 72 try { 73 JOptionPane pane = new JOptionPane("Initializing help system. Please Wait...", 74 JOptionPane.INFORMATION_MESSAGE); 75 JDialog dialog = pane.createDialog(null, "WebPad Help System"); 76 dialog.setModal(false); 77 dialog.setVisible(true); 78 79 HelpSet hs = null; 80 ClassLoader cl = HelpHandler.class.getClassLoader(); 81 URL hsURL = HelpSet.findHelpSet(cl, helpsetName); 82 hs = new HelpSet(cl, hsURL); 83 _hb = hs.createHelpBroker(); 84 _hb.initPresentation(); 85 dialog.setVisible(false); 86 } catch (Exception ee) { 87 System.out.println("HelpSet " + helpsetName + " not found"); 88 return; 89 } 90 } 91 92 static private void checkForDownload() { 93 try { 94 _ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService"); 95 } catch (UnavailableServiceException e) { 96 _ds = null; 97 98 } 99 100 if (_ds != null) { 101 try { 102 103 if (_ds.isPartCached("help")) { 104 System.out.println("Help System is cached"); 105 return; 106 } 107 _ds.loadPart("help", _ds.getDefaultProgressWindow()); 108 } catch(Exception e) { 109 e.printStackTrace(); 110 } 111 } 112 } 113 } 114 115 | Popular Tags |