From 5830ee5180ab6e86c3490abfee2f842c81799578 Mon Sep 17 00:00:00 2001 From: Elias Csomor Date: Fri, 9 Dec 2022 17:13:05 +0100 Subject: [PATCH 1/6] fixing execution and notification dates in test db --- .../ch/zhaw/gartenverwaltung/io/template-taskdb.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/resources/ch/zhaw/gartenverwaltung/io/template-taskdb.json b/src/test/resources/ch/zhaw/gartenverwaltung/io/template-taskdb.json index b10124d..53ea6c3 100644 --- a/src/test/resources/ch/zhaw/gartenverwaltung/io/template-taskdb.json +++ b/src/test/resources/ch/zhaw/gartenverwaltung/io/template-taskdb.json @@ -26,8 +26,8 @@ "name" : "fertilize plant", "description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture", "startDate" : "2022-06-01", - "nextExecution": "2022-05-01", - "nextNotification": "2022-05-01", + "nextExecution": "2022-06-01", + "nextNotification": "2022-06-01", "endDate" : "2022-08-01", "interval" : 28, "cropId" : 0 @@ -37,8 +37,8 @@ "name" : "covering plant", "description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage", "startDate" : "2022-07-01", - "nextExecution": "2022-05-01", - "nextNotification": "2022-05-01", + "nextExecution": "2022-07-01", + "nextNotification": "2022-07-01", "endDate" : "2022-07-01", "interval" : 0, "cropId" : 0 @@ -59,8 +59,8 @@ "name" : "harvest plant", "description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ", "startDate" : "2022-09-01", - "nextExecution": "2022-05-01", - "nextNotification": "2022-05-01", + "nextExecution": "2022-09-01", + "nextNotification": "2022-09-01", "endDate" : "2022-09-01", "interval" : 0, "cropId" : 0 From 56020a7529a5064010cdac6224bdc96fedb2cf03 Mon Sep 17 00:00:00 2001 From: Elias Csomor Date: Fri, 9 Dec 2022 17:35:41 +0100 Subject: [PATCH 2/6] Setup Platform for runLater in GardenSchedule Otherwise Test planTaskForCrop crashes due to unitialized Platform --- .../gartenverwaltung/models/GardenScheduleTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/ch/zhaw/gartenverwaltung/models/GardenScheduleTest.java b/src/test/java/ch/zhaw/gartenverwaltung/models/GardenScheduleTest.java index 8bce1be..4f45242 100644 --- a/src/test/java/ch/zhaw/gartenverwaltung/models/GardenScheduleTest.java +++ b/src/test/java/ch/zhaw/gartenverwaltung/models/GardenScheduleTest.java @@ -3,6 +3,9 @@ package ch.zhaw.gartenverwaltung.models; import ch.zhaw.gartenverwaltung.io.*; import ch.zhaw.gartenverwaltung.models.GardenSchedule; import ch.zhaw.gartenverwaltung.types.*; +import javafx.application.Platform; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,6 +32,16 @@ class GardenScheduleTest { List exampleTaskTemplateList; GardenSchedule model; + @BeforeAll + static void setUpAll() { + Platform.startup(()->{}); + } + + @AfterAll + static void tearDownAll() { + Platform.exit(); + } + @BeforeEach void setUp() throws IOException, HardinessZoneNotSetException { createExampleTaskList(); From 96dc0ad827cb5f2ce5b858c66daf0afb0c1f4a4c Mon Sep 17 00:00:00 2001 From: giavaphi Date: Fri, 9 Dec 2022 19:38:22 +0100 Subject: [PATCH 3/6] fix show all tasks --- .../MyScheduleController.java | 30 +++++++++++++++---- .../models/GardenSchedule.java | 10 ------- .../ch/zhaw/gartenverwaltung/MySchedule.fxml | 12 ++++---- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/MyScheduleController.java b/src/main/java/ch/zhaw/gartenverwaltung/MyScheduleController.java index b72ad05..ec23853 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/MyScheduleController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/MyScheduleController.java @@ -3,15 +3,15 @@ package ch.zhaw.gartenverwaltung; import ch.zhaw.gartenverwaltung.bootstrap.AfterInject; import ch.zhaw.gartenverwaltung.bootstrap.Inject; import ch.zhaw.gartenverwaltung.io.PlantList; +import ch.zhaw.gartenverwaltung.io.TaskList; import ch.zhaw.gartenverwaltung.models.Garden; import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException; import ch.zhaw.gartenverwaltung.models.GardenSchedule; import ch.zhaw.gartenverwaltung.types.Crop; import ch.zhaw.gartenverwaltung.types.Plant; import ch.zhaw.gartenverwaltung.types.Task; +import javafx.application.Platform; import javafx.beans.property.ListProperty; -import javafx.beans.property.SimpleListProperty; -import javafx.collections.FXCollections; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; @@ -51,9 +51,15 @@ public class MyScheduleController { @FXML private ListView scheduledPlants_listview; + @FXML + private void showAllTasks(ActionEvent actionEvent) throws IOException { + gardenSchedule.getTasksUpcomingWeek(); + scheduledPlants_listview.getSelectionModel().clearSelection(); + } + @AfterInject @SuppressWarnings("unused") - public void init() { + public void init() throws IOException { setCellFactoryCropListView(); setCellFactoryTaskListView(); scheduledPlants_listview.itemsProperty().bind(garden.getPlantedCrops()); @@ -61,6 +67,19 @@ public class MyScheduleController { week_listView.itemsProperty().bind(taskListProperty); lookForSelectedListEntries(); information_label.setText(""); + + gardenSchedule.getTasksUpcomingWeek(); + TaskList.TaskListObserver taskListObserver = newTaskList -> { + Platform.runLater(() -> { + try { + gardenSchedule.getTasksUpcomingWeek(); + scheduledPlants_listview.getSelectionModel().clearSelection(); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + }; + gardenSchedule.setTaskListObserver(taskListObserver); } /** @@ -81,6 +100,8 @@ public class MyScheduleController { * set cellFactory for the crops. */ private void setCellFactoryCropListView() { + MultipleSelectionModel selectionModel = scheduledPlants_listview.getSelectionModel(); + selectionModel.setSelectionMode(SelectionMode.MULTIPLE); scheduledPlants_listview.setCellFactory(param -> new ListCell<>() { @Override protected void updateItem(Crop crop, boolean empty) { @@ -133,8 +154,6 @@ public class MyScheduleController { } else { gardenSchedule.getTasksUpcomingWeek(); } - //taskListProperty.clear(); - //taskListProperty.addAll(taskLists); } /** @@ -200,5 +219,4 @@ public class MyScheduleController { }); } - } diff --git a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java index 2e3eb3d..7118b2d 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java @@ -32,16 +32,6 @@ public class GardenSchedule { public GardenSchedule(TaskList taskList, PlantList plantList) throws IOException { this.taskList = taskList; this.plantList = plantList; - TaskList.TaskListObserver taskListObserver = newTaskList -> { - Platform.runLater(() -> { - try { - getTasksUpcomingWeek(); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - }; - setTaskListObserver(taskListObserver); } public ListProperty> getWeeklyTaskListProperty() { diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/MySchedule.fxml b/src/main/resources/ch/zhaw/gartenverwaltung/MySchedule.fxml index 1e31955..07ba3bf 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/MySchedule.fxml +++ b/src/main/resources/ch/zhaw/gartenverwaltung/MySchedule.fxml @@ -1,6 +1,7 @@ + @@ -19,11 +20,12 @@ - - - - - + + + +