Skip to content

Commit ebbb713

Browse files
committed
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.
1 parent 9acaf04 commit ebbb713

File tree

6 files changed

+52
-40
lines changed

6 files changed

+52
-40
lines changed

build.gradle

-19
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ dependencies {
5757
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
5858
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
5959
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
60-
implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'win'
61-
implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'mac'
62-
implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'linux'
63-
implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'win'
64-
implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'mac'
65-
implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'linux'
6660

6761
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
6862
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'
@@ -158,17 +152,4 @@ task copyStylesheets(type: Copy) {
158152
}
159153
asciidoctor.dependsOn copyStylesheets
160154

161-
task deployOfflineDocs(type: Copy) {
162-
into('src/main/resources/docs')
163-
164-
from ("${asciidoctor.outputDir}/html5") {
165-
include 'stylesheets/*'
166-
include 'images/*'
167-
include 'HelpWindow.html'
168-
}
169-
}
170-
171-
deployOfflineDocs.dependsOn asciidoctor
172-
processResources.dependsOn deployOfflineDocs
173-
174155
defaultTasks 'clean', 'test', 'coverage', 'asciidoctor'

docs/HelpWindow.adoc

-3
This file was deleted.

docs/SettingUp.adoc

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ Do not disable them. If you have disabled them, go to `File` > `Settings` > `Plu
3333
. Click `Import Project`
3434
. Locate the `build.gradle` file and select it. Click `OK`
3535
. Click `Open as Project`
36-
. Click `OK` to accept the default settings
37-
. Open a console and run the command `gradlew processResources` (Mac/Linux: `./gradlew processResources`). It should finish with the `BUILD SUCCESSFUL` message. +
38-
This will generate all resources required by the application and tests.
36+
. Click `OK` to accept the default settings.
3937

4038
== Verifying the setup
4139

docs/Testing.adoc

-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ e.g. `seedu.address.logic.LogicManagerTest`
4343

4444

4545
== Troubleshooting Testing
46-
**Problem: `HelpWindowTest` fails with a `NullPointerException`.**
47-
48-
* Reason: One of its dependencies, `HelpWindow.html` in `src/main/resources/docs` is missing.
49-
* Solution: Execute Gradle task `processResources`.
50-
5146
**Problem: Keyboard and mouse movements are not simulated on macOS Mojave, resulting in GUI Tests failure.**
5247

5348
* Reason: From macOS Mojave onwards, applications without `Accessibility` permission cannot simulate certain keyboard and mouse movements.

src/main/java/seedu/address/ui/HelpWindow.java

+24-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import java.util.logging.Logger;
44

55
import javafx.fxml.FXML;
6-
import javafx.scene.web.WebView;
6+
import javafx.scene.control.Button;
7+
import javafx.scene.control.Label;
8+
import javafx.scene.input.Clipboard;
9+
import javafx.scene.input.ClipboardContent;
710
import javafx.stage.Stage;
811
import seedu.address.commons.core.LogsCenter;
912

@@ -12,13 +15,17 @@
1215
*/
1316
public class HelpWindow extends UiPart<Stage> {
1417

15-
public static final String USERGUIDE_FILE_PATH = "/docs/HelpWindow.html";
18+
public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html";
19+
public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL;
1620

1721
private static final Logger logger = LogsCenter.getLogger(HelpWindow.class);
1822
private static final String FXML = "HelpWindow.fxml";
1923

2024
@FXML
21-
private WebView browser;
25+
private Button copyButton;
26+
27+
@FXML
28+
private Label helpMessage;
2229

2330
/**
2431
* Creates a new HelpWindow.
@@ -27,9 +34,8 @@ public class HelpWindow extends UiPart<Stage> {
2734
*/
2835
public HelpWindow(Stage root) {
2936
super(FXML, root);
30-
31-
String userGuideUrl = getClass().getResource(USERGUIDE_FILE_PATH).toString();
32-
browser.getEngine().load(userGuideUrl);
37+
helpMessage.setText(HELP_MESSAGE);
38+
root.sizeToScene();
3339
}
3440

3541
/**
@@ -60,6 +66,7 @@ public HelpWindow() {
6066
public void show() {
6167
logger.fine("Showing help page about the application.");
6268
getRoot().show();
69+
getRoot().centerOnScreen();
6370
}
6471

6572
/**
@@ -82,4 +89,15 @@ public void hide() {
8289
public void focus() {
8390
getRoot().requestFocus();
8491
}
92+
93+
/**
94+
* Copies the URL to the user guide to the clipboard.
95+
*/
96+
@FXML
97+
private void copyUrl() {
98+
final Clipboard clipboard = Clipboard.getSystemClipboard();
99+
final ClipboardContent url = new ClipboardContent();
100+
url.putString(USERGUIDE_URL);
101+
clipboard.setContent(url);
102+
}
85103
}
+27-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3+
<?import javafx.geometry.Insets?>
34
<?import javafx.scene.Scene?>
5+
<?import javafx.scene.control.Button?>
6+
<?import javafx.scene.control.Label?>
47
<?import javafx.scene.image.Image?>
5-
<?import javafx.scene.web.WebView?>
8+
<?import javafx.scene.layout.HBox?>
9+
<?import javafx.stage.Stage?>
610

711
<!-- TODO: set a more appropriate initial size -->
8-
<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
9-
title="Help" maximized="true">
12+
13+
<fx:root maximized="true" title="Help" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
1014
<icons>
1115
<Image url="@/images/help_icon.png" />
1216
</icons>
1317
<scene>
1418
<Scene>
15-
<WebView fx:id="browser" />
19+
<HBox alignment="CENTER">
20+
<children>
21+
<Label fx:id="helpMessage" text="Label">
22+
<HBox.margin>
23+
<Insets right="5.0" />
24+
</HBox.margin>
25+
</Label>
26+
<Button fx:id="copyButton" mnemonicParsing="false" onAction="#copyUrl" text="Copy URL">
27+
<HBox.margin>
28+
<Insets left="5.0" />
29+
</HBox.margin>
30+
</Button>
31+
</children>
32+
<opaqueInsets>
33+
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" />
34+
</opaqueInsets>
35+
<padding>
36+
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" />
37+
</padding>
38+
</HBox>
1639
</Scene>
1740
</scene>
1841
</fx:root>

0 commit comments

Comments
 (0)