Skip to content

Commit

Permalink
Fix fxml version
Browse files Browse the repository at this point in the history
  • Loading branch information
teoks0199 committed Sep 21, 2023
1 parent bd3dec1 commit 3a26e6f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test {
}

application {
mainClass.set("duke.Duke")
mainClass.set("duke.Launcher")
}

shadowJar {
Expand Down
5 changes: 2 additions & 3 deletions data/duke.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
D | N | return book | 2020-09-20
E | N | fun carnival | 2023-11-08 | 2020-09-21
T | N | read book
T | N | sf
T | N | wibf
6 changes: 3 additions & 3 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Duke {
*/
public Duke() {
storage = new Storage(FILEPATH);
assert storage != null;
assert storage != null : "Storage should not be null";
tasks = new TaskList(storage.loadTaskList());
}

Expand All @@ -31,7 +31,7 @@ public void run() {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
Parser parser = new Parser(tasks);
assert input != null;
assert input != null : "Input should not be null";
parser.parse(input);
while (!parser.isDone()) {
input = scanner.nextLine();
Expand All @@ -56,7 +56,7 @@ public void updateTaskList() {
public String getResponse(String input) {
Parser parser = new Parser(tasks);
String response = parser.parse(input);
assert response != null;
assert response != null : "Response should not be null";
return response;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/duke/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public void initialize() {
/**
* Sets the duke object.
*
* @param d The duke object.
* @param duke The duke object.
*/
public void setDuke(Duke d) {
duke = d;
public void setDuke(Duke duke) {
this.duke = duke;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package duke;

import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.util.Duration;

/**
* Used to parse user input into appropriate commands.
Expand Down Expand Up @@ -63,13 +65,15 @@ public String parse(String s) {
case "bye":
this.isFinished = true;
output = Ui.bye();
Platform.exit();
PauseTransition delay = new PauseTransition(Duration.seconds(1));
delay.setOnFinished(event -> Platform.exit());
delay.play();
break;
default:
output = Ui.unknownCommandErrorMessage();
}
Ui.horizontalLine();
assert output != null;
assert output != null : "Output should not be null";
return output;
}

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/duke/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ public ArrayList<Task> loadTaskList() {
Path parentDirectory = filePath.getParent();
if (!Files.exists(parentDirectory)) {
Files.createDirectories(parentDirectory);
System.out.println("Parent directories created: " + parentDirectory.toAbsolutePath());
}

// Create the file if it doesn't exist
if (!Files.exists(filePath)) {
Files.createFile(filePath);
System.out.println("File created: " + filePath);
}

// Read the existing content from the file
Expand Down Expand Up @@ -80,12 +78,10 @@ public void updateTaskList() {
Path parentDirectory = filePath.getParent();
if (!Files.exists(parentDirectory)) {
Files.createDirectories(parentDirectory);
System.out.println("Parent directories created: " + parentDirectory.toAbsolutePath());
}
// Create the file if it doesn't exist
if (!Files.exists(filePath)) {
Files.createFile(filePath);
System.out.println("File created: " + filePath);
}
// Write new content to the file
StringBuilder toWrite = new StringBuilder();
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Text?>

<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" style="-fx-background-color: grey; -fx-border-color: black;" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" style="-fx-background-color: grey; -fx-border-color: black;" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<children>
<!-- <Label fx:id="dialog" text="Label" wrapText="true" />-->
<Text fx:id="dialog" layoutX="-0.0" text="Label" textAlignment="RIGHT" wrappingWidth="300.0">
<HBox.margin>
<Insets left="10.0" right="10.0" />
Expand Down
14 changes: 1 addition & 13 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>

<!--<fx:root type="javafx.scene.layout.AnchorPane" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="duke.MainWindow">-->
<!-- <children>-->
<!-- <TextField fx:id="userInput" layoutY="558.0" onAction="#handleUserInput" prefHeight="41.0" prefWidth="324.0" AnchorPane.bottomAnchor="1.0" />-->
<!-- <Button fx:id="sendButton" layoutX="324.0" layoutY="558.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0" prefWidth="76.0" text="SEND" />-->
<!-- <ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" hvalue="1.0" prefHeight="557.0" prefWidth="400.0" vvalue="1.0">-->
<!-- <content>-->
<!-- <VBox fx:id="dialogContainer" prefHeight="552.0" prefWidth="388.0" />-->
<!-- </content>-->
<!-- </ScrollPane>-->
<!-- </children>-->
<!--</fx:root>-->

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="duke.MainWindow">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="duke.MainWindow">
<children>
<TextField fx:id="userInput" layoutY="558.0" onAction="#handleUserInput" prefHeight="41.0" prefWidth="500.0" AnchorPane.bottomAnchor="1.0" />
<Button fx:id="sendButton" layoutX="423.0" layoutY="558.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0" prefWidth="76.0" text="SEND" />
Expand Down

0 comments on commit 3a26e6f

Please sign in to comment.