JAL-2814 JAL-3032 targeted help URL links for JalviewJS
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 14 Mar 2019 13:05:33 +0000 (13:05 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 14 Mar 2019 13:05:33 +0000 (13:05 +0000)
src/jalview/gui/Help.java

index 651d265..83fcaf7 100644 (file)
@@ -39,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;
@@ -82,7 +96,7 @@ public class Help
        {
          try 
          {
-               BrowserLauncher.openURL("http://www.jalview.org/help.html");
+               BrowserLauncher.openURL(HELP_PAGE_ROOT + id.getPath());
          } catch (IOException e) {}
            return;
        }
@@ -101,10 +115,10 @@ public class Help
 
     try
     {
-      hb.setCurrentID(id.toString());
+      hb.setCurrentID(id.getId());
     } catch (BadIDException bad)
     {
-      System.out.println("Bad help link: " + id.toString()
+      System.out.println("Bad help link: " + id.getId()
               + ": must match a target in help.jhm");
       throw bad;
     }