77 *******************************************************************************/
88package org .phoebus .ui .help ;
99
10- import org .phoebus .framework .workbench .ApplicationService ;
10+ import org .phoebus .framework .workbench .Locations ;
1111import org .phoebus .ui .application .Messages ;
1212import org .phoebus .ui .javafx .ImageCache ;
1313import org .phoebus .ui .spi .MenuEntry ;
1414
1515import javafx .scene .image .Image ;
16+ import org .phoebus .ui .web .WebBrowserApplication ;
17+
18+ import java .io .File ;
19+ import java .net .URI ;
20+ import java .net .URISyntaxException ;
21+ import java .util .logging .Level ;
22+
23+ import static org .phoebus .ui .application .PhoebusApplication .logger ;
1624
1725/** Menu entry to open help
1826 * @author Kay Kasemir
@@ -23,7 +31,7 @@ public class OpenHelp implements MenuEntry
2331 @ Override
2432 public String getName ()
2533 {
26- return HelpApplication . DISPLAY_NAME ;
34+ return Messages . Help ;
2735 }
2836
2937 @ Override
@@ -41,7 +49,39 @@ public Image getIcon()
4149 @ Override
4250 public Void call ()
4351 {
44- ApplicationService .createInstance (HelpApplication .NAME );
52+ try {
53+ URI helpLocationURI = new URI (determineHelpLocation ());
54+ WebBrowserApplication webBrowserApplication = new WebBrowserApplication ();
55+ webBrowserApplication .create (helpLocationURI );
56+ } catch (URISyntaxException uriSyntaxException ) {
57+ throw new RuntimeException (uriSyntaxException );
58+ }
4559 return null ;
4660 }
61+
62+ public static String determineHelpLocation ()
63+ {
64+ final File phoenix_install = Locations .install ();
65+
66+ // The distribution includes a lib/ and a doc/ folder.
67+ // Check for the doc/index.html
68+ File loc = new File (phoenix_install , "doc/index.html" );
69+ if (loc .exists ())
70+ return loc .toURI ().toString ();
71+
72+ // During development,
73+ // product is started from IDE as ....../git/phoebus/phoebus-product.
74+ // Check for copy of docs in ....../git/phoebus/docs/build/html
75+ loc = new File (phoenix_install , "docs" );
76+ if (loc .exists ())
77+ {
78+ loc = new File (loc , "build/html/index.html" );
79+ if (loc .exists ())
80+ return loc .toURI ().toString ();
81+ logger .log (Level .WARNING , "Found phoebus-doc repository, but no build/html/index.html. Run 'make html'" );
82+ }
83+
84+ // Fall back to online copy of the manual
85+ return "https://control-system-studio.readthedocs.io" ;
86+ }
4787}
0 commit comments