X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FHelp.java;h=810fc92f3c476655bc9919bfdfca61221c7076ac;hb=e1aa3fdd1ca82abf5acc0cd3c2b86a5ca1083941;hp=1224645652f6cb4c2c3d6e3f0cf371ebdc30ce5b;hpb=4d7f98a6dd54d9863ba449ec79dcd95d25ed863d;p=jalview.git diff --git a/src/jalview/gui/Help.java b/src/jalview/gui/Help.java index 1224645..810fc92 100644 --- a/src/jalview/gui/Help.java +++ b/src/jalview/gui/Help.java @@ -1,5 +1,26 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.gui; +import java.awt.Point; import java.net.URL; import javax.help.BadIDException; @@ -8,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"); + Home("home"), SequenceFeatureSettings("seqfeatures.settings"), + StructureViewer("viewingpdbs"), PdbFts("pdbfts"), + UniprotFts("uniprotfts"); private String id; @@ -34,9 +55,7 @@ public class Help } } - private static final long HALF_A_MO = 500; // half a second - - private static long lastOpenedTime = 0L; + private static HelpBroker hb; /** * Not instantiable @@ -47,42 +66,50 @@ public class Help } /** - * 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);