X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FHelp.java;fp=src%2Fjalview%2Fgui%2FHelp.java;h=8bd01ea42916fa907c0249ae3426b932663588be;hp=810fc92f3c476655bc9919bfdfca61221c7076ac;hb=65740880573a48adc758bec3939ece9d9ae104dd;hpb=71aa78b8a7d54e5aeb6b278310dfd735efb77477 diff --git a/src/jalview/gui/Help.java b/src/jalview/gui/Help.java index 810fc92..8bd01ea 100644 --- a/src/jalview/gui/Help.java +++ b/src/jalview/gui/Help.java @@ -20,7 +20,11 @@ */ package jalview.gui; +import jalview.util.BrowserLauncher; +import jalview.util.Platform; + import java.awt.Point; +import java.io.IOException; import java.net.URL; import javax.help.BadIDException; @@ -35,24 +39,38 @@ import javax.help.HelpSetException; */ public class Help { + private static final String HELP_PAGE_ROOT = "http://www.jalview.org/help/"; + + /** + * Defines selected help targets with links to inbuilt (Java) help page target, + * and externally hosted help page. Will need to be maintained manually if help + * pages are reorganised in future. + */ public enum HelpId { - Home("home"), SequenceFeatureSettings("seqfeatures.settings"), - StructureViewer("viewingpdbs"), PdbFts("pdbfts"), - UniprotFts("uniprotfts"); + Home("home", "help.html"), SequenceFeatureSettings("seqfeatures.settings", "html/features/featuresettings.html"), + StructureViewer("viewingpdbs", "html/features/viewingpdbs.html"), PdbFts("pdbfts", "html/features/pdbsequencefetcher.html#pdbfts"), + UniprotFts("uniprotfts", "html/features/uniprotsequencefetcher.html#uniprotfts"); private String id; + + private String path; - private HelpId(String loc) + private HelpId(String hepLoc, String htmlPath) { - this.id = loc; + this.id = hepLoc; + this.path = htmlPath; } - @Override - public String toString() + String getId() { return this.id; } + + String getPath() + { + return this.path; + } } private static HelpBroker hb; @@ -74,35 +92,53 @@ public class Help */ public static void showHelpWindow(HelpId id) throws HelpSetException { - ClassLoader cl = Desktop.class.getClassLoader(); - URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$ - HelpSet hs = new HelpSet(cl, url); - - if (hb == null) + if (Platform.isJS()) { - /* - * create help broker first time (only) - */ - hb = hs.createHelpBroker(); + try + { + BrowserLauncher.openURL(HELP_PAGE_ROOT + id.getPath()); + } catch (IOException e) + { + } } - - try - { - hb.setCurrentID(id.toString()); - } catch (BadIDException bad) + else + /** + * Java only + * + * @j2sIgnore + */ { - 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); + ClassLoader cl = Desktop.class.getClassLoader(); + URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$ + HelpSet hs = new HelpSet(cl, url); + + if (hb == null) + { + /* + * create help broker first time (only) + */ + hb = hs.createHelpBroker(); + } + + try + { + hb.setCurrentID(id.getId()); + } catch (BadIDException bad) + { + System.out.println("Bad help link: " + id.getId() + + ": 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); + } } /**