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");
24 private HelpId(String loc)
30 public String toString()
36 private static final long HALF_A_MO = 500; // half a second
38 private static long lastOpenedTime = 0L;
49 * Show help text in a new window. But do nothing if within half a second of
50 * the last invocation.
52 * This is a workaround for issue JAL-914 - both Desktop and AlignFrame
53 * responding to F1 key, resulting in duplicate help windows opened.
56 * @throws HelpSetException
58 public static void showHelpWindow(HelpId id) throws HelpSetException
60 long timeNow = System.currentTimeMillis();
62 if (timeNow - lastOpenedTime > HALF_A_MO)
64 lastOpenedTime = timeNow;
65 ClassLoader cl = Desktop.class.getClassLoader();
66 URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$
67 HelpSet hs = new HelpSet(cl, url);
69 HelpBroker hb = hs.createHelpBroker();
72 hb.setCurrentID(id.toString());
73 } catch (BadIDException bad)
75 System.out.println("Bad help link: " + id.toString()
76 + ": must match a target in help.jhm");
79 hb.setDisplayed(true);
83 public static void showHelpWindow() throws HelpSetException
85 showHelpWindow(HelpId.Home);