Compare commits
No commits in common. "bee517317a41a0c796b4f857a04c80dc8fb76818" and "78a27499a8c267778f40f9152e9d3d66945ee947" have entirely different histories.
bee517317a
...
78a27499a8
|
@ -1,132 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.plantList.PlantListModel;
|
|
||||||
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Pest;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.layout.HBox;
|
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CropDetailController {
|
|
||||||
private Crop crop = null;
|
|
||||||
private final PlantListModel plantListModel = new PlantListModel();
|
|
||||||
private final TaskListModel taskListModel = new TaskListModel();
|
|
||||||
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ImageView imageView;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button area_button;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label area_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label cropName_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label description_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private VBox growthPhases_vbox;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label location_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label light_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button location_button;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private VBox pests_vbox;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label soil_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label spacing_label;
|
|
||||||
|
|
||||||
public CropDetailController() throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
void editTaskList(ActionEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
void goBack(ActionEvent event) {
|
|
||||||
Stage stage = (Stage) imageView.getScene().getWindow();
|
|
||||||
stage.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
void setArea(ActionEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
void setLocation(ActionEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlantFromCrop(Crop crop) throws HardinessZoneNotSetException, IOException {
|
|
||||||
this.crop = crop;
|
|
||||||
Plant plant = plantListModel.getFilteredPlantListById(Config.getCurrentHardinessZone(), crop.getPlantId()).get(0);
|
|
||||||
cropName_label.setText(plant.name());
|
|
||||||
description_label.setText(plant.description());
|
|
||||||
light_label.setText(String.valueOf(plant.light()));
|
|
||||||
soil_label.setText(plant.soil());
|
|
||||||
spacing_label.setText(plant.spacing());
|
|
||||||
if (plant.image() != null) {
|
|
||||||
imageView.setImage(plant.image());
|
|
||||||
}
|
|
||||||
area_label.setText("");
|
|
||||||
location_label.setText("");
|
|
||||||
createTaskLists(crop);
|
|
||||||
createPestList(plant);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createTaskLists(Crop crop) throws IOException {
|
|
||||||
List<Task> taskList = taskListModel.getTaskListForCrop(crop.getCropId().get());
|
|
||||||
for (Task task : taskList) {
|
|
||||||
Label label = new Label(task.getDescription());
|
|
||||||
growthPhases_vbox.getChildren().add(label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPestList(Plant plant) {
|
|
||||||
List<Pest> pests = plant.pests();
|
|
||||||
for (Pest pest : pests) {
|
|
||||||
Label label = new Label(pest.name() + ":");
|
|
||||||
label.setStyle("-fx-font-weight: bold");
|
|
||||||
HBox hBox = new HBox();
|
|
||||||
hBox.fillHeightProperty();
|
|
||||||
Label label1 = new Label(pest.description());
|
|
||||||
label1.setAlignment(Pos.TOP_LEFT);
|
|
||||||
label1.setWrapText(true);
|
|
||||||
label1.setMaxWidth(600);
|
|
||||||
label1.setMaxHeight(100);
|
|
||||||
Button button = new Button("Get Counter Measures");
|
|
||||||
hBox.getChildren().addAll(label1, button);
|
|
||||||
pests_vbox.getChildren().addAll(label, hBox);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
|
||||||
|
@ -13,15 +14,12 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class MainFXMLController implements Initializable {
|
public class MainFXMLController implements Initializable {
|
||||||
/**
|
/**
|
||||||
* Caching the panes
|
* Caching the panes
|
||||||
*/
|
*/
|
||||||
private final Map<String, AnchorPane> panes = new HashMap<>();
|
private final Map<String, AnchorPane> panes = new HashMap<>();
|
||||||
private static final Logger LOG = Logger.getLogger(MainFXMLController.class.getName());
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button home_button;
|
private Button home_button;
|
||||||
|
@ -102,7 +100,7 @@ public class MainFXMLController implements Initializable {
|
||||||
loadPane("Home.fxml");
|
loadPane("Home.fxml");
|
||||||
styleChangeButton(home_button);
|
styleChangeButton(home_button);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.log(Level.SEVERE, "Failed to load FXML-Pane!", e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,27 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.plantList.PlantListModel;
|
|
||||||
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Alert;
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ButtonType;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.layout.HBox;
|
|
||||||
import javafx.scene.layout.Priority;
|
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Modality;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class MyPlantsController implements Initializable {
|
public class MyPlantsController implements Initializable {
|
||||||
MainFXMLController mainController;
|
MainFXMLController mainController;
|
||||||
private final TaskListModel taskListModel = new TaskListModel();
|
|
||||||
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
@FXML
|
||||||
private final PlantListModel plantListModel = new PlantListModel();
|
private Button addPlant_button;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private VBox myPlants_vbox;
|
private VBox myPlants_vbox;
|
||||||
|
|
||||||
public MyPlantsController() throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void addPlant(ActionEvent event) throws IOException {
|
void addPlant(ActionEvent event) throws IOException {
|
||||||
mainController.loadPane("Plants.fxml");
|
mainController.loadPane("Plants.fxml");
|
||||||
|
@ -47,29 +29,15 @@ public class MyPlantsController implements Initializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
//ToDo update, when new crops are added
|
//ToDo
|
||||||
try {
|
List<Plant> myPlants = getMyPlants();
|
||||||
loadCropList();
|
createPlantView(myPlants);
|
||||||
} catch (HardinessZoneNotSetException | IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCropList() throws HardinessZoneNotSetException, IOException {
|
private void createPlantView(List<Plant> myPlants) {
|
||||||
List<Crop> cropList = new LinkedList<>();
|
//ToDo
|
||||||
try {
|
for(Plant plant : myPlants) {
|
||||||
cropList = getCropList();
|
createPlantView();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
createPlantView(cropList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPlantView(List<Crop> crops) throws HardinessZoneNotSetException, IOException {
|
|
||||||
myPlants_vbox.getChildren().clear();
|
|
||||||
for(Crop crop : crops) {
|
|
||||||
HBox hBox = createPlantView(crop);
|
|
||||||
myPlants_vbox.getChildren().add(hBox);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,84 +45,14 @@ public class MyPlantsController implements Initializable {
|
||||||
mainController = controller;
|
mainController = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Crop> getCropList() throws IOException {
|
private List<Plant> getMyPlants() {
|
||||||
List<Crop> cropList;
|
//ToDo method to get myPlantList(scheduled)
|
||||||
cropList = gardenplanmodel.getCrops();
|
//Method to call all Plants saved
|
||||||
return cropList;
|
List<Plant> myPlantList = new LinkedList<>();
|
||||||
|
return myPlantList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HBox createPlantView(Crop crop) throws HardinessZoneNotSetException, IOException {
|
private void createPlantView() {
|
||||||
//ToDo add better design
|
//ToDo FXML Panel with Plant data
|
||||||
Plant plant = plantListModel.getFilteredPlantListById(Config.getCurrentHardinessZone(), crop.getPlantId()).get(0);
|
|
||||||
HBox hBox = new HBox(10);
|
|
||||||
ImageView imageView = new ImageView();
|
|
||||||
imageView.setPreserveRatio(false);
|
|
||||||
imageView.setFitHeight(100);
|
|
||||||
imageView.setFitWidth(100);
|
|
||||||
imageView.maxHeight(100);
|
|
||||||
if (plant.image() != null) {
|
|
||||||
imageView.setImage(plant.image());
|
|
||||||
}
|
|
||||||
hBox.setMinHeight(100);
|
|
||||||
Label label = new Label(plant.name());
|
|
||||||
label.setMaxWidth(2000);
|
|
||||||
HBox.setHgrow(label, Priority.ALWAYS);
|
|
||||||
Button details = new Button("Details");
|
|
||||||
Button delete = new Button("delete");
|
|
||||||
details.setOnAction(getGoToCropDetailEvent(crop));
|
|
||||||
delete.setOnAction(getDeleteCropEvent(crop));
|
|
||||||
hBox.getChildren().addAll(imageView, label, details, delete);
|
|
||||||
return hBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
private EventHandler<ActionEvent> getGoToCropDetailEvent(Crop crop) {
|
|
||||||
EventHandler<ActionEvent> event = new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
Parent root;
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(Objects.requireNonNull(getClass().getResource("CropDetail.fxml")));
|
|
||||||
try {
|
|
||||||
root = fxmlLoader.load();
|
|
||||||
CropDetailController controller = fxmlLoader.getController();
|
|
||||||
controller.setPlantFromCrop(crop);
|
|
||||||
Stage stage = new Stage();
|
|
||||||
stage.setScene(new Scene(root));
|
|
||||||
stage.initModality(Modality.APPLICATION_MODAL);
|
|
||||||
stage.setResizable(true);
|
|
||||||
stage.showAndWait();
|
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
private EventHandler<ActionEvent> getDeleteCropEvent(Crop crop) {
|
|
||||||
EventHandler<ActionEvent> event = new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
try {
|
|
||||||
showConfirmation(crop);
|
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showConfirmation(Crop crop) throws IOException, HardinessZoneNotSetException {
|
|
||||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
|
||||||
alert.setTitle("Delete Crop");
|
|
||||||
alert.setHeaderText("Are you sure want to delete this Crop?");
|
|
||||||
alert.setContentText("placeholder");
|
|
||||||
|
|
||||||
Optional<ButtonType> option = alert.showAndWait();
|
|
||||||
|
|
||||||
if (option.get() == ButtonType.OK) {
|
|
||||||
gardenplanmodel.removeCrop(crop);
|
|
||||||
loadCropList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,15 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.plantList.PlantListModel;
|
|
||||||
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
|
||||||
import javafx.beans.property.ListProperty;
|
|
||||||
import javafx.beans.property.SimpleListProperty;
|
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ListCell;
|
import javafx.scene.control.ListCell;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -27,12 +17,7 @@ import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class MyScheduleController implements Initializable {
|
public class MyScheduleController implements Initializable {
|
||||||
private Crop selectedCrop = null;
|
private Plant selectedPlant = null;
|
||||||
private final TaskListModel taskListModel = new TaskListModel();
|
|
||||||
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
|
||||||
private final PlantListModel plantListModel = new PlantListModel();
|
|
||||||
|
|
||||||
private final ListProperty<Crop> cropListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label day1_label;
|
private Label day1_label;
|
||||||
|
@ -80,41 +65,27 @@ public class MyScheduleController implements Initializable {
|
||||||
private Label information_label;
|
private Label information_label;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<Crop> scheduledPlants_listview;
|
private ListView<Plant> scheduledPlants_listview;
|
||||||
|
|
||||||
public MyScheduleController() throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
List<Crop> cropList;
|
List<Plant> plantList = new LinkedList<>();
|
||||||
try {
|
fillListViewMyPlantsInSchedule(plantList);
|
||||||
cropList = gardenplanmodel.getCrops();
|
getSelectedPlantTask();
|
||||||
cropListProperty.addAll(cropList);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
setCellFactoryListView();
|
|
||||||
scheduledPlants_listview.itemsProperty().bind(cropListProperty);
|
|
||||||
lookForSelectedListEntries();
|
|
||||||
setDayLabels();
|
setDayLabels();
|
||||||
information_label.setText("");
|
information_label.setText("");
|
||||||
try {
|
|
||||||
loadTaskList();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lookForSelectedListEntries() {
|
private void getSelectedPlantTask() {
|
||||||
scheduledPlants_listview.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Crop>() {
|
scheduledPlants_listview.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Plant>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends Crop> observable, Crop oldValue, Crop newValue) {
|
public void changed(ObservableValue<? extends Plant> observable, Plant oldValue, Plant newValue) {
|
||||||
selectedCrop = newValue;
|
if(newValue != null) {
|
||||||
try {
|
selectedPlant = newValue;
|
||||||
loadTaskList();
|
//ToDo update day<x>_panel with task for the day
|
||||||
} catch (IOException e) {
|
} else {
|
||||||
e.printStackTrace();
|
selectedPlant = null;
|
||||||
|
//ToDo update day<x>_panel with task for the day (all plants)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -131,52 +102,23 @@ public class MyScheduleController implements Initializable {
|
||||||
day7_label.setText(today.plusDays(6).getDayOfWeek().toString());
|
day7_label.setText(today.plusDays(6).getDayOfWeek().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCellFactoryListView() {
|
private void fillListViewMyPlantsInSchedule(List<Plant> list) {
|
||||||
scheduledPlants_listview.setCellFactory(param -> new ListCell<Crop>() {
|
for (Plant plant : list) {
|
||||||
|
scheduledPlants_listview.getItems().add(plant);
|
||||||
|
}
|
||||||
|
scheduledPlants_listview.setCellFactory(param -> new ListCell<Plant>() {
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(Crop crop, boolean empty) {
|
protected void updateItem(Plant plant, boolean empty) {
|
||||||
super.updateItem(crop, empty);
|
super.updateItem(plant, empty);
|
||||||
|
|
||||||
if (empty || crop == null) {
|
if (empty || plant == null || plant.name() == null) {
|
||||||
setText(null);
|
setText(null);
|
||||||
} else {
|
} else {
|
||||||
try {
|
setText(plant.name());
|
||||||
setText(plantListModel.getFilteredPlantListById(Config.getCurrentHardinessZone(), crop.getPlantId()).get(0).name());
|
|
||||||
} catch (HardinessZoneNotSetException | IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadTaskList() throws IOException {
|
|
||||||
List<List<Task>> taskLists = new LinkedList<>();
|
|
||||||
if (selectedCrop != null) {
|
|
||||||
taskLists = taskListModel.getTasksUpcomingWeekForCrop(selectedCrop.getCropId().get());
|
|
||||||
} else {
|
|
||||||
taskLists = taskListModel.getTasksUpcomingWeek();
|
|
||||||
}
|
|
||||||
if (!taskLists.isEmpty()) {
|
|
||||||
viewTaskListOfDay(day1_pane, taskLists.get(0));
|
|
||||||
viewTaskListOfDay(day2_pane, taskLists.get(1));
|
|
||||||
viewTaskListOfDay(day3_pane, taskLists.get(2));
|
|
||||||
viewTaskListOfDay(day4_pane, taskLists.get(3));
|
|
||||||
viewTaskListOfDay(day5_pane, taskLists.get(4));
|
|
||||||
viewTaskListOfDay(day6_pane, taskLists.get(5));
|
|
||||||
viewTaskListOfDay(day7_pane, taskLists.get(6));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void viewTaskListOfDay(Pane pane, List<Task> tasks) {
|
|
||||||
//ToDo update pane with task list
|
|
||||||
VBox vBox = new VBox();
|
|
||||||
for (Task task : tasks) {
|
|
||||||
Label label = new Label(task.getDescription());
|
|
||||||
vBox.getChildren().add(label);
|
|
||||||
}
|
|
||||||
pane.getChildren().add(vBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import ch.zhaw.gartenverwaltung.types.Seasons;
|
import ch.zhaw.gartenverwaltung.types.Seasons;
|
||||||
import javafx.beans.property.ListProperty;
|
import javafx.beans.property.ListProperty;
|
||||||
import javafx.beans.property.SimpleListProperty;
|
import javafx.beans.property.SimpleListProperty;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -27,11 +29,8 @@ import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class PlantsController implements Initializable {
|
public class PlantsController implements Initializable {
|
||||||
private static final Logger LOG = Logger.getLogger(PlantsController.class.getName());
|
|
||||||
private final PlantListModel plantListModel = new PlantListModel();
|
private final PlantListModel plantListModel = new PlantListModel();
|
||||||
private Plant selectedPlant = null;
|
private Plant selectedPlant = null;
|
||||||
private final HardinessZone DEFAULT_HARDINESS_ZONE = HardinessZone.ZONE_8A;
|
private final HardinessZone DEFAULT_HARDINESS_ZONE = HardinessZone.ZONE_8A;
|
||||||
|
@ -99,10 +98,8 @@ public class PlantsController implements Initializable {
|
||||||
lookForSelectedListEntry();
|
lookForSelectedListEntry();
|
||||||
try {
|
try {
|
||||||
viewFilteredListBySearch();
|
viewFilteredListBySearch();
|
||||||
} catch (HardinessZoneNotSetException e) {
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
LOG.log(Level.WARNING, "Hardiness Zone not set!");
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.WARNING, "Could not retrieve data!", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +107,7 @@ public class PlantsController implements Initializable {
|
||||||
* set text of list view to plant name
|
* set text of list view to plant name
|
||||||
*/
|
*/
|
||||||
private void setListCellFactory() {
|
private void setListCellFactory() {
|
||||||
list_plants.setCellFactory(param -> new ListCell<>() {
|
list_plants.setCellFactory(param -> new ListCell<Plant>() {
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(Plant plant, boolean empty) {
|
protected void updateItem(Plant plant, boolean empty) {
|
||||||
super.updateItem(plant, empty);
|
super.updateItem(plant, empty);
|
||||||
|
@ -146,15 +143,13 @@ public class PlantsController implements Initializable {
|
||||||
search_plants.textProperty().addListener((observable, oldValue, newValue) -> {
|
search_plants.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
if (newValue.isEmpty()) {
|
if (newValue.isEmpty()) {
|
||||||
fillPlantListWithHardinessZone();
|
fillPlantListWithHardinessZone();
|
||||||
} else {
|
}else {
|
||||||
try {
|
try {
|
||||||
List<Plant> filteredPlants = plantListModel.getFilteredPlantListByString(DEFAULT_HARDINESS_ZONE, newValue);
|
List<Plant> filteredPlants = plantListModel.getFilteredPlantListByString(DEFAULT_HARDINESS_ZONE, newValue);
|
||||||
clearListView();
|
clearListView();
|
||||||
plantListProperty.addAll(filteredPlants);
|
plantListProperty.addAll(filteredPlants);
|
||||||
} catch (HardinessZoneNotSetException e) {
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
LOG.log(Level.WARNING, "Hardiness Zone not set!");
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.WARNING, "Could not retrieve data!", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -168,10 +163,8 @@ public class PlantsController implements Initializable {
|
||||||
try {
|
try {
|
||||||
clearListView();
|
clearListView();
|
||||||
plantListProperty.addAll(plantListModel.getPlantList(plantListModel.getCurrentZone()));
|
plantListProperty.addAll(plantListModel.getPlantList(plantListModel.getCurrentZone()));
|
||||||
} catch (HardinessZoneNotSetException e) {
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
LOG.log(Level.WARNING, "Hardiness Zone not set!");
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.WARNING, "Could not retrieve data!", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +182,12 @@ public class PlantsController implements Initializable {
|
||||||
if (zone.equals(DEFAULT_HARDINESS_ZONE)) {
|
if (zone.equals(DEFAULT_HARDINESS_ZONE)) {
|
||||||
radioButton.setSelected(true);
|
radioButton.setSelected(true);
|
||||||
}
|
}
|
||||||
radioButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
radioButton.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||||
plantListModel.setCurrentZone(zone);
|
plantListModel.setCurrentZone(zone);
|
||||||
fillPlantListWithHardinessZone();
|
fillPlantListWithHardinessZone();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
climate_zones.getChildren().add(radioButton);
|
climate_zones.getChildren().add(radioButton);
|
||||||
}
|
}
|
||||||
|
@ -211,19 +207,20 @@ public class PlantsController implements Initializable {
|
||||||
if (season.equals(Seasons.AllSEASONS)) {
|
if (season.equals(Seasons.AllSEASONS)) {
|
||||||
radioButton.setSelected(true);
|
radioButton.setSelected(true);
|
||||||
}
|
}
|
||||||
radioButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
radioButton.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||||
if (season.equals(Seasons.AllSEASONS)) {
|
if (season.equals(Seasons.AllSEASONS)) {
|
||||||
fillPlantListWithHardinessZone();
|
fillPlantListWithHardinessZone();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
viewFilteredListBySeason(season);
|
viewFilteredListBySeason(season);
|
||||||
} catch (HardinessZoneNotSetException e) {
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
LOG.log(Level.WARNING, "Hardiness Zone not set!");
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.WARNING, "Could not retrieve data!", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
seasons.getChildren().add(radioButton);
|
seasons.getChildren().add(radioButton);
|
||||||
}
|
}
|
||||||
|
@ -240,24 +237,27 @@ public class PlantsController implements Initializable {
|
||||||
selectSowDay_button.setDisable(true);
|
selectSowDay_button.setDisable(true);
|
||||||
Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
||||||
img_plant.setImage(img);
|
img_plant.setImage(img);
|
||||||
list_plants.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
list_plants.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Plant>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Plant> observable, Plant oldValue, Plant newValue) {
|
||||||
if(newValue != null) {
|
if(newValue != null) {
|
||||||
selectedPlant = newValue;
|
selectedPlant = newValue;
|
||||||
description_plant.setText(selectedPlant.description());
|
description_plant.setText(selectedPlant.description());
|
||||||
selectSowDay_button.setDisable(false);
|
selectSowDay_button.setDisable(false);
|
||||||
Image img1;
|
Image img;
|
||||||
if(selectedPlant.image() != null) {
|
if(selectedPlant.image() != null) {
|
||||||
img1 = selectedPlant.image();
|
img = selectedPlant.image();
|
||||||
} else {
|
} else {
|
||||||
img1 = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
||||||
}
|
}
|
||||||
img_plant.setImage(img1);
|
img_plant.setImage(img);
|
||||||
} else {
|
} else {
|
||||||
selectedPlant = null;
|
selectedPlant = null;
|
||||||
description_plant.setText("");
|
description_plant.setText("");
|
||||||
selectSowDay_button.setDisable(true);
|
selectSowDay_button.setDisable(true);
|
||||||
Image img1 = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
||||||
img_plant.setImage(img1);
|
img_plant.setImage(img);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
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.GrowthPhaseType;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
|
@ -15,7 +11,6 @@ import javafx.scene.control.*;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,8 +18,6 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class SelectSowDayController implements Initializable {
|
public class SelectSowDayController implements Initializable {
|
||||||
private Plant selectedPlant = null;
|
private Plant selectedPlant = null;
|
||||||
private final TaskListModel taskListModel = new TaskListModel();
|
|
||||||
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private DatePicker datepicker;
|
private DatePicker datepicker;
|
||||||
|
@ -38,8 +31,6 @@ public class SelectSowDayController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
private RadioButton sow_radio;
|
private RadioButton sow_radio;
|
||||||
|
|
||||||
public SelectSowDayController() throws IOException {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* close the date selector window
|
* close the date selector window
|
||||||
* @param event event
|
* @param event event
|
||||||
|
@ -55,7 +46,8 @@ public class SelectSowDayController implements Initializable {
|
||||||
* @param event event
|
* @param event event
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void save(ActionEvent event) throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
|
void save(ActionEvent event) {
|
||||||
|
//ToDo save plant and sow date to crop/gardenplan model
|
||||||
LocalDate sowDate;
|
LocalDate sowDate;
|
||||||
if (sow_radio.isSelected()) {
|
if (sow_radio.isSelected()) {
|
||||||
sowDate = datepicker.getValue();
|
sowDate = datepicker.getValue();
|
||||||
|
@ -63,7 +55,8 @@ public class SelectSowDayController implements Initializable {
|
||||||
//ToDo method to get current lifecycle group in plant
|
//ToDo method to get current lifecycle group in plant
|
||||||
sowDate = selectedPlant.sowDateFromHarvestDate(datepicker.getValue(), 0);
|
sowDate = selectedPlant.sowDateFromHarvestDate(datepicker.getValue(), 0);
|
||||||
}
|
}
|
||||||
gardenplanmodel.plantAsCrop(selectedPlant, sowDate);
|
System.out.println(sowDate);
|
||||||
|
System.out.println(selectedPlant);
|
||||||
closeWindow();
|
closeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ public class JsonGardenPlan implements GardenPlan {
|
||||||
.registerModule(new Jdk8Module())
|
.registerModule(new Jdk8Module())
|
||||||
.writeValue(new File(dataSource.toURI()), cropMap.values());
|
.writeValue(new File(dataSource.toURI()), cropMap.values());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
|
// TODO: Log
|
||||||
throw new IOException(INVALID_DATASOURCE_MSG, e);
|
throw new IOException(INVALID_DATASOURCE_MSG, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,13 @@ public class GrowthPhaseTypeDeserializer extends StdDeserializer<GrowthPhaseType
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GrowthPhaseType deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
public GrowthPhaseType deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||||
GrowthPhaseType result;
|
GrowthPhaseType result = null;
|
||||||
String token = parser.getText();
|
String token = parser.getText();
|
||||||
try {
|
try {
|
||||||
result = GrowthPhaseType.valueOf(token.toUpperCase());
|
result = GrowthPhaseType.valueOf(token.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new IOException(String.format("Bad growth phase type \"%s\"\n", token));
|
// TODO: Log
|
||||||
|
System.err.printf("Bad growth phase type \"%s\"\n", token);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,13 @@ public class HardinessZoneDeserializer extends StdDeserializer<HardinessZone> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HardinessZone deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
public HardinessZone deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||||
HardinessZone result;
|
HardinessZone result = null;
|
||||||
String token = parser.getText();
|
String token = parser.getText();
|
||||||
try {
|
try {
|
||||||
result = HardinessZone.valueOf(token.toUpperCase());
|
result = HardinessZone.valueOf(token.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new IOException(String.format("Unknown Hardiness Zone \"%s\"\n", token), e);
|
// TODO: Log
|
||||||
|
System.err.printf("Unknown Hardiness Zone \"%s\"\n", token);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@ public class PlantImageDeserializer extends JsonDeserializer<Image> {
|
||||||
try (InputStream is = new FileInputStream(new File(imageUrl.toURI()))) {
|
try (InputStream is = new FileInputStream(new File(imageUrl.toURI()))) {
|
||||||
result = new Image(is);
|
result = new Image(is);
|
||||||
} catch (IllegalArgumentException | URISyntaxException e) {
|
} catch (IllegalArgumentException | URISyntaxException e) {
|
||||||
throw new IOException(String.format("Cannot find Image \"%s\"\n", imageUrl.getFile()));
|
// TODO: Log
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.printf("Cannot find Image \"%s\"\n", imageUrl.getFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -116,10 +116,9 @@ public class PlantListModel {
|
||||||
if (searchString.length() == 0) {
|
if (searchString.length() == 0) {
|
||||||
return getPlantList(zone);
|
return getPlantList(zone);
|
||||||
} else if (searchString.charAt(0) == '#') {
|
} else if (searchString.charAt(0) == '#') {
|
||||||
if (isPositiveIntegral(searchString.substring(1))) {
|
try {
|
||||||
Long searchId = Long.parseLong(searchString.substring(1));
|
return getFilteredPlantListById(zone, Long.parseLong(searchString.substring(1)));
|
||||||
return getFilteredPlantListById(zone, searchId);
|
} catch (NumberFormatException e) {
|
||||||
} else {
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -170,6 +169,7 @@ public class PlantListModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param zone selected hardiness zone
|
* @param zone selected hardiness zone
|
||||||
* @param from the earliest date to for the filter
|
* @param from the earliest date to for the filter
|
||||||
* @param to the lastest date for the filter
|
* @param to the lastest date for the filter
|
||||||
|
@ -180,14 +180,4 @@ public class PlantListModel {
|
||||||
public List<Plant> getFilteredPlantListBySaisonWithoutGrowthPhase(HardinessZone zone, MonthDay from, MonthDay to) throws HardinessZoneNotSetException, IOException {
|
public List<Plant> getFilteredPlantListBySaisonWithoutGrowthPhase(HardinessZone zone, MonthDay from, MonthDay to) throws HardinessZoneNotSetException, IOException {
|
||||||
return getFilteredPlantList(zone, plant -> plant.lifecycle().stream().anyMatch(growthPhase -> growthPhase.startDate().compareTo(from) >= 0 && (growthPhase.startDate().compareTo(to) <= 0)));
|
return getFilteredPlantList(zone, plant -> plant.lifecycle().stream().anyMatch(growthPhase -> growthPhase.startDate().compareTo(from) >= 0 && (growthPhase.startDate().compareTo(to) <= 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a string can safely be parsed as a positive Integral value (short/int/long)
|
|
||||||
*
|
|
||||||
* @param subject The string to be tested
|
|
||||||
* @return Whether the string contains only digits
|
|
||||||
*/
|
|
||||||
private boolean isPositiveIntegral(String subject) {
|
|
||||||
return subject != null && subject.matches("[0-9]+");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package ch.zhaw.gartenverwaltung.taskList;
|
package ch.zhaw.gartenverwaltung.taskList;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.Config;
|
import ch.zhaw.gartenverwaltung.Config;
|
||||||
import ch.zhaw.gartenverwaltung.io.*;
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.JsonTaskDatabase;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.PlantDatabase;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.TaskDatabase;
|
||||||
import ch.zhaw.gartenverwaltung.types.*;
|
import ch.zhaw.gartenverwaltung.types.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -23,7 +26,6 @@ public class TaskListModel {
|
||||||
|
|
||||||
public TaskListModel(){
|
public TaskListModel(){
|
||||||
taskDatabase = new JsonTaskDatabase();
|
taskDatabase = new JsonTaskDatabase();
|
||||||
plantDatabase = new JsonPlantDatabase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class Task {
|
||||||
name= "";
|
name= "";
|
||||||
description= "";
|
description= "";
|
||||||
startDate = LocalDate.now();
|
startDate = LocalDate.now();
|
||||||
|
//this.cropId = cropId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task(String name, String description, LocalDate startDate, long cropId) {
|
public Task(String name, String description, LocalDate startDate, long cropId) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ module ch.zhaw.gartenverwaltung {
|
||||||
requires com.fasterxml.jackson.databind;
|
requires com.fasterxml.jackson.databind;
|
||||||
requires com.fasterxml.jackson.datatype.jsr310;
|
requires com.fasterxml.jackson.datatype.jsr310;
|
||||||
requires com.fasterxml.jackson.datatype.jdk8;
|
requires com.fasterxml.jackson.datatype.jdk8;
|
||||||
requires java.logging;
|
|
||||||
|
|
||||||
opens ch.zhaw.gartenverwaltung to javafx.fxml;
|
opens ch.zhaw.gartenverwaltung to javafx.fxml;
|
||||||
opens ch.zhaw.gartenverwaltung.types to com.fasterxml.jackson.databind;
|
opens ch.zhaw.gartenverwaltung.types to com.fasterxml.jackson.databind;
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.ScrollPane?>
|
|
||||||
<?import javafx.scene.image.ImageView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
|
||||||
<?import javafx.scene.layout.GridPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="785.0" prefWidth="899.0"
|
|
||||||
xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.CropDetailController">
|
|
||||||
<children>
|
|
||||||
<ScrollPane fitToWidth="true" prefHeight="759.0" prefWidth="664.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<content>
|
|
||||||
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="503.0" prefWidth="897.0">
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
<children>
|
|
||||||
<Button mnemonicParsing="false" onAction="#goBack" prefHeight="25.0" prefWidth="91.0" text="Go Back">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Button>
|
|
||||||
<Label fx:id="cropName_label" text="Label">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<HBox prefHeight="265.0" prefWidth="879.0">
|
|
||||||
<children>
|
|
||||||
<GridPane maxWidth="1.7976931348623157E308" prefHeight="296.0" prefWidth="577.0" HBox.hgrow="ALWAYS">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" maxWidth="284.0" minWidth="10.0" prefWidth="97.33334350585938" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="488.99999237060547" minWidth="10.0" prefWidth="481.9999898274739" />
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints maxHeight="149.66665903727215" minHeight="10.0" prefHeight="149.66665903727215" valignment="TOP" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="187.9999647140503" minHeight="10.0" prefHeight="51.00000762939453" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="105.66662597656247" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints maxHeight="105.66662597656247" minHeight="10.0" prefHeight="46.66666666666666" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<Label prefHeight="17.0" prefWidth="65.0" text="Description:">
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets top="10.0" />
|
|
||||||
</GridPane.margin>
|
|
||||||
</Label>
|
|
||||||
<Label text="Light-Level:" GridPane.rowIndex="1" />
|
|
||||||
<Label text="Spacing:" GridPane.rowIndex="2" />
|
|
||||||
<Label text="Soil-Type:" GridPane.rowIndex="3" />
|
|
||||||
<Label fx:id="description_label" text="Label" wrapText="true" GridPane.columnIndex="1">
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets left="10.0" top="10.0" />
|
|
||||||
</GridPane.margin>
|
|
||||||
</Label>
|
|
||||||
<Label fx:id="light_label" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets left="10.0" />
|
|
||||||
</GridPane.margin>
|
|
||||||
</Label>
|
|
||||||
<Label fx:id="spacing_label" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets left="10.0" />
|
|
||||||
</GridPane.margin>
|
|
||||||
</Label>
|
|
||||||
<Label fx:id="soil_label" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets left="10.0" />
|
|
||||||
</GridPane.margin>
|
|
||||||
</Label>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
<ImageView fx:id="imageView" fitHeight="300.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<Label text="Growth Phases:">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<VBox fx:id="growthPhases_vbox" prefHeight="135.0" prefWidth="879.0">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</VBox>
|
|
||||||
<Button mnemonicParsing="false" onAction="#editTaskList" prefHeight="25.0" prefWidth="92.0" text="Edit Tasklist">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Button>
|
|
||||||
<Label text="Pests:" />
|
|
||||||
<VBox fx:id="pests_vbox" prefHeight="200.0" prefWidth="100.0">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</VBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" VBox.vgrow="NEVER">
|
|
||||||
<children>
|
|
||||||
<Label text="Area:">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="60.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</Label>
|
|
||||||
<Label fx:id="area_label" text="Label">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="10.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</Label>
|
|
||||||
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Add Area" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="719.0" prefHeight="100.0" prefWidth="200.0" VBox.vgrow="NEVER">
|
|
||||||
<children>
|
|
||||||
<Label text="Location:">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="40.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</Label>
|
|
||||||
<Label fx:id="location_label" text="Label">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="10.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</Label>
|
|
||||||
<Button fx:id="location_button" mnemonicParsing="false" onAction="#setLocation" prefHeight="25.0" prefWidth="115.0" text="Add Location" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
</VBox>
|
|
||||||
</content>
|
|
||||||
</ScrollPane>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
|
@ -7,7 +7,9 @@
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="655.0" prefWidth="1175.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyPlantsController">
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="655.0" prefWidth="1175.0" xmlns="http://javafx.com/javafx/17"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyPlantsController">
|
||||||
<children>
|
<children>
|
||||||
<VBox layoutY="49.0" prefHeight="655.0" prefWidth="1175.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<VBox layoutY="49.0" prefHeight="655.0" prefWidth="1175.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
|
@ -19,7 +21,7 @@
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<VBox fx:id="myPlants_vbox" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="100.0" VBox.vgrow="ALWAYS" />
|
<VBox fx:id="myPlants_vbox" prefHeight="200.0" prefWidth="100.0" VBox.vgrow="ALWAYS" />
|
||||||
<Button fx:id="addPlant_button" mnemonicParsing="false" onAction="#addPlant" prefHeight="45.0" prefWidth="155.0" text="Add new Plant">
|
<Button fx:id="addPlant_button" mnemonicParsing="false" onAction="#addPlant" prefHeight="45.0" prefWidth="155.0" text="Add new Plant">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets top="10.0" />
|
<Insets top="10.0" />
|
||||||
|
|
Loading…
Reference in New Issue