Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on WebView #27

Merged
merged 1 commit into from
Aug 21, 2019
Merged

Remove dependency on WebView #27

merged 1 commit into from
Aug 21, 2019

Conversation

j-lum
Copy link
Member

@j-lum j-lum commented Aug 5, 2019

The help command is the only command 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 the help command to
output a URL to the user guide instead.

@CanIHasReview-bot
Copy link

Click here to submit a new iteration when this PR is ready for review.

See this repository's contribution guide for more information.

@CanIHasReview-bot
Copy link

v1

@j-lum submitted v1 for review.

(📚 Archive)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level3.git refs/pr/27/1/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@damithc
Copy link
Contributor

damithc commented Aug 5, 2019

There is a Travis error though. Fix and do a v2?

@j-lum
Copy link
Member Author

j-lum commented Aug 5, 2019

Completely forgot to show whitespace on my home setup.

@CanIHasReview-bot
Copy link

v2

@j-lum submitted v2 for review.

(📚 Archive) (📈 Interdiff between v1 and v2) (📈 Range-Diff between v1 and v2)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level3.git refs/pr/27/2/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@j-lum j-lum force-pushed the remove-webview branch 3 times, most recently from 0acf9e4 to eae5dcc Compare August 5, 2019 10:51
@j-lum
Copy link
Member Author

j-lum commented Aug 5, 2019

I missed out some things in the initial commit.

  • Remove HelpWindow.adoc
  • Remove Gradle tasks that copy HelpWindow into resource folder

@CanIHasReview-bot
Copy link

v3

@j-lum submitted v3 for review.

(📚 Archive) (📈 Interdiff between v2 and v3) (📈 Range-Diff between v2 and v3)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level3.git refs/pr/27/3/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

Copy link
Collaborator

@pyokagan pyokagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I thought that the HelpWindow also doubles as an example of how to write and show a dialog box. May want to check with @damithc about that.

If you want to remove the help window, you'll need the following additional changes to properly remove it:

diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc
index 4e5d297a..51d7e6f3 100644
--- a/docs/UserGuide.adoc
+++ b/docs/UserGuide.adoc
@@ -30,7 +30,7 @@ AddressBook Level 3 (AB3) is for those who *prefer to use a desktop app for mana
 image::Ui.png[width="790"]
 +
 .  Type the command in the command box and press kbd:[Enter] to execute it. +
-e.g. typing *`help`* and pressing kbd:[Enter] will open the help window.
+e.g. typing *`help`* and pressing kbd:[Enter] will display a link to the user guide.
 .  Some example commands you can try:
 
 * *`list`* : lists all contacts
diff --git a/src/main/java/seedu/address/logic/commands/CommandResult.java b/src/main/java/seedu/address/logic/commands/CommandResult.java
index 92f900b7..fead1d42 100644
--- a/src/main/java/seedu/address/logic/commands/CommandResult.java
+++ b/src/main/java/seedu/address/logic/commands/CommandResult.java
@@ -11,18 +11,14 @@ public class CommandResult {
 
     private final String feedbackToUser;
 
-    /** Help information should be shown to the user. */
-    private final boolean showHelp;
-
     /** The application should exit. */
     private final boolean exit;
 
     /**
      * Constructs a {@code CommandResult} with the specified fields.
      */
-    public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
+    public CommandResult(String feedbackToUser, boolean exit) {
         this.feedbackToUser = requireNonNull(feedbackToUser);
-        this.showHelp = showHelp;
         this.exit = exit;
     }
 
@@ -31,17 +27,13 @@ public class CommandResult {
      * and other fields set to their default value.
      */
     public CommandResult(String feedbackToUser) {
-        this(feedbackToUser, false, false);
+        this(feedbackToUser, false);
     }
 
     public String getFeedbackToUser() {
         return feedbackToUser;
     }
 
-    public boolean isShowHelp() {
-        return showHelp;
-    }
-
     public boolean isExit() {
         return exit;
     }
@@ -59,13 +51,12 @@ public class CommandResult {
 
         CommandResult otherCommandResult = (CommandResult) other;
         return feedbackToUser.equals(otherCommandResult.feedbackToUser)
-                && showHelp == otherCommandResult.showHelp
                 && exit == otherCommandResult.exit;
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(feedbackToUser, showHelp, exit);
+        return Objects.hash(feedbackToUser, exit);
     }
 
 }
diff --git a/src/main/java/seedu/address/logic/commands/ExitCommand.java b/src/main/java/seedu/address/logic/commands/ExitCommand.java
index 3dd85a8b..e950db1c 100644
--- a/src/main/java/seedu/address/logic/commands/ExitCommand.java
+++ b/src/main/java/seedu/address/logic/commands/ExitCommand.java
@@ -13,7 +13,7 @@ public class ExitCommand extends Command {
 
     @Override
     public CommandResult execute(Model model) {
-        return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true);
+        return new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, true);
     }
 
 }
diff --git a/src/test/java/seedu/address/logic/commands/CommandResultTest.java b/src/test/java/seedu/address/logic/commands/CommandResultTest.java
index 4f3eb46e..7e48bb18 100644
--- a/src/test/java/seedu/address/logic/commands/CommandResultTest.java
+++ b/src/test/java/seedu/address/logic/commands/CommandResultTest.java
@@ -14,7 +14,7 @@ public class CommandResultTest {
 
         // same values -> returns true
         assertTrue(commandResult.equals(new CommandResult("feedback")));
-        assertTrue(commandResult.equals(new CommandResult("feedback", false, false)));
+        assertTrue(commandResult.equals(new CommandResult("feedback", false)));
 
         // same object -> returns true
         assertTrue(commandResult.equals(commandResult));
@@ -28,11 +28,8 @@ public class CommandResultTest {
         // different feedbackToUser value -> returns false
         assertFalse(commandResult.equals(new CommandResult("different")));
 
-        // different showHelp value -> returns false
-        assertFalse(commandResult.equals(new CommandResult("feedback", true, false)));
-
         // different exit value -> returns false
-        assertFalse(commandResult.equals(new CommandResult("feedback", false, true)));
+        assertFalse(commandResult.equals(new CommandResult("feedback", true)));
     }
 
     @Test
@@ -45,10 +42,7 @@ public class CommandResultTest {
         // different feedbackToUser value -> returns different hashcode
         assertNotEquals(commandResult.hashCode(), new CommandResult("different").hashCode());
 
-        // different showHelp value -> returns different hashcode
-        assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", true, false).hashCode());
-
         // different exit value -> returns different hashcode
-        assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", false, true).hashCode());
+        assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", true).hashCode());
     }
 }
diff --git a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java
index 9533c473..3fbc5eb7 100644
--- a/src/test/java/seedu/address/logic/commands/ExitCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/ExitCommandTest.java
@@ -14,7 +14,7 @@ public class ExitCommandTest {
 
     @Test
     public void execute_exit_success() {
-        CommandResult expectedCommandResult = new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, false, true);
+        CommandResult expectedCommandResult = new CommandResult(MESSAGE_EXIT_ACKNOWLEDGEMENT, true);
         assertCommandSuccess(new ExitCommand(), model, expectedCommandResult, expectedModel);
     }
 }

But imo it's much more intrusive (aka harder to merge changes from AB4) compared to keeping the HelpWindow but replacing the WebView with a label or something. Might even be able to add a JavaFX hyperlink widget or something.

Also, I'm not sure why https://github.com/se-edu/addressbook-level3/blob/master/docs/UserGuide.adoc was chosen as the URL compared to https://se-education.org/addressbook-level3/UserGuide.html which is usually what users would expect to see as a user guide. In fact, before se-edu/addressbook-level4@6ec9b68 that was the URL we used.

Can merge once you've made the changes and are reasonably confident of the results. Otherwise ask again for a review.

@@ -34,7 +34,6 @@ Do not disable them. If you have disabled them, go to `File` > `Settings` > `Plu
. 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence also needs to be deleted as well.

Copy link
Collaborator

@pyokagan pyokagan Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed this comment in the previous review:

This sentence also needs to be deleted as well.

This was added in 1488051, with obvious reference to the processResources task, so if the processResources task is being removed it makes sense to remove this as well.

Anyway, it is not precise to say that "pressing OK would generate all resources required by the application and tests." anyway, since we don't have any resources to generate.

@damithc
Copy link
Contributor

damithc commented Aug 6, 2019

Eh, I thought that the HelpWindow also doubles as an example of how to write and show a dialog box. May want to check with @damithc about that.

Yes, that's a good idea. @j-lum can?

Also, I'm not sure why https://github.com/se-edu/addressbook-level3/blob/master/docs/UserGuide.adoc was chosen as the URL compared to https://se-education.org/addressbook-level3/UserGuide.html which is usually what users would expect to see as a user guide. In fact, before se-edu/addressbook-level4@6ec9b68 that was the URL we used.

Yes, it is better to use the html link.

@j-lum
Copy link
Member Author

j-lum commented Aug 6, 2019

Actually replacing the original webview with a label looks like the path of least resistance so let's do that for now.

I linked the adoc because I'm worried that some students won't be on netlify. Will change the official copy to link to html page.

@damithc
Copy link
Contributor

damithc commented Aug 6, 2019

Actually replacing the original webview with a label looks like the path of least resistance so let's do that for now.

Yes, let's do that. Plus, it gives students an example of opening child windows.

I linked the adoc because I'm worried that some students won't be on netlify. Will change the official copy to link to html page.

Netlify preview is optional but auto-publishing (via Travis) is a requirement i.e., the html link will work in all projects.

@damithc
Copy link
Contributor

damithc commented Aug 15, 2019

@j-lum Let's resume this.

@damithc
Copy link
Contributor

damithc commented Aug 19, 2019

Let's wrap this up in and do a release by Thursday. Students are expected to download AB3 jar file starting from this Friday.

@j-lum
Copy link
Member Author

j-lum commented Aug 19, 2019

I iterated through a bunch of layouts for HelpWindow and eventually settled on this:
image

Other things I've tried are:
Using an immutable TextField to display the URL results in having some really funky code to resize the TextField.

Just the plain Label is not helpful as the user cannot copy the label.

Hyperlinks are a mess in JavaFX.

Images in buttons are a bit overkill just for a clipboard icon so I went with the unicode emoji.

@j-lum
Copy link
Member Author

j-lum commented Aug 19, 2019

Eh CIHR bot failed with an unknown error with an ID: job-090a7c34-103a-494a-b190-6d67961f24bb so I'm just manually flipping the status for now.

@canihasreview
Copy link

canihasreview bot commented Aug 19, 2019

v4

@pyokagan submitted v4 for review.

(📚 Archive) (📈 Interdiff between v3 and v4) (📈 Range-Diff between v3 and v4)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level3.git refs/pr/27/4/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@canihasreview canihasreview bot requested a review from pyokagan August 19, 2019 10:36
@pyokagan
Copy link
Collaborator

Eh CIHR bot failed with an unknown error with an ID: job-090a7c34-103a-494a-b190-6d67961f24bb so I'm just manually flipping the status for now.

The logs say:

Running git ["push","-f","origin","+refs/pr/27/4/*:refs/pr/27/4/*"]
remote: fatal error in commit_refs
To https://github.com/se-edu/addressbook-level3.git
 ! [remote rejected] refs/pr/27/4/base -> refs/pr/27/4/base (failure)
 ! [remote rejected] refs/pr/27/4/head -> refs/pr/27/4/head (failure)
 ! [remote rejected] refs/pr/27/4/interdiff -> refs/pr/27/4/interdiff (failure)
 ! [remote rejected] refs/pr/27/4/rangediff -> refs/pr/27/4/rangediff (failure)
error: failed to push some refs to 'https://github.com/se-edu/addressbook-level3.git'

Disabling branch protection seems to solve it, but the generic remote: fatal error in commit_refs error message from GitHub makes me think it's a bug on GitHub's side. Unfortunately I'm having trouble reproducing it with a new repo :-(

Copy link
Collaborator

@pyokagan pyokagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove dependencies on WebView

The `help` command is the only command that relies on WebView, a

Suggestion: The wording "the help command" made sense in the previous iteration because we were modifying the help command directly, but maybe with the change in approach in this commit "help command" should
be changed to "Help Window"?

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 the `help` command to

Here as well.

output a URL to the user guide instead.

HelpWindow.adoc should be removed if it is not being used?


I get this error on Linux:

java.lang.ArrayIndexOutOfBoundsException: Index -7 out of bounds for length 32
        at com.sun.prism.impl.GlyphCache.getCachedGlyph(GlyphCache.java:332)
        at com.sun.prism.impl.GlyphCache.render(GlyphCache.java:148)
        at com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2101)
        at com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312)
        at com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270)
        at com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
        at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
        at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
        at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
        at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
        at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
        at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
        at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
        at java.base/java.lang.Thread.run(Thread.java:834)

and the help window does not open at all.


Also, I get this warning logged to console:

WARNING: Loading FXML document with JavaFX API of version 11.0.1 by JavaFX runtime of version 11

It's harmless, but from past experience I know that students will ask questions about that ;-)


I see the addition of the removal of javafx-media in the interdiff as well. I guess we probably didn't need it in the first place (and it's independent of whether we are using the web browser or not), but if that's so then it should be mentioned in the commit message, otherwise if devs need to revert this commit in the future they may bring the javafx-media dependency back.

@@ -34,7 +34,6 @@ Do not disable them. If you have disabled them, go to `File` > `Settings` > `Plu
. 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.
Copy link
Collaborator

@pyokagan pyokagan Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed this comment in the previous review:

This sentence also needs to be deleted as well.

This was added in 1488051, with obvious reference to the processResources task, so if the processResources task is being removed it makes sense to remove this as well.

Anyway, it is not precise to say that "pressing OK would generate all resources required by the application and tests." anyway, since we don't have any resources to generate.

<?import javafx.scene.image.Image?>
<?import javafx.scene.web.WebView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.stage.Stage?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange that javafx.stage.Stage is being imported here even though it is not used in the FXML file.

If it was generated by Gluon Scenebuilder then nevermind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's generated by scenebuilder so I didn't touch it.

@pyokagan
Copy link
Collaborator

This was added in 1488051, with obvious reference to the processResources task, so if the processResources task is being removed it makes sense to remove this as well.

Also, as the commit 1488051 shows, we should probably be removing the "HelpWindowTest" troubleshooting entry in Testing.adoc :-P

@j-lum
Copy link
Member Author

j-lum commented Aug 19, 2019

I was under the impression that media was brought in because it was a dependency that web relies on as the JavaFX plugin pulls media in when web is required.

From https://github.com/openjfx/javafx-gradle-plugin/blob/master/src/main/java/org/openjfx/gradle/JavaFXModule.java :

public enum JavaFXModule {
    BASE,
    GRAPHICS(BASE),
    CONTROLS(BASE, GRAPHICS),
    FXML(BASE, GRAPHICS),
    MEDIA(BASE, GRAPHICS),
    SWING(BASE, GRAPHICS),
    WEB(BASE, CONTROLS, GRAPHICS, MEDIA);
//...
}

I could go to the fxml and manually change the version of JavaFX to 11 to fix the warning.

Your exception seems to be problem with emojis: javafxports/openjdk-jfx#287 . I'll purge the clipboard😢. It works fine on my VM though, so it might be a distro issue that I'm not really willing to fix.

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.
@canihasreview
Copy link

canihasreview bot commented Aug 19, 2019

v5

@j-lum submitted v5 for review.

(📚 Archive) (📈 Interdiff between v4 and v5) (📈 Range-Diff between v4 and v5)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level3.git refs/pr/27/5/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@canihasreview canihasreview bot requested a review from pyokagan August 19, 2019 14:05
@pyokagan
Copy link
Collaborator

I was under the impression that media was brought in because it was a dependency that web relies on as the JavaFX plugin pulls media in when web is required.

From https://github.com/openjfx/javafx-gradle-plugin/blob/master/src/main/java/org/openjfx/gradle/JavaFXModule.java :

public enum JavaFXModule {
    BASE,
    GRAPHICS(BASE),
    CONTROLS(BASE, GRAPHICS),
    FXML(BASE, GRAPHICS),
    MEDIA(BASE, GRAPHICS),
    SWING(BASE, GRAPHICS),
    WEB(BASE, CONTROLS, GRAPHICS, MEDIA);
//...
}

Ah OK, that sounds good.

I could go to the fxml and manually change the version of JavaFX to 11 to fix the warning.

Yes, that sounds good for this PR. However, if students use Gluon SceneBuilder in the future they would get this issue again, so it might be good to upgrade to JavaFX 11.0.1 in another commit.

Your exception seems to be problem with emojis: javafxports/openjdk-jfx#287 . I'll purge the clipboardcry. It works fine on my VM though, so it might be a distro issue that I'm not really willing to fix.

Great, it works for me now 👍

Copy link
Collaborator

@pyokagan pyokagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, just one side-note.

. 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.
Copy link
Collaborator

@pyokagan pyokagan Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unnecessary change. Avoid them or move it into another commit in the future.

@damithc
Copy link
Contributor

damithc commented Aug 21, 2019

Great. Almost there.
@j-lum can merge this and do a release?

@j-lum j-lum merged commit f594ed0 into se-edu:master Aug 21, 2019
j-lum added a commit to j-lum/addressbook-level3 that referenced this pull request Aug 29, 2019
Address a regression in PR se-edu#27 where subsequent `help` commands will 
spawn a `HelpWindow` maximized, covering the screen.
Disable the maximize button completely as it serves no purpose.
@j-lum j-lum deleted the remove-webview branch May 26, 2020 13:00
ShiJiaAo pushed a commit to ShiJiaAo/addressbook-level3 that referenced this pull request Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants