diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..f4a4102b77 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +language: java +jdk: openjdk11 \ No newline at end of file diff --git "a/\\" "b/\\" new file mode 100644 index 0000000000..ea909b4cbb --- /dev/null +++ "b/\\" @@ -0,0 +1,6 @@ +Merge branch 'branch-Level-7' +# Please enter a commit message to explain why this merge is necessary, +# especially if it merges an updated upstream into a topic branch. +# +# Lines starting with '#' will be ignored, and an empty message aborts +# the commit. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..e2964b9d87 --- /dev/null +++ b/build.gradle @@ -0,0 +1,54 @@ +plugins { + id 'java' + id 'application' + id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'checkstyle' + id 'org.openjfx.javafxplugin' version '0.0.7' +} + +shadowJar { + archiveBaseName = "duke" + archiveVersion = "0.1.3" + archiveClassifier = null + archiveAppendix = null +} + +checkstyle { + toolVersion = '8.23' +} + +repositories { + mavenCentral() +} + +javafx { + version = "11.0.2" + modules = [ 'javafx.controls', 'javafx.fxml' ] +} + +group 'seedu.duke' +version '0.1.0' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'junit:junit:4.12' + implementation 'junit:junit:4.12' + implementation 'junit:junit:4.12' + implementation 'junit:junit:4.12' + implementation 'junit:junit:4.12' + implementation 'junit:junit:4.12' + implementation 'junit:junit:4.12' + implementation 'junit:junit:4.12' +} + +application { + // Change this to your main class. + mainClassName = "Launcher" +} + +run { + standardInput = System.in +} \ No newline at end of file diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000000..b1a57ba6c0 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/duke.txt b/data/duke.txt new file mode 100644 index 0000000000..4c7e2d7184 --- /dev/null +++ b/data/duke.txt @@ -0,0 +1,5 @@ +T , 0 , read book +T , 0 , mow lawn +T , 0 , feed dogs +E , 1 , book fair , 25 Jan 07 +D , 0 , quiz , 2020-11-02 diff --git a/docs/README.md b/docs/README.md index fd44069597..3d9525a59b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,20 +1,169 @@ # User Guide -## Features +## Introduction +![GUI](Ui.png) -### Feature 1 -Description of feature. +Duke is a Chatbot Personal Assistant to help keep track of various types of **tasks**. -## Usage +The types of tasks are: +1. **Todo** + - Tasks with no attached attached date/time. +2. **Event** + - Tasks that have a start and end date/time +3. **Deadline** + - Tasks to be completed by a certain date. -### `Keyword` - Describe action +Duke can: +1. Add task +2. Delete task +3. Complete task +4. List all tasks +5. Find tasks based on keyword +6. Sort tasks +7. Exit +# Features: -Describe action and its outcome. +## 1. Add task +The type of task that can be added are: +1. todo +2. event +3. deadline + +### Usage + +`todo` - Add new todo + +Format: `todo [name]` + +Provide a name for Duke to associate the todo to. + +Example of usage: `todo read book` + +Expected outcome: + +![Todo Success](todo-expected.png) + +`event` - Add new event + +Format: `event [name] /at [date in ANY format]` + +Provide a name for Duke to associate the event to. + +Example of usage: `event book fair /at 25 Jan 07` + +Expected outcome: + +![Event Success](event-expected.png) + +`deadline` - Add new deadline + +Format: `deadline [name] /by [date in yyyy-mm-dd]` + +Provide a name for Duke to associate the deadline to. Example of usage: -`keyword (optional arguments)` +`deadline submit essay /by 2020-08-06` Expected outcome: -`outcome` +![Deadline Success](deadline-expected.png) + +## 2. Delete task +Delete an existing task. + +### Usage +`delete` - Delete task + +Delete a task based on its index in the list. To find out a task's index, +check using the `list` command. + +Format: +`delete [index]` + +Example of usage: `delete 3` + +Expected outcome: + +![Delete Success](delete-expected.png) + +## 3. Complete task +Complete an existing task. + +### Usage +`done` - Complete a task + +Complete a task and mark it as done based on its index in the list. +To find out a task's index, check using the `list` command. + +Format: +`done [index]` + +Example of usage: `done 2` + +Expected outcome: + +![Done Success](done-expected.png) + +## 4. List all tasks + +Shows all tasks. + +### Usage +`list` - List tasks + +Display list of all tasks. + +Example of usage: `list` + +Expected outcome: + +![List Success](list-expected.png) + +## 5. Find tasks based on keyword + +Finds tasks with names containing the keyword. + +### Usage +`find` - Find task that contains a given keyword + +Returns a list of tasks with names that contain the given keyword. + +Format: +`find [keyword]` + +Example of usage: `find book` + +Expected outcome: + +![Find Success](find-expected.png) + +## 6. Sort Tasks + +Tasks will be sorted by type and date/time. + +When `find` or `list` commands are run, the list generated and displayed +will be sorted by type in the order Todo, Event and Deadline. Deadlines +are sorted chronologically by their date/time. + +## 7. Exit + +Close application + +### Usage +`bye` - Close application + +Returns a list of tasks with names that contain the given keyword. + +Example of usage: `bye` + +## Acknowledgements + +GUI done with +[JavaFX Tutorial](https://github.com/nus-cs2103-AY1920S2/duke/blob/master/tutorials/javaFxTutorialPart4.md) +by [Jeffry Lum](https://github.com/j-lum) + +Da Vinci from https://upload.wikimedia.org/wikipedia/commons/b/ba/Leonardo_self.jpg + +Mona Lisa from +https://upload.wikimedia.org/wikipedia/commons/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg \ No newline at end of file diff --git a/docs/Ui.png b/docs/Ui.png new file mode 100644 index 0000000000..6f11b6577a Binary files /dev/null and b/docs/Ui.png differ diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000000..2f7efbeab5 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-minimal \ No newline at end of file diff --git a/docs/deadline-expected.png b/docs/deadline-expected.png new file mode 100644 index 0000000000..a4e325ac23 Binary files /dev/null and b/docs/deadline-expected.png differ diff --git a/docs/delete-expected.png b/docs/delete-expected.png new file mode 100644 index 0000000000..008ddd534c Binary files /dev/null and b/docs/delete-expected.png differ diff --git a/docs/done-expected.png b/docs/done-expected.png new file mode 100644 index 0000000000..8698c94318 Binary files /dev/null and b/docs/done-expected.png differ diff --git a/docs/event-expected.png b/docs/event-expected.png new file mode 100644 index 0000000000..4a429b5125 Binary files /dev/null and b/docs/event-expected.png differ diff --git a/docs/find-expected.png b/docs/find-expected.png new file mode 100644 index 0000000000..5ffa54da73 Binary files /dev/null and b/docs/find-expected.png differ diff --git a/docs/list-expected.png b/docs/list-expected.png new file mode 100644 index 0000000000..facad77639 Binary files /dev/null and b/docs/list-expected.png differ diff --git a/docs/todo-expected.png b/docs/todo-expected.png new file mode 100644 index 0000000000..027f1b2bfc Binary files /dev/null and b/docs/todo-expected.png differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..87b738cbd0 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..4b7e1f3d38 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000000..af6708ff22 --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000000..6d57edc706 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000000..d1e92fe5db --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'duke' diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java new file mode 100644 index 0000000000..9dd721d790 --- /dev/null +++ b/src/main/java/Deadline.java @@ -0,0 +1,51 @@ +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +/** Deadline is a child class of Task. + * Task that needs to be done before a specific date/time.*/ +public class Deadline extends Task { + String dateString; + LocalDate dateObj; + + /** + * Constructor that takes in 2 params. + * @param name Name of Deadline + * @param dateString Date to finish by + */ + public Deadline(String name, String dateString) { + super(name); + this.dateString = dateString; + dateObj = LocalDate.parse(dateString); + } + + public String getName() { + return this.name; + } + + public boolean getDone() { + return this.done; + } + + public String getClassName() { + return "deadline"; + } + + public LocalDate getDateObj() { + return this.dateObj; + } + + /** + * Converts Deadline into a String to be saved to file. + * @return String to be saved to file + */ + @Override + public String toFile() { + int doneInt = done ? 1 : 0; + return "D , " + doneInt + " , " + name + " , " + dateString; + } + + @Override + public String toString() { + return "[D]" + super.toString() + "(by: " + dateObj.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")"; + } +} diff --git a/src/main/java/DialogBox.java b/src/main/java/DialogBox.java new file mode 100644 index 0000000000..2e751dae69 --- /dev/null +++ b/src/main/java/DialogBox.java @@ -0,0 +1,66 @@ +import java.io.IOException; +import java.util.Collections; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.HBox; + +/** + * An example of a custom control using FXML. + * This control represents a dialog box consisting of an ImageView to represent the speaker's face and a label + * containing text from the speaker. + */ +public class DialogBox extends HBox { + @FXML + private Label dialog; + @FXML + private ImageView displayPicture; + + private DialogBox(String text, Image img) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml")); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + fxmlLoader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + dialog.setText(text); + displayPicture.setImage(img); + } + + /** + * Flips the dialog box such that the ImageView is on the left and text on the right. + */ + private void flip() { + ObservableList tmp = FXCollections.observableArrayList(this.getChildren()); + Collections.reverse(tmp); + getChildren().setAll(tmp); + setAlignment(Pos.TOP_LEFT); + } + + public static DialogBox getUserDialog(String text, Image img) { + return new DialogBox(text, img); + } + + /** + * Text of Duke response. + * + * @param text input text + * @param img duke image + * @return returns a Dialog box + */ + public static DialogBox getDukeDialog(String text, Image img) { + var db = new DialogBox(text, img); + db.flip(); + return db; + } +} \ No newline at end of file diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 5d313334cc..5ccffd1f05 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -1,10 +1,161 @@ -public class Duke { - public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); - } -} +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import javafx.scene.image.Image; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; + + +public class Duke extends Application { + + private ScrollPane scrollPane; + private VBox dialogContainer; + private TextField userInput; + private Button sendButton; + private Scene scene; + private Image user = new Image(this.getClass().getResourceAsStream("/images/DaUser.png")); + private Image duke = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png")); + PrintStream old; + + String filePath; + Storage storage; + TaskList taskList; + + /** + * Method to initialise Duke. + */ + + public Duke() { + filePath = "data/duke.txt"; + try { + storage = new Storage(filePath); + taskList = storage.getTaskList(); // initialise from text file + } catch (IOException e) { + System.out.println(e); + } + } + + @Override + public void start(Stage stage) { + //Step 1. Setting up required components + + //The container for the content of the chat to scroll. + scrollPane = new ScrollPane(); + dialogContainer = new VBox(); + scrollPane.setContent(dialogContainer); + + userInput = new TextField(); + sendButton = new Button("Send"); + + AnchorPane mainLayout = new AnchorPane(); + mainLayout.getChildren().addAll(scrollPane, userInput, sendButton); + + scene = new Scene(mainLayout); + + stage.setScene(scene); + stage.show(); + + //Step 2. Formatting the window to look as expected + stage.setTitle("Duke"); + stage.setResizable(false); + stage.setMinHeight(600.0); + stage.setMinWidth(400.0); + + mainLayout.setPrefSize(400.0, 600.0); + + scrollPane.setPrefSize(385, 535); + scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); + scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); + + scrollPane.setVvalue(1.0); + scrollPane.setFitToWidth(true); + + // You will need to import `javafx.scene.layout.Region` for this. + dialogContainer.setPrefHeight(Region.USE_COMPUTED_SIZE); + + userInput.setPrefWidth(325.0); + + sendButton.setPrefWidth(55.0); + + AnchorPane.setTopAnchor(scrollPane, 1.0); + + AnchorPane.setBottomAnchor(sendButton, 1.0); + AnchorPane.setRightAnchor(sendButton, 1.0); + + AnchorPane.setLeftAnchor(userInput, 1.0); + AnchorPane.setBottomAnchor(userInput, 1.0); + + //Step 3. Add functionality to handle user input. + sendButton.setOnMouseClicked((event) -> { + handleUserInput(); + }); + + userInput.setOnAction((event) -> { + handleUserInput(); + }); + + //Scroll down to the end every time dialogContainer's height changes. + dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0)); + } + + /** + * Iteration 1: + * Creates a label with the specified text and adds it to the dialog container. + * @param text String containing text to add + * @return a label with the specified text that has word wrap enabled. + */ + private Label getDialogLabel(String text) { + // You will need to import `javafx.scene.control.Label`. + Label textToAdd = new Label(text); + textToAdd.setWrapText(true); + + return textToAdd; + } + + /** + * Iteration 2: + * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to + * the dialog container. Clears the user input after processing. + */ + private void handleUserInput() { + String userText = userInput.getText(); + String dukeText = getResponse(userInput.getText()); + dialogContainer.getChildren().addAll( + DialogBox.getUserDialog(userText, user), + DialogBox.getDukeDialog(dukeText, duke) + ); + userInput.clear(); + } + + /** + * You should have your own function to generate a response to user input. + * Replace this stub with your completed method. + */ + public String getResponse(String input) { + // Create a stream to hold the output + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + // IMPORTANT: Save the old System.out! + old = System.out; + // Tell Java to use your special stream + System.setOut(ps); + if (input.toLowerCase().contains("bye")) { + System.exit(0); + } else { + Parser.read(input, taskList, storage); + } + System.out.flush(); + System.setOut(old); + + return baos.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/DukeException.java b/src/main/java/DukeException.java new file mode 100644 index 0000000000..40de44e8fc --- /dev/null +++ b/src/main/java/DukeException.java @@ -0,0 +1,8 @@ +/** + * Duke Exception that extends from Exception. + */ +public class DukeException extends Exception { + public DukeException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/src/main/java/Event.java b/src/main/java/Event.java new file mode 100644 index 0000000000..fc002097e3 --- /dev/null +++ b/src/main/java/Event.java @@ -0,0 +1,46 @@ +import java.time.LocalDate; + +/** Event is a child class of Task. + * Task that starts at a specific time and ends at a specific time.*/ +public class Event extends Task { + String dateString; + + /** + * Constructor that takes in 2 params. + * + * @param name Name of Event + * @param dateString Date of event + */ + public Event(String name, String dateString) { + super(name); + this.dateString = dateString; + } + + public String getName() { + return this.name; + } + + public boolean getDone() { + return this.done; + } + + public String getClassName() { + return "event"; + } + + /** + * Converts Event into a String to be saved to file. + * @return String to be saved to file + */ + @Override + public String toFile() { + int doneInt = done ? 1 : 0; + return "E , " + doneInt + " , " + name + " , " + dateString; + } + + @Override + public String toString() { + return "[E]" + super.toString() + "(at: " + dateString + ")"; + } + +} diff --git a/src/main/java/Launcher.java b/src/main/java/Launcher.java new file mode 100644 index 0000000000..11dbf00c62 --- /dev/null +++ b/src/main/java/Launcher.java @@ -0,0 +1,10 @@ +import javafx.application.Application; + +/** + * A launcher class to workaround classpath issues. + */ +public class Launcher { + public static void main(String[] args) { + Application.launch(Main.class, args); + } +} \ No newline at end of file diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 0000000000..dca7732b26 --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,29 @@ +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.AnchorPane; +import javafx.stage.Stage; + +import java.io.IOException; + +/** + * A GUI for Duke using FXML. + */ +public class Main extends Application { + + private Duke duke = new Duke(); + + @Override + public void start(Stage stage) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml")); + AnchorPane ap = fxmlLoader.load(); + Scene scene = new Scene(ap); + stage.setScene(scene); + fxmlLoader.getController().setDuke(duke); + stage.show(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/main/java/MainWindow.java b/src/main/java/MainWindow.java new file mode 100644 index 0000000000..1c825e6baa --- /dev/null +++ b/src/main/java/MainWindow.java @@ -0,0 +1,60 @@ +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; + +/** + * Controller for MainWindow. Provides the layout for the other controls. + */ +public class MainWindow extends AnchorPane { + @FXML + private ScrollPane scrollPane; + @FXML + private VBox dialogContainer; + @FXML + private TextField userInput; + @FXML + private Button sendButton; + + private static final String WELCOME_MESSAGE + = " Hello! I'm Da Vinci\n" + + " What can I do for you?\n"; + + private Duke duke; + + private Image userImage = new Image(this.getClass().getResourceAsStream("/images/mona-lisa.jpg")); + private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/da-vinci.jpg")); + + /** + * Initializes GUI. + */ + @FXML + public void initialize() { + scrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); + dialogContainer.getChildren().addAll( + DialogBox.getDukeDialog(WELCOME_MESSAGE, dukeImage) + ); + } + + public void setDuke(Duke d) { + duke = d; + } + + /** + * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to + * the dialog container. Clears the user input after processing. + */ + @FXML + private void handleUserInput() { + String input = userInput.getText(); + String response = duke.getResponse(input); + dialogContainer.getChildren().addAll( + DialogBox.getUserDialog(input, userImage), + DialogBox.getDukeDialog(response, dukeImage) + ); + userInput.clear(); + } +} \ No newline at end of file diff --git a/src/main/java/Parser.java b/src/main/java/Parser.java new file mode 100644 index 0000000000..160f7fbb7a --- /dev/null +++ b/src/main/java/Parser.java @@ -0,0 +1,71 @@ +import java.io.IOException; + +/** + * Parser class to handle inputs and initiate the appropriate actions. + */ +public class Parser { + public Parser(Ui ui) { + } + + /** + * Method reads input from user and performs required actions. + * @param taskList TaskList to store tasks + * @param storage Storage to update/write information to + * */ + public static void read(String input, TaskList taskList, Storage storage) { + try { + if (input.equals("bye")) { + Ui.printBye(); + } else if (input.equals("list")) { + Ui.printList(taskList); + } else if (input.contains("done")) { + String[] inputArr = input.split(" ", 2); + assert inputArr.length == 2; + int taskNum = Integer.parseInt(inputArr[1]); + taskList.taskDone(taskNum); + storage.updateFile(taskList); + } else if (input.contains("find")) { + String[] inputArr = input.split(" ", 2); + assert inputArr.length == 2; + taskList.findTasks(inputArr[1]); + } else if (input.contains("todo")) { + assert input.substring(5).length() > 0; + if (input.split(" ").length == 1) { + throw new DukeException("OOPS!!! The description of a todo cannot be empty."); + } else { + taskList.addList(new ToDo(input.substring(5))); + storage.updateFile(taskList); + } + } else if (input.contains("deadline")) { + if (input.split(" ").length == 1) { + throw new DukeException("OOPS!!! The description of a deadline cannot be empty."); + } else { + int index = input.indexOf("/"); + taskList.addList(new Deadline(input.substring(9, index), input.substring(index + 4))); + } + } else if (input.contains("event")) { + if (input.split(" ").length == 1) { + throw new DukeException("OOPS!!! The description of an event cannot be empty."); + } else { + int index = input.indexOf("/"); + taskList.addList(new Event(input.substring(6, index), input.substring(index + 4))); + } + } else if (input.contains("delete")) { + if (input.split(" ").length == 1) { + throw new DukeException("OOPS!!! Please specify a task number."); + } else { + String[] inputArr = input.split(" "); + int taskNum = Integer.parseInt(inputArr[1]); + taskList.deleteTask(taskNum); + storage.updateFile(taskList); + } + } else { + throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-("); + } + } catch (DukeException e) { + Ui.printException(e); + } catch (IOException e) { + Ui.printException(e); + } + } +} diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java new file mode 100644 index 0000000000..2719f426c0 --- /dev/null +++ b/src/main/java/Storage.java @@ -0,0 +1,93 @@ +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Scanner; + +/** + * Storage object to read and write from and to a file in the given file path. + */ + +public class Storage { + String filePath; + File file; + static final String TODO_INITIAL = "T"; + static final String EVENT_INITIAL = "E"; + static final String DEADLINE_INITIAL = "D"; + + /** + * Constructor. Links this storage object to a specific file path. Create a file if it does not exist. + * @param filePath Path of the file. + */ + public Storage(String filePath) throws IOException { + this.filePath = filePath; + this.file = new File(filePath); + if (!this.file.exists()) { + this.file.getParentFile().mkdirs(); + this.file.createNewFile(); + this.file = new File(this.filePath); + } + } + + /** + * Generate TaskList from file obtained from filePath. + * @return TaskList generated from file obtained from filePath + * @throws IOException Throws error when there is error with I/O + */ + public TaskList getTaskList() throws IOException { + File f = new File(filePath); // create a File for the given file path + Scanner s = new Scanner(f); // create a Scanner using the File as the source + TaskList taskList = new TaskList(); + while (s.hasNext()) { + parseLine(s.nextLine(), taskList); + } + return taskList; + } + + /** + * Helper method to parse each line into a Task. + * @param taskString Line of input to be parsed + * @param taskList TaskList to add the Task to + */ + public void parseLine(String taskString, TaskList taskList) { + assert taskString.length() > 0; + String[] taskDetails = taskString.split(","); + for (int i = 0; i < taskDetails.length; i++) { + taskDetails[i] = taskDetails[i].trim(); + } + String taskType = taskDetails[0]; + boolean isTaskDone = taskDetails[1].equals("1"); + String taskName = taskDetails[2]; + + if (taskType.equals(TODO_INITIAL)) { + Task newTask = new ToDo(taskName); + newTask.done = isTaskDone; + taskList.arrList.add(newTask); + } else if (taskType.equals(DEADLINE_INITIAL)) { + String taskTime = taskDetails[3]; + Task newTask = new Deadline(taskName, taskTime); + newTask.done = isTaskDone; + taskList.arrList.add(newTask); + } else if (taskType.equals(EVENT_INITIAL)) { + String taskTime = taskDetails[3]; + Task newTask = new Event(taskName, taskTime); + newTask.done = isTaskDone; + taskList.arrList.add(newTask); + } + } + + /** + * Updates the file contents based on the taskList given. + * @param taskList TaskList to be written into the file + * @throws IOException Throws error when there is error with I/O + */ + public void updateFile(TaskList taskList) throws IOException { + String textToAdd = ""; + for (Task t : taskList.arrList) { + textToAdd += t.toFile() + "\n"; + } + FileWriter fw = new FileWriter(filePath); + fw.write(textToAdd); + fw.close(); + } + +} diff --git a/src/main/java/Task.java b/src/main/java/Task.java new file mode 100644 index 0000000000..341efff276 --- /dev/null +++ b/src/main/java/Task.java @@ -0,0 +1,63 @@ +import java.time.LocalDate; + +/** + * Parent class of Deadline, Event and ToDo. + */ +public class Task { + public boolean done; + public String name; + + /** + * Constructor. Initialise name and done status. + * + * @param name Name of task. + */ + public Task(String name) { + this.name = name; + this.done = false; + } + + public String getName() { + return this.name; + } + + public boolean getDone() { + return this.done; + } + + public String getClassName() { + return "Task"; + } + + public LocalDate getDateObj() { + return null; + } + + /** + * Toggle status of the done attribute of task. + */ + public void toggleDone() { + this.done = true; + } + + /** + * Converts Task into a String to be saved to file. + * Overwritten by child classes + * @return String to be saved to file + */ + public String toFile() { + int doneInt = done ? 1 : 0; + return "Q , " + doneInt + " , " + name; + } + + @Override + public String toString() { + String symbol; + if (done) { + symbol = "O"; + } else { + symbol = "X"; + } + return "[" + symbol + "] " + this.name; + } +} diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java new file mode 100644 index 0000000000..00e36f9885 --- /dev/null +++ b/src/main/java/TaskList.java @@ -0,0 +1,89 @@ +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +/** + * TaskList class to hold Task objects and perform necessary actions on them. + */ + +public class TaskList { + public ArrayList arrList; + + /** + * Constructor. To create and bind an arrayList. + */ + public TaskList() { + arrList = new ArrayList(); + } + + /** + * Delete task at index taskNum. + * @param taskNum index at which to delete task + */ + public void deleteTask(int taskNum) { + Task removedTask = arrList.get(taskNum - 1); + arrList.remove(taskNum - 1); + Ui.printDelete(removedTask, arrList); + } + + /** + * Marks task at index taskNum as done. + * @param taskNum index at which to mark the task + */ + public void taskDone(int taskNum) { + Task doneTask = arrList.get(taskNum - 1); + doneTask.toggleDone(); + Ui.printDone(doneTask, arrList); + } + + /** + * Adds a Task to TaskList. + * @param task Task to be added + */ + public void addList(Task task) { + arrList.add(task); + sortTasks(); + Ui.printAdd(task, arrList); + } + + /** + * Finds tasks with taskSubString in their name. + * @param taskSubString String to be found in Task name + */ + public void findTasks(String taskSubString) { + sortTasks(); + ArrayList filteredList = new ArrayList(); + for (Task t : arrList) { + if (t.getName().contains(taskSubString)) { + filteredList.add(t); + } + } + Ui.printFilteredList(filteredList); + } + + /** + * Sort the arrList bound to this object. + */ + public void sortTasks() { + Collections.sort(arrList, new Comparator() { + public int compare(Task t1, Task t2) { + String thisClass = t1.getClassName(); + String otherClass = t2.getClassName(); + if (thisClass.equals(otherClass)) { + if (thisClass.equals("deadline")) { + return t1.getDateObj().compareTo(t2.getDateObj()); + } + } else { + if (thisClass.equals("todo")) { + return -1; + } else if (thisClass.equals("event") && otherClass.equals("deadline")) { + return -1; + } else { + return 1; + } + } + return 0; + } + }); + } +} diff --git a/src/main/java/ToDo.java b/src/main/java/ToDo.java new file mode 100644 index 0000000000..aa2e48bd8b --- /dev/null +++ b/src/main/java/ToDo.java @@ -0,0 +1,42 @@ +/** ToDo is a child class of Task. + * Task without any date/time attached to it*/ + +public class ToDo extends Task { + String time; + + /** + * Constructor that takes in 1 param. + * + * @param name Name of ToDo. + */ + public ToDo(String name) { + super(name); + } + + public String getName() { + return this.name; + } + + public boolean getDone() { + return this.done; + } + + public String getClassName() { + return "todo"; + } + + /** + * Converts ToDo into a String to be saved to file. + * @return String to be saved to file + */ + @Override + public String toFile() { + int doneInt = done ? 1 : 0; + return "T , " + doneInt + " , " + name; + } + + @Override + public String toString() { + return "[T]" + super.toString(); + } +} diff --git a/src/main/java/Ui.java b/src/main/java/Ui.java new file mode 100644 index 0000000000..3c66589258 --- /dev/null +++ b/src/main/java/Ui.java @@ -0,0 +1,80 @@ +import java.util.ArrayList; + +/** + * Ui class to support output to user. + */ +public class Ui { + public Ui() { + + } + + /** + * Print goodbye message. + */ + public static void printBye() { + System.out.println("Bye. Hope to see you again soon!"); + } + + /** + * Print out tasks in taskList. + * @param taskList TaskList to print tasks from + */ + public static void printList(TaskList taskList) { + System.out.println("Here are the tasks in your list:"); + for (Task s : taskList.arrList) { + System.out.println((taskList.arrList.indexOf(s) + 1) + "." + s); + } + } + + /** + * Print out tasks in filteredList. + * @param filteredList ArrayList to print tasks from + */ + public static void printFilteredList(ArrayList filteredList) { + System.out.println("Here are the matching tasks in your list:"); + for (Task s : filteredList) { + System.out.println((filteredList.indexOf(s) + 1) + ". " + s); + } + } + + /** + * Print exception. + * @param e Exception to be printed + */ + public static void printException(Exception e) { + System.out.println(e); + } + + /** + * Print message when task is deleted from arrList. + * @param task Deleted Task + * @param arrList ArrayList from which Task is deleted from + */ + public static void printDelete(Task task, ArrayList arrList) { + System.out.println("Noted. I've removed this task: \n" + + task + "\n\n" + + "Now you have " + arrList.size() + " tasks in the list."); + } + + /** + * Print message when task is done. + * @param task Done Task + * @param arrList ArrayList from which Task is marked + */ + public static void printDone(Task task, ArrayList arrList) { + System.out.println("Nice! I've marked this task as done: \n" + + task); + } + + /** + * Print message when task is added. + * @param task Added Task + * @param arrList ArrayList to which task is added + */ + public static void printAdd(Task task, ArrayList arrList) { + System.out.println("Got it. I've added this task: \n" + + task + "\n\n" + + "Now you have " + arrList.size() + " tasks in the list."); + } + +} diff --git a/src/main/resources/images/DaDuke.png b/src/main/resources/images/DaDuke.png new file mode 100644 index 0000000000..d893658717 Binary files /dev/null and b/src/main/resources/images/DaDuke.png differ diff --git a/src/main/resources/images/DaUser.png b/src/main/resources/images/DaUser.png new file mode 100644 index 0000000000..3c82f45461 Binary files /dev/null and b/src/main/resources/images/DaUser.png differ diff --git a/src/main/resources/images/da-vinci.jpg b/src/main/resources/images/da-vinci.jpg new file mode 100644 index 0000000000..21ba0cadef Binary files /dev/null and b/src/main/resources/images/da-vinci.jpg differ diff --git a/src/main/resources/images/mona-lisa.jpg b/src/main/resources/images/mona-lisa.jpg new file mode 100644 index 0000000000..e04ca906cc Binary files /dev/null and b/src/main/resources/images/mona-lisa.jpg differ diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml new file mode 100644 index 0000000000..598aaa14d7 --- /dev/null +++ b/src/main/resources/view/DialogBox.fxml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml new file mode 100644 index 0000000000..1169a0c91b --- /dev/null +++ b/src/main/resources/view/MainWindow.fxml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/DeadlineTest.java b/src/test/java/DeadlineTest.java new file mode 100644 index 0000000000..e2d4762526 --- /dev/null +++ b/src/test/java/DeadlineTest.java @@ -0,0 +1,17 @@ +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class DeadlineTest { + @Test + public void testName() { + Deadline test = new Deadline("deadlineTest", "2020-06-06"); + assertEquals("deadlineTest", test.getName()); + } + + @Test + public void testDone() { + Deadline test = new Deadline("deadlineTest", "2020-06-06"); + assertEquals(false, test.getDone()); + } +} diff --git a/src/test/java/DukeTest.java b/src/test/java/DukeTest.java new file mode 100644 index 0000000000..1091bb9e21 --- /dev/null +++ b/src/test/java/DukeTest.java @@ -0,0 +1,10 @@ +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class DukeTest { + @Test + public void dummyTest() { + assertEquals(2, 2); + } +} \ No newline at end of file diff --git a/src/test/java/EventTest.java b/src/test/java/EventTest.java new file mode 100644 index 0000000000..6ff6812303 --- /dev/null +++ b/src/test/java/EventTest.java @@ -0,0 +1,17 @@ +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class EventTest { + @Test + public void testName() { + Event test = new Event("eventTest", "2020-06-06"); + assertEquals("eventTest", test.getName()); + } + + @Test + public void testDone() { + Event test = new Event("eventTest", "2020-06-06"); + assertEquals(false, test.getDone()); + } +} diff --git a/src/test/java/TodoTest.java b/src/test/java/TodoTest.java new file mode 100644 index 0000000000..d37b3fe474 --- /dev/null +++ b/src/test/java/TodoTest.java @@ -0,0 +1,17 @@ +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class TodoTest { + @Test + public void testName() { + ToDo test = new ToDo("todoTest"); + assertEquals("todoTest", test.getName()); + } + + @Test + public void testDone() { + ToDo test = new ToDo("todoTest"); + assertEquals(false, test.getDone()); + } +} diff --git a/text-ui-test/EXPECTED.txt b/text-ui-test/EXPECTED.txt new file mode 100644 index 0000000000..09c1f562eb --- /dev/null +++ b/text-ui-test/EXPECTED.txt @@ -0,0 +1,4 @@ + ____________________________________________________________ + Got it. I've added this task: + [T][X] borrow book + Now you have 1 tasks in the list. diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt new file mode 100644 index 0000000000..b911285fdf --- /dev/null +++ b/text-ui-test/input.txt @@ -0,0 +1 @@ +todo borrow book \ No newline at end of file diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh new file mode 100644 index 0000000000..d1409b0d45 --- /dev/null +++ b/text-ui-test/runtest.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# create bin directory if it doesn't exist +if [ ! -d "../bin" ] +then + mkdir ../bin +fi + +# delete output from previous run +if [ -e "./ACTUAL.TXT" ] +then + rm ACTUAL.TXT +fi + +# compile the code into the bin folder, terminates if error occurred +if ! javac -cp ./src -Xlint:none -d ../bin ./src/main/java/Duke.java +then + echo "********** BUILD FAILURE **********" + exit 1 +fi + +# run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT +java -classpath ../bin Duke < input.txt > ACTUAL.TXT + +# compare the output to the expected output +diff ACTUAL.TXT EXPECTED.TXT +if [ $? -eq 0 ] +then + echo "Test result: PASSED" + exit 0 +else + echo "Test result: FAILED" + exit 1 +fi \ No newline at end of file diff --git a/tutorials/javaFxTutorialPart1.md b/tutorials/javaFxTutorialPart1.md index 561daeca43..6400dfa154 100644 --- a/tutorials/javaFxTutorialPart1.md +++ b/tutorials/javaFxTutorialPart1.md @@ -27,18 +27,25 @@ A JavaFX application is like a play you are directing. Instead of creating props Update your `build.gradle` to include the following lines: ```groovy -plugins { - id 'java' - id 'org.openjfx.javafxplugin' version '0.0.7' -} - repositories { mavenCentral() } -javafx { - version = "11.0.2" - modules = [ 'javafx.controls', 'javafx.fxml' ] +dependencies { + String javaFxVersion = '11' + + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' + 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' } ```