5 import javax.help.BadIDException;
6 import javax.help.HelpBroker;
7 import javax.help.HelpSet;
8 import javax.help.HelpSetException;
11 * Utility class to show the help documentation window.
20 Home("home"), SequenceFeatureSettings("seqfeatures.settings"), StructureViewer(
25 private HelpId(String loc)
31 public String toString()
37 private static final long HALF_A_MO = 500; // half a second
39 private static long lastOpenedTime = 0L;
50 * Show help text in a new window. But do nothing if within half a second of
51 * the last invocation.
53 * This is a workaround for issue JAL-914 - both Desktop and AlignFrame
54 * responding to F1 key, resulting in duplicate help windows opened.
59 * @throws HelpSetException
61 public static void showHelpWindow(HelpId id) throws HelpSetException
63 long timeNow = System.currentTimeMillis();
65 if (timeNow - lastOpenedTime > HALF_A_MO)
67 lastOpenedTime = timeNow;
68 ClassLoader cl = Desktop.class.getClassLoader();
69 URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$
70 HelpSet hs = new HelpSet(cl, url);
72 HelpBroker hb = hs.createHelpBroker();
75 hb.setCurrentID(id.toString());
76 } catch (BadIDException bad)
78 System.out.println("Bad help link: " + id.toString()
79 + ": must match a target in help.jhm");
82 hb.setDisplayed(true);
86 public static void showHelpWindow() throws HelpSetException
88 showHelpWindow(HelpId.Home);