From fa3d6bbca0db11fc90456cbc3a850dfb0d427857 Mon Sep 17 00:00:00 2001 From: rtutz Date: Sat, 5 Aug 2023 20:05:02 -0400 Subject: [PATCH 1/2] Fixed bug in presenter displayChangedTaskDetails --- ...ojectViewingAndModificationController.java | 4 ++-- ...rojectViewingAndModificationPresenter.java | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/c_interface_adapters/ProjectViewingAndModificationController.java b/src/main/java/c_interface_adapters/ProjectViewingAndModificationController.java index 2aa424f..ad0fd0c 100644 --- a/src/main/java/c_interface_adapters/ProjectViewingAndModificationController.java +++ b/src/main/java/c_interface_adapters/ProjectViewingAndModificationController.java @@ -109,8 +109,8 @@ void changeTaskDetails(TaskModel task, HBox hbox, String newTaskName, interactor.changeTaskDetails(changedTask, taskID); //Creating a TaskViewModel for display purposes - TaskViewModel newTask = new TaskViewModel(task.getName(), taskID, task.getDescription(), - task.getCompletionStatus(), task.getDueDateTime()); + TaskViewModel newTask = new TaskViewModel(newTaskName, taskID, newTaskName, + taskStatus, newDueDate); //Calling a handler to display the final task changes presenter.displayChangedTaskDetails(taskID, newTask, hbox); diff --git a/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java b/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java index fc41417..d6e682d 100644 --- a/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java +++ b/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java @@ -223,18 +223,23 @@ public void displayDeletedColumn(ColumnModel columnModel) { */ @Override public void displayChangedTaskDetails(UUID taskID, TaskViewModel task, HBox hbox) { - String taskUUID = task.getID().toString(); + System.out.println("IN PRESENTER"); String taskName = task.getName(); + System.out.println("Name of task in displayChangedTaskDetails " + taskName); //Removing the existing nane from the Hbox hbox.getChildren().removeAll(); - - //Creating a new label and adding them in - Label taskLabel = new Label(taskName); - Button taskOptionsButton = new Button("..."); - taskOptionsButton.setStyle("-fx-font-size: 8px;"); - hbox.getChildren().add(taskLabel); - hbox.getChildren().add(taskOptionsButton); + System.out.println("ID OF ACTUAL TASK" + taskID); + System.out.println("ID OF HBOX UI" + hbox); + for (Node node: hbox.getChildren()) { + System.out.println("ITEM IN HBOX " + node); + if (node instanceof Text) { + System.out.println("FOUND THE TEXT"); + ((Text) node).setText(taskName); + System.out.println("TEXT UPDATED"); + break; + } + } } @Override From 9a2df3fa33ced4e684a7148ad92b46d0d52bd3a7 Mon Sep 17 00:00:00 2001 From: rtutz Date: Sat, 5 Aug 2023 20:12:54 -0400 Subject: [PATCH 2/2] ensured that empty inputs does not cause errors. --- ...rojectViewingAndModificationPresenter.java | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java b/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java index d6e682d..8b08d66 100644 --- a/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java +++ b/src/main/java/c_interface_adapters/ProjectViewingAndModificationPresenter.java @@ -29,6 +29,7 @@ import javafx.util.Pair; import java.io.IOException; +import java.time.LocalDate; import java.util.*; /** @@ -328,8 +329,7 @@ public void displayNewColumn(ColumnModel column) { MenuItem deleteColumnButton = new MenuItem("Delete Column"); Button addTaskButton = new Button("Add Task"); - addTaskButton.setOnAction(event -> controller.presenter.handleAddTaskPopup(columnBox, - controller)); + addTaskButton.setOnAction(event -> controller.presenter.handleAddTaskPopup(columnBox)); HBox TaskBtnVBox = new HBox(addTaskButton); // Add event handler on menu item. @@ -421,7 +421,7 @@ void populateTasksForEachColumn(VBox columnBox, List tasks, ProjectVi // projectViewingAndModificationController.renameTask(task, hbox);}); //Event handler for the changing task details. Calls another method on this presenter changeTaskDetailsButton.setOnAction(event -> { - this.handleChangeTaskPopup(task, hbox, controller); + this.handleChangeTaskPopup(task, hbox); //projectViewingAndModificationController.changeTaskDetails( //task, hbox); }); @@ -550,10 +550,9 @@ private void SetHBoxFeatures(VBox columnBox, HBox hbox) { * the selected column. * * @param columnBox The VBox representing the Column UI where the task will be added. - * @param projectViewingAndModificationController */ - void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController projectViewingAndModificationController) { - projectViewingAndModificationController.setPresenter(); + void handleAddTaskPopup(VBox columnBox) { + controller.setPresenter(); // Create a new stage for the popup Stage popupStage = new Stage(); @@ -568,7 +567,6 @@ void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController gridPane.setVgap(10); // Create labels and input fields for Task Details, Task Due Date, and Task Name - Label nameLabel = new Label("Task Name:"); TextField nameTextField = new TextField(); @@ -593,12 +591,20 @@ void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController // Handles the action of putting a new task in the correct Column UI. addTaskToColumnButton.setOnAction(event -> { - // Close the popup when "Submit" button is pressed - popupStage.close(); + String taskName = nameTextField.getText().trim(); + String taskDetails = detailsTextArea.getText().trim(); + LocalDate dueDate = dueDatePicker.getValue(); + + if (taskName.isEmpty() || taskDetails.isEmpty() || dueDate == null) { + // Show an alert if any of the fields are empty + showAlert("Error", "All fields are required. Please fill in all the details."); + } else { + // Close the popup when "Submit" button is pressed + popupStage.close(); - // Call the method to handle adding the task to the column - projectViewingAndModificationController.handleAddTaskToColumn(columnBox.getId(), nameTextField.getText(), - detailsTextArea.getText(), dueDatePicker.getValue().atStartOfDay()); + // Call the method to handle adding the task to the column + controller.handleAddTaskToColumn(columnBox.getId(), taskName, taskDetails, dueDate.atStartOfDay()); + } }); // Add the "Add" button to the GridPane @@ -618,11 +624,9 @@ void handleAddTaskPopup(VBox columnBox, ProjectViewingAndModificationController * ProjectViewingAndModificationController * @param task * @param hbox - * @param projectViewingAndModificationController */ - void handleChangeTaskPopup(TaskModel task, HBox hbox, - ProjectViewingAndModificationController projectViewingAndModificationController) { - projectViewingAndModificationController.setPresenter(); + void handleChangeTaskPopup(TaskModel task, HBox hbox) { + controller.setPresenter(); // Create a new stage for the popup Stage popupStage = new Stage(); @@ -637,7 +641,6 @@ void handleChangeTaskPopup(TaskModel task, HBox hbox, gridPane.setVgap(10); // Create labels and input fields for Task Details, Task Due Date, and Task Name - Label nameLabel = new Label("Task Name:"); TextField nameTextField = new TextField(); @@ -662,13 +665,22 @@ void handleChangeTaskPopup(TaskModel task, HBox hbox, // Handles the action of putting a new task in the correct Column UI. changeTaskButton.setOnAction(event -> { - // Close the popup when "Submit" button is pressed - popupStage.close(); + String taskName = nameTextField.getText().trim(); + String taskDetails = detailsTextArea.getText().trim(); + LocalDate dueDate = dueDatePicker.getValue(); - // Call the method to handle adding the task to the column - projectViewingAndModificationController.changeTaskDetails(task, hbox, nameTextField.getText(), - detailsTextArea.getText(), dueDatePicker.getValue().atStartOfDay()); + if (taskName.isEmpty() || taskDetails.isEmpty() || dueDate == null) { + // Show an alert if any of the fields are empty + showAlert("Error", "All fields are required. Please fill in all the details."); + } else { + // Close the popup when "Submit" button is pressed + popupStage.close(); + + // Call the method to handle changing the task details + controller.changeTaskDetails(task, hbox, taskName, taskDetails, dueDate.atStartOfDay()); + } }); + // Add the "Change Task" button to the GridPane gridPane.add(changeTaskButton, 0, 3, 2, 1);