diff --git a/src/main/java/ch/zhaw/gartenverwaltung/MyScheduleController.java b/src/main/java/ch/zhaw/gartenverwaltung/MyScheduleController.java index 4c94c16..43eeb4c 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); } /** @@ -202,5 +221,4 @@ public class MyScheduleController { }); } - } diff --git a/src/main/java/ch/zhaw/gartenverwaltung/TutorialController.java b/src/main/java/ch/zhaw/gartenverwaltung/TutorialController.java index eb4ad5d..2e0b1db 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/TutorialController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/TutorialController.java @@ -22,6 +22,8 @@ public class TutorialController { public ImageView imgAddNewPlant; public ImageView imgTaskList; public ImageView imgSelectDate; + public ImageView imgAddTaskButton; + public ImageView imgDetailDeleteButtons; private int page = 0; @@ -30,10 +32,17 @@ public class TutorialController { switchViews(); setButtonAbilities(); - Image placeholder = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png"))); - imgAddNewPlant.setImage(placeholder); - imgSelectDate.setImage(placeholder); - imgTaskList.setImage(placeholder); + Image addNewPlantImage = new Image(String.valueOf(PlantsController.class.getResource("add-new-plant.png"))); + Image selectSowHarvestImage = new Image(String.valueOf(PlantsController.class.getResource("select-sow-harvest.png"))); + Image scheduleImage = new Image(String.valueOf(PlantsController.class.getResource("schedule.png"))); + Image detailDeleteButtonsImage = new Image(String.valueOf(PlantsController.class.getResource("details-delete.png"))); + Image addTaskImage = new Image(String.valueOf(PlantsController.class.getResource("add-task.png"))); + + imgAddNewPlant.setImage(addNewPlantImage); + imgSelectDate.setImage(selectSowHarvestImage); + imgDetailDeleteButtons.setImage(detailDeleteButtonsImage); + imgAddTaskButton.setImage(addTaskImage); + imgTaskList.setImage(scheduleImage); } public void viewNextPage() { diff --git a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java index 2e3eb3d..5e72331 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() { @@ -176,13 +166,10 @@ public class GardenSchedule { dayTaskList.add(new ArrayList<>()); final int finalI = i; weekTasks.forEach(task -> { - if (task.getNextExecution() == null) { - task.isDone(); - } else { + if(task.getNextExecution() != null) { LocalDate checkDate = task.getNextExecution(); - do { - if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { + if (date.equals(task.getNextExecution()) || (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN)))) { dayTaskList.get(finalI).add(task); } checkDate = checkDate.plusDays(task.getInterval().orElse(0)); diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java b/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java index 62e42b0..9316095 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java @@ -108,7 +108,7 @@ public class Task { * @return Whether the Task is within the given range */ public boolean isInTimePeriod(LocalDate searchStartDate, LocalDate searchEndDate) { - return endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate) || (nextExecution != null && nextExecution.isBefore(searchEndDate) && nextExecution.isAfter(searchStartDate)); + return (endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate)) || ((nextExecution != null && nextExecution.isBefore(searchEndDate.plusDays(1)) && nextExecution.isAfter(searchStartDate.minusDays(1)))); } /** diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/CropDetail.fxml b/src/main/resources/ch/zhaw/gartenverwaltung/CropDetail.fxml index 6a2e116..89ff698 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/CropDetail.fxml +++ b/src/main/resources/ch/zhaw/gartenverwaltung/CropDetail.fxml @@ -89,7 +89,7 @@ -