Skip to content

Commit

Permalink
Merge pull request #27 from j-lum/remove-webview
Browse files Browse the repository at this point in the history
Remove dependency on WebView
  • Loading branch information
j-lum authored Aug 21, 2019
2 parents 9acaf04 + ebbb713 commit f594ed0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 40 deletions.
19 changes: 0 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
3 changes: 0 additions & 3 deletions docs/HelpWindow.adoc

This file was deleted.

4 changes: 1 addition & 3 deletions docs/SettingUp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions docs/Testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
30 changes: 24 additions & 6 deletions src/main/java/seedu/address/ui/HelpWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,13 +15,17 @@
*/
public class HelpWindow extends UiPart<Stage> {

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.
Expand All @@ -27,9 +34,8 @@ public class HelpWindow extends UiPart<Stage> {
*/
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();
}

/**
Expand Down Expand Up @@ -60,6 +66,7 @@ public HelpWindow() {
public void show() {
logger.fine("Showing help page about the application.");
getRoot().show();
getRoot().centerOnScreen();
}

/**
Expand All @@ -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);
}
}
31 changes: 27 additions & 4 deletions src/main/resources/view/HelpWindow.fxml
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.web.WebView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.stage.Stage?>

<!-- TODO: set a more appropriate initial size -->
<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
title="Help" maximized="true">

<fx:root maximized="true" title="Help" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<icons>
<Image url="@/images/help_icon.png" />
</icons>
<scene>
<Scene>
<WebView fx:id="browser" />
<HBox alignment="CENTER">
<children>
<Label fx:id="helpMessage" text="Label">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
</Label>
<Button fx:id="copyButton" mnemonicParsing="false" onAction="#copyUrl" text="Copy URL">
<HBox.margin>
<Insets left="5.0" />
</HBox.margin>
</Button>
</children>
<opaqueInsets>
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" />
</opaqueInsets>
<padding>
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" />
</padding>
</HBox>
</Scene>
</scene>
</fx:root>

0 comments on commit f594ed0

Please sign in to comment.