|
7 | 7 | *******************************************************************************/ |
8 | 8 | package org.phoebus.ui.help; |
9 | 9 |
|
| 10 | +import org.phoebus.framework.workbench.Locations; |
10 | 11 | import org.phoebus.ui.application.Messages; |
11 | 12 | import org.phoebus.ui.javafx.ImageCache; |
12 | 13 | import org.phoebus.ui.spi.MenuEntry; |
13 | 14 |
|
14 | 15 | import javafx.scene.image.Image; |
15 | 16 | import org.phoebus.ui.web.WebBrowserApplication; |
16 | 17 |
|
| 18 | +import java.io.File; |
17 | 19 | import java.net.URI; |
18 | 20 | import java.net.URISyntaxException; |
| 21 | +import java.util.logging.Level; |
| 22 | + |
| 23 | +import static org.phoebus.ui.application.PhoebusApplication.logger; |
19 | 24 |
|
20 | 25 | /** Menu entry to open help |
21 | 26 | * @author Kay Kasemir |
@@ -45,12 +50,38 @@ public Image getIcon() |
45 | 50 | public Void call() |
46 | 51 | { |
47 | 52 | try { |
48 | | - URI helpLocationURI = new URI(HelpBrowser.determineHelpLocation()); |
| 53 | + URI helpLocationURI = new URI(determineHelpLocation()); |
49 | 54 | WebBrowserApplication webBrowserApplication = new WebBrowserApplication(); |
50 | 55 | webBrowserApplication.create(helpLocationURI); |
51 | 56 | } catch (URISyntaxException uriSyntaxException) { |
52 | 57 | throw new RuntimeException(uriSyntaxException); |
53 | 58 | } |
54 | 59 | return null; |
55 | 60 | } |
| 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 | + } |
56 | 87 | } |
0 commit comments