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.
57 * @throws HelpSetException
59 public static void showHelpWindow(HelpId id) throws HelpSetException
61 long timeNow = System.currentTimeMillis();
63 if (timeNow - lastOpenedTime > HALF_A_MO)
65 lastOpenedTime = timeNow;
66 ClassLoader cl = Desktop.class.getClassLoader();
67 URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$
68 HelpSet hs = new HelpSet(cl, url);
70 HelpBroker hb = hs.createHelpBroker();
73 hb.setCurrentID(id.toString());
74 } catch (BadIDException bad)
76 System.out.println("Bad help link: " + id.toString()
77 + ": must match a target in help.jhm");
80 hb.setDisplayed(true);
84 public static void showHelpWindow() throws HelpSetException
86 showHelpWindow(HelpId.Home);