connection task list model and garden plan model with controllers

This commit is contained in:
giavaphi
2022-11-08 21:03:01 +01:00
parent 802f238d69
commit ced2645bd7
6 changed files with 104 additions and 35 deletions
@@ -1,5 +1,9 @@
package ch.zhaw.gartenverwaltung;
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
import ch.zhaw.gartenverwaltung.taskList.PlantNotFoundException;
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
import ch.zhaw.gartenverwaltung.types.GrowthPhaseType;
import ch.zhaw.gartenverwaltung.types.Plant;
import javafx.beans.value.ChangeListener;
@@ -11,6 +15,7 @@ import javafx.scene.control.*;
import javafx.stage.Stage;
import javafx.util.Callback;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.util.List;
@@ -18,6 +23,8 @@ import java.util.ResourceBundle;
public class SelectSowDayController implements Initializable {
private Plant selectedPlant = null;
private final TaskListModel taskListModel = new TaskListModel();
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
@FXML
private DatePicker datepicker;
@@ -31,6 +38,8 @@ public class SelectSowDayController implements Initializable {
@FXML
private RadioButton sow_radio;
public SelectSowDayController() throws IOException {}
/**
* close the date selector window
* @param event event
@@ -46,8 +55,7 @@ public class SelectSowDayController implements Initializable {
* @param event event
*/
@FXML
void save(ActionEvent event) {
//ToDo save plant and sow date to crop/gardenplan model
void save(ActionEvent event) throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
LocalDate sowDate;
if (sow_radio.isSelected()) {
sowDate = datepicker.getValue();
@@ -55,8 +63,8 @@ public class SelectSowDayController implements Initializable {
//ToDo method to get current lifecycle group in plant
sowDate = selectedPlant.sowDateFromHarvestDate(datepicker.getValue(), 0);
}
System.out.println(sowDate);
System.out.println(selectedPlant);
//ToDo uncomment, when error from JsonTaskDatabase.java loadTaskListFromFile() is fixed.
//gardenplanmodel.plantAsCrop(selectedPlant, sowDate);
closeWindow();
}