From: gmungoc Date: Tue, 5 Mar 2019 12:05:28 +0000 (+0000) Subject: Merge remote-tracking branch 'origin/bug/JAL-914multipleHelpScreens' into develop X-Git-Tag: Release_2_11_0~17^2~68 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=1a04478ca5d5fa6bae27f8e7220df5b57fe1c698;hp=-c Merge remote-tracking branch 'origin/bug/JAL-914multipleHelpScreens' into develop --- 1a04478ca5d5fa6bae27f8e7220df5b57fe1c698 diff --combined src/jalview/gui/Help.java index cba9c2c,9d8955f..810fc92 --- a/src/jalview/gui/Help.java +++ b/src/jalview/gui/Help.java @@@ -20,6 -20,7 +20,7 @@@ */ package jalview.gui; + import java.awt.Point; import java.net.URL; import javax.help.BadIDException; @@@ -28,17 -29,17 +29,17 @@@ import javax.help.HelpSet import javax.help.HelpSetException; /** - * Utility class to show the help documentation window. + * Utility class to show the help documentation window * * @author gmcarstairs - * */ public class Help { public enum HelpId { Home("home"), SequenceFeatureSettings("seqfeatures.settings"), - StructureViewer("viewingpdbs"); + StructureViewer("viewingpdbs"), PdbFts("pdbfts"), + UniprotFts("uniprotfts"); private String id; @@@ -54,9 -55,7 +55,7 @@@ } } - private static final long HALF_A_MO = 500; // half a second - - private static long lastOpenedTime = 0L; + private static HelpBroker hb; /** * Not instantiable @@@ -67,42 -66,50 +66,50 @@@ } /** - * Show help text in a new window. But do nothing if within half a second of - * the last invocation. - * - * This is a workaround for issue JAL-914 - both Desktop and AlignFrame - * responding to F1 key, resulting in duplicate help windows opened. + * Shows the help window, at the entry specified by the given helpId * * @param id - * TODO * * @throws HelpSetException */ public static void showHelpWindow(HelpId id) throws HelpSetException { - long timeNow = System.currentTimeMillis(); + ClassLoader cl = Desktop.class.getClassLoader(); + URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$ + HelpSet hs = new HelpSet(cl, url); - if (timeNow - lastOpenedTime > HALF_A_MO) + if (hb == null) { - lastOpenedTime = timeNow; - ClassLoader cl = Desktop.class.getClassLoader(); - URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$ - HelpSet hs = new HelpSet(cl, url); + /* + * create help broker first time (only) + */ + hb = hs.createHelpBroker(); + } - HelpBroker hb = hs.createHelpBroker(); - try - { - hb.setCurrentID(id.toString()); - } catch (BadIDException bad) - { - System.out.println("Bad help link: " + id.toString() - + ": must match a target in help.jhm"); - throw bad; - } - hb.setDisplayed(true); + try + { + hb.setCurrentID(id.toString()); + } catch (BadIDException bad) + { + System.out.println("Bad help link: " + id.toString() + + ": must match a target in help.jhm"); + throw bad; } + + /* + * set Help visible - at its current location if it is already shown, + * else at a location as determined by the window manager + */ + Point p = hb.getLocation(); + hb.setLocation(p); + hb.setDisplayed(true); } + /** + * Show the Help window at the root entry + * + * @throws HelpSetException + */ public static void showHelpWindow() throws HelpSetException { showHelpWindow(HelpId.Home);