From ebbb7131ecdb83f2512b79068f952d37f69784b5 Mon Sep 17 00:00:00 2001 From: Jeffry Lum <22460123+j-lum@users.noreply.github.com> Date: Mon, 19 Aug 2019 16:58:06 +0800 Subject: [PATCH] Remove dependencies on WebView The HelpWindow is the only component that relies on WebView, a dependency that weighs in at around 70MB, more than quadrupling the size of the executable jar. As there are plans to customize the jars for each individual student during the practical examination, this overhead can lead to further problems (bandwidth in the lecture hall, storage space, etc). Let's remove the dependency on WebView by changing HelpWindow to display a link to the user guide instead. --- build.gradle | 19 ------------ docs/HelpWindow.adoc | 3 -- docs/SettingUp.adoc | 4 +-- docs/Testing.adoc | 5 --- .../java/seedu/address/ui/HelpWindow.java | 30 ++++++++++++++---- src/main/resources/view/HelpWindow.fxml | 31 ++++++++++++++++--- 6 files changed, 52 insertions(+), 40 deletions(-) delete mode 100644 docs/HelpWindow.adoc diff --git a/build.gradle b/build.gradle index 5f8902633..93029ef82 100644 --- a/build.gradle +++ b/build.gradle @@ -57,12 +57,6 @@ dependencies { implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux' - implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'win' - implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'mac' - implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'linux' - implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'win' - implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'mac' - implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'linux' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0' implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4' @@ -158,17 +152,4 @@ task copyStylesheets(type: Copy) { } asciidoctor.dependsOn copyStylesheets -task deployOfflineDocs(type: Copy) { - into('src/main/resources/docs') - - from ("${asciidoctor.outputDir}/html5") { - include 'stylesheets/*' - include 'images/*' - include 'HelpWindow.html' - } -} - -deployOfflineDocs.dependsOn asciidoctor -processResources.dependsOn deployOfflineDocs - defaultTasks 'clean', 'test', 'coverage', 'asciidoctor' diff --git a/docs/HelpWindow.adoc b/docs/HelpWindow.adoc deleted file mode 100644 index bfdae9919..000000000 --- a/docs/HelpWindow.adoc +++ /dev/null @@ -1,3 +0,0 @@ -:no-site-header: - -include::UserGuide.adoc[] diff --git a/docs/SettingUp.adoc b/docs/SettingUp.adoc index 28201aeec..c0659782f 100644 --- a/docs/SettingUp.adoc +++ b/docs/SettingUp.adoc @@ -33,9 +33,7 @@ Do not disable them. If you have disabled them, go to `File` > `Settings` > `Plu . Click `Import Project` . Locate the `build.gradle` file and select it. Click `OK` . Click `Open as Project` -. Click `OK` to accept the default settings -. Open a console and run the command `gradlew processResources` (Mac/Linux: `./gradlew processResources`). It should finish with the `BUILD SUCCESSFUL` message. + -This will generate all resources required by the application and tests. +. Click `OK` to accept the default settings. == Verifying the setup diff --git a/docs/Testing.adoc b/docs/Testing.adoc index bacbae172..5767b9291 100644 --- a/docs/Testing.adoc +++ b/docs/Testing.adoc @@ -43,11 +43,6 @@ e.g. `seedu.address.logic.LogicManagerTest` == Troubleshooting Testing -**Problem: `HelpWindowTest` fails with a `NullPointerException`.** - -* Reason: One of its dependencies, `HelpWindow.html` in `src/main/resources/docs` is missing. -* Solution: Execute Gradle task `processResources`. - **Problem: Keyboard and mouse movements are not simulated on macOS Mojave, resulting in GUI Tests failure.** * Reason: From macOS Mojave onwards, applications without `Accessibility` permission cannot simulate certain keyboard and mouse movements. diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/seedu/address/ui/HelpWindow.java index 22606d102..7a27ad098 100644 --- a/src/main/java/seedu/address/ui/HelpWindow.java +++ b/src/main/java/seedu/address/ui/HelpWindow.java @@ -3,7 +3,10 @@ import java.util.logging.Logger; import javafx.fxml.FXML; -import javafx.scene.web.WebView; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.input.Clipboard; +import javafx.scene.input.ClipboardContent; import javafx.stage.Stage; import seedu.address.commons.core.LogsCenter; @@ -12,13 +15,17 @@ */ public class HelpWindow extends UiPart { - public static final String USERGUIDE_FILE_PATH = "/docs/HelpWindow.html"; + public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html"; + public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL; private static final Logger logger = LogsCenter.getLogger(HelpWindow.class); private static final String FXML = "HelpWindow.fxml"; @FXML - private WebView browser; + private Button copyButton; + + @FXML + private Label helpMessage; /** * Creates a new HelpWindow. @@ -27,9 +34,8 @@ public class HelpWindow extends UiPart { */ public HelpWindow(Stage root) { super(FXML, root); - - String userGuideUrl = getClass().getResource(USERGUIDE_FILE_PATH).toString(); - browser.getEngine().load(userGuideUrl); + helpMessage.setText(HELP_MESSAGE); + root.sizeToScene(); } /** @@ -60,6 +66,7 @@ public HelpWindow() { public void show() { logger.fine("Showing help page about the application."); getRoot().show(); + getRoot().centerOnScreen(); } /** @@ -82,4 +89,15 @@ public void hide() { public void focus() { getRoot().requestFocus(); } + + /** + * Copies the URL to the user guide to the clipboard. + */ + @FXML + private void copyUrl() { + final Clipboard clipboard = Clipboard.getSystemClipboard(); + final ClipboardContent url = new ClipboardContent(); + url.putString(USERGUIDE_URL); + clipboard.setContent(url); + } } diff --git a/src/main/resources/view/HelpWindow.fxml b/src/main/resources/view/HelpWindow.fxml index c07e8e685..a16c28524 100644 --- a/src/main/resources/view/HelpWindow.fxml +++ b/src/main/resources/view/HelpWindow.fxml @@ -1,18 +1,41 @@ + + + - + + - + + - + + + + + + + + + + + +