Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c64339c945 | ||
|
|
21643e5d63 | ||
|
|
e9fbbf2f9f | ||
|
|
ce8bdaba7e | ||
|
|
7e5730a19f | ||
|
|
ec42a6e75a | ||
|
|
2452e42b72 | ||
|
|
3d36c85941 | ||
|
|
84df4c07a1 | ||
|
|
4ae9eec9f7 | ||
|
|
d0959f535b | ||
|
|
129a26e1a9 | ||
|
|
e9258fb238 | ||
|
|
6d24687f7b | ||
|
|
2ec37114de | ||
|
|
aedcfe2be9 | ||
|
|
b3f839e4a3 | ||
|
|
1dc2ad1774 | ||
|
|
e75ececedb | ||
|
|
560cea2ff9 | ||
|
|
4e720c2ddc | ||
|
|
77541c282c | ||
|
|
c79386ec88 | ||
|
|
f36826ef29 | ||
|
|
c9ba9c1234 | ||
|
|
04e4ea1dea | ||
|
|
1f049f86ab | ||
|
|
9b08113ff9 | ||
|
|
f389cfcdfd | ||
|
|
e22cb0b24d | ||
|
|
1c83fc4694 | ||
|
|
df19edb25a | ||
|
|
6b7a6f095d | ||
|
|
b2c0886e46 | ||
|
|
775e35a70b | ||
|
|
d7b9095050 | ||
|
|
bcb36b89c7 | ||
|
|
f7105f041c | ||
|
|
b0369e3174 | ||
|
|
8c20dcaadb | ||
|
|
95b0f7e13d | ||
|
|
2312149256 | ||
|
|
ffc7f5174e | ||
|
|
8d3fbc06ad | ||
|
|
dcb97f1c55 | ||
|
|
ee67c83b22 | ||
|
|
2963872237 | ||
|
|
7920bdff28 | ||
|
|
e96280cd0c | ||
|
|
bfe3fcfb79 | ||
|
|
8e3af2ba32 | ||
|
|
b70a758099 | ||
|
|
3a69119eb7 | ||
|
|
165dc6d901 | ||
|
|
384dc2d853 | ||
|
|
2f69c48800 | ||
|
|
86a9eeaf2e | ||
|
|
9ba252b828 | ||
|
|
90d2de65de |
@@ -1,5 +1,6 @@
|
|||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
import ch.zhaw.gartenverwaltung.io.PlantList;
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
import ch.zhaw.gartenverwaltung.models.Garden;
|
||||||
@@ -10,13 +11,19 @@ import ch.zhaw.gartenverwaltung.types.Crop;
|
|||||||
import ch.zhaw.gartenverwaltung.types.Pest;
|
import ch.zhaw.gartenverwaltung.types.Pest;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
|
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;
|
import javafx.fxml.FXML;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -34,7 +41,12 @@ public class CropDetailController {
|
|||||||
@Inject
|
@Inject
|
||||||
private Garden garden;
|
private Garden garden;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
AppLoader appLoader;
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(CropDetailController.class.getName());
|
private static final Logger LOG = Logger.getLogger(CropDetailController.class.getName());
|
||||||
|
private final ListProperty<Task> taskListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
|
private final ListProperty<Pest> pestListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
@@ -51,9 +63,6 @@ public class CropDetailController {
|
|||||||
@FXML
|
@FXML
|
||||||
private Label description_label;
|
private Label description_label;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private VBox growthPhases_vbox;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label location_label;
|
private Label location_label;
|
||||||
|
|
||||||
@@ -63,9 +72,6 @@ public class CropDetailController {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button location_button;
|
private Button location_button;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private VBox pests_vbox;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label soil_label;
|
private Label soil_label;
|
||||||
|
|
||||||
@@ -73,54 +79,125 @@ public class CropDetailController {
|
|||||||
private Label spacing_label;
|
private Label spacing_label;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void editTaskList() {
|
private Button addTask_button;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<Task> taskList_listView;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<Pest> pests_listView;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void addTask() throws IOException, HardinessZoneNotSetException {
|
||||||
|
createTaskDialog(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* close Window
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void goBack() {
|
void goBack() {
|
||||||
Stage stage = (Stage) imageView.getScene().getWindow();
|
Stage stage = (Stage) imageView.getScene().getWindow();
|
||||||
stage.close();
|
stage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* open dialog to set area
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void setArea() {
|
void setArea() throws IOException {
|
||||||
|
openTextFieldDialog("set Text Area", "Text Area", area_label.getText(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* open dialog to set location
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void setLocation() {
|
void setLocation() throws IOException {
|
||||||
|
openTextFieldDialog("set Location", "Location", location_label.getText(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlantFromCrop(Crop crop) throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
|
/**
|
||||||
|
* set labels and image from selected {@link Crop}
|
||||||
|
* set icons for buttons
|
||||||
|
* @param crop {@link Crop} which will be displayed
|
||||||
|
* @throws PlantNotFoundException exception
|
||||||
|
*/
|
||||||
|
public void setPlantFromCrop(Crop crop) throws PlantNotFoundException {
|
||||||
this.crop = crop;
|
this.crop = crop;
|
||||||
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId())
|
try {
|
||||||
.orElseThrow(PlantNotFoundException::new);
|
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId())
|
||||||
|
.orElseThrow(PlantNotFoundException::new);
|
||||||
|
|
||||||
cropName_label.setText(plant.name());
|
cropName_label.setText(plant.name());
|
||||||
description_label.setText(plant.description());
|
description_label.setText(plant.description());
|
||||||
light_label.setText(String.valueOf(plant.light()));
|
light_label.setText(String.valueOf(plant.light()));
|
||||||
soil_label.setText(plant.soil());
|
soil_label.setText(plant.soil());
|
||||||
spacing_label.setText(plant.spacing());
|
spacing_label.setText(plant.spacing());
|
||||||
if (plant.image() != null) {
|
if (plant.image() != null) {
|
||||||
imageView.setImage(plant.image());
|
imageView.setImage(plant.image());
|
||||||
|
}
|
||||||
|
area_label.setText(String.valueOf(crop.getArea()));
|
||||||
|
location_label.setText("");
|
||||||
|
|
||||||
|
setTaskListProperty(crop);
|
||||||
|
taskList_listView.itemsProperty().bind(taskListProperty);
|
||||||
|
|
||||||
|
pestListProperty.addAll(plant.pests());
|
||||||
|
pests_listView.itemsProperty().bind(pestListProperty);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
|
throw new PlantNotFoundException();
|
||||||
}
|
}
|
||||||
area_label.setText("");
|
setIconToButton(addTask_button, "addIcon.png");
|
||||||
location_label.setText("");
|
setIconToButton(area_button, "areaIcon.png");
|
||||||
createTaskLists(crop);
|
setIconToButton(location_button, "locationIcon.png");
|
||||||
createPestList(plant);
|
setCellFactoryPests();
|
||||||
|
setCellFactoryTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTaskLists(Crop crop) {
|
private void setCellFactoryTasks() {
|
||||||
|
taskList_listView.setCellFactory(param -> new ListCell<>() {
|
||||||
|
@Override
|
||||||
|
protected void updateItem(Task task, boolean empty) {
|
||||||
|
super.updateItem(task, empty);
|
||||||
|
|
||||||
|
if (empty || task == null) {
|
||||||
|
setText(null);
|
||||||
|
setGraphic(null);
|
||||||
|
} else {
|
||||||
|
setText("");
|
||||||
|
setGraphic(createTaskHBox(task));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCellFactoryPests() {
|
||||||
|
pests_listView.setCellFactory(param -> new ListCell<>() {
|
||||||
|
@Override
|
||||||
|
protected void updateItem(Pest pest, boolean empty) {
|
||||||
|
super.updateItem(pest, empty);
|
||||||
|
|
||||||
|
if (empty || pest == null) {
|
||||||
|
setText(null);
|
||||||
|
setGraphic(null);
|
||||||
|
} else {
|
||||||
|
setText("");
|
||||||
|
setGraphic(createPestHBox(pest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTaskListProperty(Crop crop) {
|
||||||
crop.getCropId().ifPresent(id -> {
|
crop.getCropId().ifPresent(id -> {
|
||||||
List<Task> taskList;
|
List<Task> taskList;
|
||||||
try {
|
try {
|
||||||
taskList = gardenSchedule.getTaskListForCrop(id);
|
taskList = gardenSchedule.getTaskListForCrop(id);
|
||||||
for (Task task : taskList) {
|
taskListProperty.clear();
|
||||||
Label label = new Label(task.getDescription());
|
taskListProperty.addAll(taskList);
|
||||||
growthPhases_vbox.getChildren().add(label);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO: Alert
|
// TODO: Alert
|
||||||
LOG.log(Level.SEVERE, "Could not get task list for crop", e.getCause());
|
LOG.log(Level.SEVERE, "Could not get task list for crop", e.getCause());
|
||||||
@@ -128,21 +205,172 @@ public class CropDetailController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPestList(Plant plant) {
|
private HBox createTaskHBox(Task task) {
|
||||||
List<Pest> pests = plant.pests();
|
HBox hBox = new HBox(10);
|
||||||
for (Pest pest : pests) {
|
Label taskName = new Label(task.getName()+": ");
|
||||||
Label label = new Label(pest.name() + ":");
|
taskName.setMinWidth(100);
|
||||||
label.setStyle("-fx-font-weight: bold");
|
taskName.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
||||||
HBox hBox = new HBox();
|
taskName.setStyle("-fx-font-weight: bold");
|
||||||
hBox.fillHeightProperty();
|
Label taskDescription = new Label(task.getDescription());
|
||||||
Label label1 = new Label(pest.description());
|
taskDescription.setWrapText(true);
|
||||||
label1.setAlignment(Pos.TOP_LEFT);
|
taskDescription.setMaxSize(600, Double.MAX_VALUE);
|
||||||
label1.setWrapText(true);
|
Pane puffer = new Pane();
|
||||||
label1.setMaxWidth(600);
|
HBox.setHgrow(puffer, Priority.ALWAYS);
|
||||||
label1.setMaxHeight(100);
|
|
||||||
Button button = new Button("Get Counter Measures");
|
|
||||||
hBox.getChildren().addAll(label1, button);
|
Button edit = new Button();
|
||||||
pests_vbox.getChildren().addAll(label, hBox);
|
Button delete = new Button();
|
||||||
|
HBox.setHgrow(edit, Priority.NEVER);
|
||||||
|
HBox.setHgrow(delete, Priority.NEVER);
|
||||||
|
setIconToButton(edit, "editIcon.png");
|
||||||
|
setIconToButton(delete, "deleteIcon.png");
|
||||||
|
edit.setOnAction(getEditTaskEvent(task));
|
||||||
|
delete.setOnAction(deleteTask(task));
|
||||||
|
|
||||||
|
hBox.getChildren().addAll(taskName, taskDescription, puffer, edit, delete);
|
||||||
|
return hBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HBox createPestHBox(Pest pest) {
|
||||||
|
Label label = new Label(pest.name() + ": ");
|
||||||
|
label.setStyle("-fx-font-weight: bold");
|
||||||
|
HBox hBox = new HBox();
|
||||||
|
hBox.fillHeightProperty();
|
||||||
|
Label description = new Label(pest.description());
|
||||||
|
description.setAlignment(Pos.TOP_LEFT);
|
||||||
|
description.setWrapText(true);
|
||||||
|
description.setMaxWidth(600);
|
||||||
|
Pane puffer = new Pane();
|
||||||
|
HBox.setHgrow(puffer, Priority.ALWAYS);
|
||||||
|
Button button = new Button("Get Counter Measures");
|
||||||
|
HBox.setHgrow(button, Priority.NEVER);
|
||||||
|
hBox.getChildren().addAll(label, description, puffer, button);
|
||||||
|
return hBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds icon to button
|
||||||
|
* @param button the button which get the icon
|
||||||
|
* @param iconFileName file name of icon
|
||||||
|
*/
|
||||||
|
private void setIconToButton(Button button, String iconFileName) {
|
||||||
|
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
||||||
|
ImageView imageView = new ImageView(img);
|
||||||
|
imageView.setFitHeight(20);
|
||||||
|
imageView.setPreserveRatio(true);
|
||||||
|
button.setGraphic(imageView);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventHandler<ActionEvent> getEditTaskEvent(Task task) {
|
||||||
|
return (event) -> {
|
||||||
|
try {
|
||||||
|
createTaskDialog(false, task);
|
||||||
|
} catch (IOException | HardinessZoneNotSetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventHandler<ActionEvent> deleteTask(Task task) {
|
||||||
|
return (event) -> {
|
||||||
|
showDeleteTask(task);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTaskDialog(boolean newTask, Task givenTask) throws IOException, HardinessZoneNotSetException {
|
||||||
|
Dialog<Task> dialog = new Dialog<>();
|
||||||
|
dialog.setTitle("Set Task");
|
||||||
|
dialog.setHeaderText("Add/Edit Task:");
|
||||||
|
dialog.setResizable(false);
|
||||||
|
|
||||||
|
DialogPane dialogPane = dialog.getDialogPane();
|
||||||
|
|
||||||
|
ButtonType saveTask;
|
||||||
|
if(newTask) {
|
||||||
|
saveTask = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
|
||||||
|
} else {
|
||||||
|
saveTask = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
||||||
|
}
|
||||||
|
dialogPane.getButtonTypes().addAll(saveTask, ButtonType.CANCEL);
|
||||||
|
|
||||||
|
if (appLoader.loadPaneToDialog("TaskFormular.fxml", dialogPane) instanceof TaskFormularController controller) {
|
||||||
|
controller.setCorp(this.crop);
|
||||||
|
controller.initSaveButton((Button) dialogPane.lookupButton(saveTask));
|
||||||
|
if (!newTask) {
|
||||||
|
controller.setTaskValue(givenTask);
|
||||||
|
}
|
||||||
|
dialog.setResultConverter(button -> button.equals(saveTask) ? controller.returnResult(this.crop) : null);
|
||||||
|
|
||||||
|
dialog.showAndWait()
|
||||||
|
.ifPresent(task -> {
|
||||||
|
if (newTask) {
|
||||||
|
try {
|
||||||
|
gardenSchedule.addTask(task);
|
||||||
|
setTaskListProperty(this.crop);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//ToDo method to edit task
|
||||||
|
setTaskListProperty(this.crop);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openTextFieldDialog(String title, String labelDescription, String value, boolean isLocation) throws IOException {
|
||||||
|
Dialog<String> dialog = new Dialog<>();
|
||||||
|
dialog.setTitle(title);
|
||||||
|
dialog.setHeaderText(title);
|
||||||
|
dialog.setResizable(false);
|
||||||
|
|
||||||
|
DialogPane dialogPane = dialog.getDialogPane();
|
||||||
|
|
||||||
|
ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
||||||
|
dialogPane.getButtonTypes().addAll(save, ButtonType.CANCEL);
|
||||||
|
|
||||||
|
if (appLoader.loadPaneToDialog("TextFieldFormular.fxml", dialogPane) instanceof TextFieldFormularController controller) {
|
||||||
|
controller.setDescription_label(labelDescription);
|
||||||
|
controller.setValueTextArea(value);
|
||||||
|
controller.initSaveButton((Button) dialogPane.lookupButton(save));
|
||||||
|
|
||||||
|
dialog.setResultConverter(button -> button.equals(save) ? controller.getValue() : null);
|
||||||
|
|
||||||
|
dialog.showAndWait()
|
||||||
|
.ifPresent(string -> {
|
||||||
|
if (isLocation) {
|
||||||
|
System.out.println(string);
|
||||||
|
//ToDo method to set location
|
||||||
|
location_label.setText(string);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
garden.updateCrop(this.crop.withArea(Double.parseDouble(string)));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
area_label.setText(string);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showDeleteTask(Task task) {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||||
|
alert.setTitle("Delete " + task.getName());
|
||||||
|
alert.setHeaderText("Are you sure want to delete this Task?");
|
||||||
|
|
||||||
|
alert.showAndWait()
|
||||||
|
.ifPresent(buttonType -> {
|
||||||
|
if (buttonType == ButtonType.OK) {
|
||||||
|
try {
|
||||||
|
gardenSchedule.removeTask(task);
|
||||||
|
setTaskListProperty(this.crop);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO: Show error alert
|
||||||
|
LOG.log(Level.SEVERE, "Could not remove crop.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
|
|
||||||
public class HelloController {
|
|
||||||
@FXML
|
|
||||||
private Label welcomeText;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void onHelloButtonClick() {
|
|
||||||
welcomeText.setText("Welcome to JavaFX Application!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,47 @@
|
|||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
public class HomeController
|
import javafx.fxml.FXML;
|
||||||
{
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class HomeController implements Initializable {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ImageView imageViewDavid;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ImageView imageViewElias;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ImageView imageViewGian;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ImageView imageViewPhilippe;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ImageView imageViewRoman;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
setImages(imageViewDavid, "");
|
||||||
|
setImages(imageViewElias, "");
|
||||||
|
setImages(imageViewGian, "");
|
||||||
|
setImages(imageViewRoman, "");
|
||||||
|
setImages(imageViewPhilippe, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setImages(ImageView imageView, String photoName) {
|
||||||
|
Image img;
|
||||||
|
if (photoName.equals("")) {
|
||||||
|
img = new Image(String.valueOf(getClass().getResource("icons/userIcon.png")));
|
||||||
|
} else {
|
||||||
|
img = new Image(String.valueOf(getClass().getResource("icons/" + photoName)));
|
||||||
|
}
|
||||||
|
imageView.setImage(img);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ import ch.zhaw.gartenverwaltung.bootstrap.ChangeViewEvent;
|
|||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.stage.Modality;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.WindowEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -33,30 +38,86 @@ public class MainFXMLController {
|
|||||||
private Button mySchedule_button;
|
private Button mySchedule_button;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button plants_button;
|
private Button settings_button;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button tutorial_button;
|
||||||
|
|
||||||
|
private final Stage tutorialModal = new Stage();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* go to home pane
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void goToHome() {
|
void goToHome() {
|
||||||
showPaneAsMainView("Home.fxml");
|
showPaneAsMainView("Home.fxml");
|
||||||
styleChangeButton(home_button);
|
styleChangeButton(home_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* go to my garden pane
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void goToMyPlants() {
|
void goToMyPlants() {
|
||||||
showPaneAsMainView("MyGarden.fxml");
|
showPaneAsMainView("MyGarden.fxml");
|
||||||
styleChangeButton(myGarden_button);
|
styleChangeButton(myGarden_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* go to the schedule pane
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void goToMySchedule() {
|
void goToMySchedule() {
|
||||||
showPaneAsMainView("MySchedule.fxml");
|
showPaneAsMainView("MySchedule.fxml");
|
||||||
styleChangeButton(mySchedule_button);
|
styleChangeButton(mySchedule_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* open dialog of the settings
|
||||||
|
* @throws IOException exception
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void goToPlants() {
|
public void openSettings() throws IOException {
|
||||||
showPaneAsMainView("Plants.fxml");
|
Dialog<ButtonType> dialog = new Dialog<>();
|
||||||
styleChangeButton(plants_button);
|
dialog.setTitle("Settings");
|
||||||
|
dialog.setHeaderText("Settings");
|
||||||
|
dialog.setResizable(false);
|
||||||
|
|
||||||
|
DialogPane dialogPane = dialog.getDialogPane();
|
||||||
|
|
||||||
|
ButtonType saveSettings = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
||||||
|
dialogPane.getButtonTypes().addAll(saveSettings, ButtonType.CANCEL);
|
||||||
|
|
||||||
|
if (appLoader.loadPaneToDialog("Settings.fxml", dialogPane) instanceof SettingsController controller) {
|
||||||
|
|
||||||
|
dialog.showAndWait()
|
||||||
|
.ifPresent(button -> {
|
||||||
|
if (button.equals(saveSettings)) {
|
||||||
|
controller.saveSettings();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the tutorial window
|
||||||
|
*/
|
||||||
|
public void showTutorial() {
|
||||||
|
if (!tutorialModal.isShowing()) {
|
||||||
|
if (tutorialModal.getScene() == null) {
|
||||||
|
try {
|
||||||
|
appLoader.loadSceneToStage("Tutorial.fxml", tutorialModal);
|
||||||
|
tutorialModal.initModality(Modality.NONE);
|
||||||
|
tutorialModal.setResizable(false);
|
||||||
|
tutorialModal.sizeToScene();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.log(Level.SEVERE, "Could not load Tutorial");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tutorialModal.show();
|
||||||
|
}
|
||||||
|
tutorialModal.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +142,10 @@ public class MainFXMLController {
|
|||||||
|
|
||||||
private final EventHandler<ChangeViewEvent> changeMainViewHandler = (ChangeViewEvent event) -> showPaneAsMainView(event.view());
|
private final EventHandler<ChangeViewEvent> changeMainViewHandler = (ChangeViewEvent event) -> showPaneAsMainView(event.view());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* preload all menu bar panes
|
||||||
|
* @throws IOException exception
|
||||||
|
*/
|
||||||
private void preloadPanes() throws IOException {
|
private void preloadPanes() throws IOException {
|
||||||
appLoader.loadAndCacheFxml("MyGarden.fxml");
|
appLoader.loadAndCacheFxml("MyGarden.fxml");
|
||||||
appLoader.loadAndCacheFxml("MySchedule.fxml");
|
appLoader.loadAndCacheFxml("MySchedule.fxml");
|
||||||
@@ -100,11 +165,31 @@ public class MainFXMLController {
|
|||||||
public void init() {
|
public void init() {
|
||||||
try {
|
try {
|
||||||
preloadPanes();
|
preloadPanes();
|
||||||
showPaneAsMainView("Home.fxml");
|
showPaneAsMainView("MyGarden.fxml");
|
||||||
styleChangeButton(home_button);
|
styleChangeButton(myGarden_button);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.log(Level.SEVERE, "Failed to load FXML-Pane!", e);
|
LOG.log(Level.SEVERE, "Failed to load FXML-Pane!", e);
|
||||||
}
|
}
|
||||||
|
mainPane.getScene().getWindow().setOnCloseRequest(this::closeWindowHandler);
|
||||||
|
setIconToButton(home_button, "homeIcon.png");
|
||||||
|
setIconToButton(settings_button, "settingsIcon.png");
|
||||||
|
tutorial_button.visibleProperty().bind(Settings.getInstance().getShowTutorialProperty());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeWindowHandler(WindowEvent windowEvent) {
|
||||||
|
tutorialModal.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds icon to given button
|
||||||
|
* @param button the button which get the icon
|
||||||
|
* @param iconFileName file name of icon
|
||||||
|
*/
|
||||||
|
private void setIconToButton(Button button, String iconFileName) {
|
||||||
|
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
||||||
|
ImageView imageView = new ImageView(img);
|
||||||
|
imageView.setFitHeight(20);
|
||||||
|
imageView.setPreserveRatio(true);
|
||||||
|
button.setGraphic(imageView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,15 +13,12 @@ import ch.zhaw.gartenverwaltung.types.Plant;
|
|||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.control.ButtonType;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.Priority;
|
import javafx.scene.layout.Priority;
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
@@ -42,39 +39,63 @@ public class MyGardenController {
|
|||||||
@FXML
|
@FXML
|
||||||
public AnchorPane myGardenRoot;
|
public AnchorPane myGardenRoot;
|
||||||
@FXML
|
@FXML
|
||||||
private VBox myPlants_vbox;
|
private Button addPlant_button;
|
||||||
|
@FXML
|
||||||
|
private ListView<Crop> myGarden_listView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize crop list
|
||||||
|
* add listener for crop list
|
||||||
|
* set icon for button
|
||||||
|
*/
|
||||||
@AfterInject
|
@AfterInject
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void init() {
|
public void init() {
|
||||||
garden.getPlantedCrops().addListener((observable, oldValue, newValue) -> {
|
setIconToButton(addPlant_button, "addIcon.png");
|
||||||
try {
|
myGarden_listView.itemsProperty().bind(garden.getPlantedCrops());
|
||||||
createPlantView(newValue);
|
setCellFactory();
|
||||||
} catch (HardinessZoneNotSetException | IOException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not update view of croplist!", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
createPlantView(garden.getPlantedCrops());
|
|
||||||
} catch (HardinessZoneNotSetException | IOException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not update view of croplist!", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* redirect to plant fxml file
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void addPlant() {
|
void addPlant() {
|
||||||
myGardenRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "Plants.fxml"));
|
myGardenRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "Plants.fxml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPlantView(List<Crop> crops) throws HardinessZoneNotSetException, IOException {
|
/**
|
||||||
myPlants_vbox.getChildren().clear();
|
* set cell factory to load {@link HBox} as list view content
|
||||||
for (Crop crop : crops) {
|
*/
|
||||||
HBox hBox = createPlantView(crop);
|
private void setCellFactory() {
|
||||||
myPlants_vbox.getChildren().add(hBox);
|
myGarden_listView.setCellFactory(param -> new ListCell<>() {
|
||||||
}
|
@Override
|
||||||
|
protected void updateItem(Crop crop, boolean empty) {
|
||||||
|
super.updateItem(crop, empty);
|
||||||
|
|
||||||
|
if (empty || crop == null) {
|
||||||
|
setText(null);
|
||||||
|
setGraphic(null);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
setText("");
|
||||||
|
setGraphic(createHBoxForListView(crop));
|
||||||
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
|
LOG.log(Level.WARNING, "Could not get plant for Cell", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private HBox createPlantView(Crop crop) throws HardinessZoneNotSetException, IOException {
|
/**
|
||||||
|
* Creates and returns HBox of the crop
|
||||||
|
* @param crop {@link Crop} which is selected
|
||||||
|
* @return {@link HBox} of the {@link Crop}
|
||||||
|
* @throws HardinessZoneNotSetException exception
|
||||||
|
* @throws IOException exception
|
||||||
|
*/
|
||||||
|
private HBox createHBoxForListView(Crop crop) throws HardinessZoneNotSetException, IOException {
|
||||||
//ToDo add better design
|
//ToDo add better design
|
||||||
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
|
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
|
||||||
HBox hBox = new HBox(10);
|
HBox hBox = new HBox(10);
|
||||||
@@ -90,14 +111,36 @@ public class MyGardenController {
|
|||||||
Label label = new Label(plant.name());
|
Label label = new Label(plant.name());
|
||||||
label.setMaxWidth(2000);
|
label.setMaxWidth(2000);
|
||||||
HBox.setHgrow(label, Priority.ALWAYS);
|
HBox.setHgrow(label, Priority.ALWAYS);
|
||||||
Button details = new Button("Details");
|
|
||||||
Button delete = new Button("delete");
|
Button details = new Button();
|
||||||
|
Button delete = new Button();
|
||||||
|
setIconToButton(details, "detailsIcon.png");
|
||||||
|
setIconToButton(delete, "deleteIcon.png");
|
||||||
details.setOnAction(getGoToCropDetailEvent(crop));
|
details.setOnAction(getGoToCropDetailEvent(crop));
|
||||||
delete.setOnAction(getDeleteCropEvent(crop));
|
delete.setOnAction(getDeleteCropEvent(crop));
|
||||||
|
|
||||||
hBox.getChildren().addAll(imageView, label, details, delete);
|
hBox.getChildren().addAll(imageView, label, details, delete);
|
||||||
return hBox;
|
return hBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds icon to button
|
||||||
|
* @param button the button which get the icon
|
||||||
|
* @param iconFileName file name of icon
|
||||||
|
*/
|
||||||
|
private void setIconToButton(Button button, String iconFileName) {
|
||||||
|
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
||||||
|
ImageView imageView = new ImageView(img);
|
||||||
|
imageView.setFitHeight(20);
|
||||||
|
imageView.setPreserveRatio(true);
|
||||||
|
button.setGraphic(imageView);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* open detail window of the selected {@link Crop}
|
||||||
|
* @param crop {@link Crop} which is selected
|
||||||
|
* @return {@link EventHandler} for button
|
||||||
|
*/
|
||||||
private EventHandler<ActionEvent> getGoToCropDetailEvent(Crop crop) {
|
private EventHandler<ActionEvent> getGoToCropDetailEvent(Crop crop) {
|
||||||
return (event) -> {
|
return (event) -> {
|
||||||
try {
|
try {
|
||||||
@@ -108,13 +151,18 @@ public class MyGardenController {
|
|||||||
stage.initModality(Modality.APPLICATION_MODAL);
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
stage.setResizable(true);
|
stage.setResizable(true);
|
||||||
stage.showAndWait();
|
stage.showAndWait();
|
||||||
} catch (IOException | HardinessZoneNotSetException | PlantNotFoundException e) {
|
} catch (IOException | PlantNotFoundException e) {
|
||||||
// TODO: show error alert
|
// TODO: show error alert
|
||||||
LOG.log(Level.SEVERE, "Could not load plant details.", e);
|
LOG.log(Level.SEVERE, "Could not load plant details.", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* open alert for deleting the selected {@link Crop}
|
||||||
|
* @param crop {@link Crop} which is selected
|
||||||
|
* @return {@link EventHandler} for button
|
||||||
|
*/
|
||||||
private EventHandler<ActionEvent> getDeleteCropEvent(Crop crop) {
|
private EventHandler<ActionEvent> getDeleteCropEvent(Crop crop) {
|
||||||
return (event) -> {
|
return (event) -> {
|
||||||
try {
|
try {
|
||||||
@@ -125,9 +173,16 @@ public class MyGardenController {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alert to confirm that the crop can be deleted.
|
||||||
|
* @param crop {@link Crop} which is selected
|
||||||
|
* @throws IOException exception
|
||||||
|
* @throws HardinessZoneNotSetException exception
|
||||||
|
*/
|
||||||
private void showConfirmation(Crop crop) throws IOException, HardinessZoneNotSetException {
|
private void showConfirmation(Crop crop) throws IOException, HardinessZoneNotSetException {
|
||||||
|
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
|
||||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||||
alert.setTitle("Delete Crop");
|
alert.setTitle("Delete " + plant.name());
|
||||||
alert.setHeaderText("Are you sure want to delete this Crop?");
|
alert.setHeaderText("Are you sure want to delete this Crop?");
|
||||||
alert.setContentText("Deleting this crop will remove all associated tasks from your schedule.");
|
alert.setContentText("Deleting this crop will remove all associated tasks from your schedule.");
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import javafx.beans.property.ListProperty;
|
|||||||
import javafx.beans.property.SimpleListProperty;
|
import javafx.beans.property.SimpleListProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.ListCell;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.control.ListView;
|
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -27,6 +27,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class MyScheduleController {
|
public class MyScheduleController {
|
||||||
private static final Logger LOG = Logger.getLogger(MyScheduleController.class.getName());
|
private static final Logger LOG = Logger.getLogger(MyScheduleController.class.getName());
|
||||||
|
private final ListProperty<List<Task>> taskListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
|
|
||||||
private Crop selectedCrop = null;
|
private Crop selectedCrop = null;
|
||||||
|
|
||||||
@@ -37,49 +38,8 @@ public class MyScheduleController {
|
|||||||
@Inject
|
@Inject
|
||||||
private PlantList plantList;
|
private PlantList plantList;
|
||||||
|
|
||||||
private final ListProperty<Crop> cropListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label day1_label;
|
private ListView<List<Task>> week_listView;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Pane day1_pane;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label day2_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Pane day2_pane;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label day3_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Pane day3_pane;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label day4_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Pane day4_pane;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label day5_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Pane day5_pane;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label day6_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Pane day6_pane;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label day7_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Pane day7_pane;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label information_label;
|
private Label information_label;
|
||||||
@@ -90,17 +50,11 @@ public class MyScheduleController {
|
|||||||
@AfterInject
|
@AfterInject
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void init() {
|
public void init() {
|
||||||
List<Crop> cropList;
|
setCellFactoryCropListView();
|
||||||
try {
|
setCellFactoryTaskListView();
|
||||||
cropList = garden.getCrops();
|
scheduledPlants_listview.itemsProperty().bind(garden.getPlantedCrops());
|
||||||
cropListProperty.addAll(cropList);
|
week_listView.itemsProperty().bind(taskListProperty);
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
setCellFactoryListView();
|
|
||||||
scheduledPlants_listview.itemsProperty().bind(cropListProperty);
|
|
||||||
lookForSelectedListEntries();
|
lookForSelectedListEntries();
|
||||||
setDayLabels();
|
|
||||||
information_label.setText("");
|
information_label.setText("");
|
||||||
try {
|
try {
|
||||||
loadTaskList();
|
loadTaskList();
|
||||||
@@ -120,18 +74,7 @@ public class MyScheduleController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDayLabels() {
|
private void setCellFactoryCropListView() {
|
||||||
LocalDate today = LocalDate.now();
|
|
||||||
day1_label.setText(today.getDayOfWeek().toString());
|
|
||||||
day2_label.setText(today.plusDays(1).getDayOfWeek().toString());
|
|
||||||
day3_label.setText(today.plusDays(2).getDayOfWeek().toString());
|
|
||||||
day4_label.setText(today.plusDays(3).getDayOfWeek().toString());
|
|
||||||
day5_label.setText(today.plusDays(4).getDayOfWeek().toString());
|
|
||||||
day6_label.setText(today.plusDays(5).getDayOfWeek().toString());
|
|
||||||
day7_label.setText(today.plusDays(6).getDayOfWeek().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCellFactoryListView() {
|
|
||||||
scheduledPlants_listview.setCellFactory(param -> new ListCell<>() {
|
scheduledPlants_listview.setCellFactory(param -> new ListCell<>() {
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(Crop crop, boolean empty) {
|
protected void updateItem(Crop crop, boolean empty) {
|
||||||
@@ -153,6 +96,23 @@ public class MyScheduleController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setCellFactoryTaskListView() {
|
||||||
|
week_listView.setCellFactory(param -> new ListCell<>() {
|
||||||
|
@Override
|
||||||
|
protected void updateItem(List<Task> taskList, boolean empty) {
|
||||||
|
super.updateItem(taskList, empty);
|
||||||
|
|
||||||
|
if (empty || taskList == null) {
|
||||||
|
setGraphic(null);
|
||||||
|
setText(null);
|
||||||
|
} else {
|
||||||
|
setText("");
|
||||||
|
setGraphic(weekTaskVBox(taskList, this.getIndex()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void loadTaskList() throws IOException {
|
private void loadTaskList() throws IOException {
|
||||||
List<List<Task>> taskLists;
|
List<List<Task>> taskLists;
|
||||||
if (selectedCrop != null) {
|
if (selectedCrop != null) {
|
||||||
@@ -160,25 +120,66 @@ public class MyScheduleController {
|
|||||||
} else {
|
} else {
|
||||||
taskLists = gardenSchedule.getTasksUpcomingWeek();
|
taskLists = gardenSchedule.getTasksUpcomingWeek();
|
||||||
}
|
}
|
||||||
if (!taskLists.isEmpty()) {
|
taskListProperty.clear();
|
||||||
viewTaskListOfDay(day1_pane, taskLists.get(0));
|
taskListProperty.addAll(taskLists);
|
||||||
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) {
|
private VBox weekTaskVBox(List<Task> tasks, int dayIndex) {
|
||||||
//ToDo update pane with task list
|
VBox vBox = new VBox(10);
|
||||||
VBox vBox = new VBox();
|
LocalDate today = LocalDate.now();
|
||||||
|
Label weekDay = new Label(today.plusDays(dayIndex).getDayOfWeek().toString());
|
||||||
|
weekDay.setStyle("-fx-font-weight: bold; -fx-underline: true");
|
||||||
|
vBox.getChildren().add(weekDay);
|
||||||
for (Task task : tasks) {
|
for (Task task : tasks) {
|
||||||
Label label = new Label(task.getDescription());
|
HBox hBox = new HBox(10);
|
||||||
vBox.getChildren().add(label);
|
Label taskName = new Label(task.getName() + ":");
|
||||||
|
taskName.setStyle("-fx-font-weight: bold");
|
||||||
|
taskName.setMinWidth(100);
|
||||||
|
taskName.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
||||||
|
hBox.getChildren().addAll(taskName);
|
||||||
|
|
||||||
|
HBox hBoxDescription = new HBox();
|
||||||
|
Label taskDescription = new Label(task.getDescription());
|
||||||
|
taskDescription.setWrapText(true);
|
||||||
|
taskDescription.setMaxSize(600, Double.MAX_VALUE);
|
||||||
|
Pane puffer = new Pane();
|
||||||
|
HBox.setHgrow(puffer, Priority.ALWAYS);
|
||||||
|
CheckBox checkBox = new CheckBox("Task completed?");
|
||||||
|
checkBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
if (newValue) {
|
||||||
|
showConfirmation(task, checkBox);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
HBox.setHgrow(checkBox, Priority.NEVER);
|
||||||
|
hBoxDescription.getChildren().addAll(taskDescription, puffer, checkBox);
|
||||||
|
vBox.getChildren().addAll(hBox, hBoxDescription);
|
||||||
}
|
}
|
||||||
pane.getChildren().add(vBox);
|
return vBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alert to confirm that task has been completed.
|
||||||
|
* @param task {@link Task} which is selected
|
||||||
|
*/
|
||||||
|
private void showConfirmation(Task task, CheckBox checkBox) {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||||
|
alert.setTitle("Task Completed?");
|
||||||
|
alert.setHeaderText("Are you sure you have completed this task?");
|
||||||
|
alert.setContentText("Confirming that you have completed the task will remove it from the schedule.");
|
||||||
|
|
||||||
|
alert.showAndWait()
|
||||||
|
.ifPresent(buttonType -> {
|
||||||
|
if (buttonType == ButtonType.OK) {
|
||||||
|
task.done();
|
||||||
|
try {
|
||||||
|
loadTaskList();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
checkBox.setSelected(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import javafx.scene.image.Image;
|
|||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -42,7 +41,6 @@ public class PlantsController {
|
|||||||
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;
|
||||||
|
|
||||||
// TODO: move to model
|
|
||||||
private final ListProperty<Plant> plantListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
private final ListProperty<Plant> plantListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@@ -74,7 +72,6 @@ public class PlantsController {
|
|||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void selectSowDate() throws IOException {
|
void selectSowDate() throws IOException {
|
||||||
Stage stage = new Stage();
|
|
||||||
Dialog<LocalDate> dateSelection = new Dialog<>();
|
Dialog<LocalDate> dateSelection = new Dialog<>();
|
||||||
dateSelection.setTitle("Select Date");
|
dateSelection.setTitle("Select Date");
|
||||||
dateSelection.setHeaderText(String.format("Select Harvest/Sow Date for %s:", selectedPlant.name()));
|
dateSelection.setHeaderText(String.format("Select Harvest/Sow Date for %s:", selectedPlant.name()));
|
||||||
@@ -85,22 +82,21 @@ public class PlantsController {
|
|||||||
ButtonType sowButton = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
ButtonType sowButton = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
||||||
dialogPane.getButtonTypes().addAll(sowButton, ButtonType.CANCEL);
|
dialogPane.getButtonTypes().addAll(sowButton, ButtonType.CANCEL);
|
||||||
|
|
||||||
if (appLoader.loadSceneToStage("SelectSowDay.fxml", stage) instanceof SelectSowDayController controller) {
|
if (appLoader.loadPaneToDialog("SelectSowDay.fxml", dialogPane) instanceof SelectSowDayController controller) {
|
||||||
controller.initSaveButton((Button) dialogPane.lookupButton(sowButton));
|
controller.initSaveButton((Button) dialogPane.lookupButton(sowButton));
|
||||||
controller.setSelectedPlant(selectedPlant);
|
controller.setSelectedPlant(selectedPlant);
|
||||||
dateSelection.setResultConverter(button -> button.equals(sowButton) ? controller.retrieveResult() : null);
|
dateSelection.setResultConverter(button -> button.equals(sowButton) ? controller.retrieveResult() : null);
|
||||||
}
|
|
||||||
dialogPane.setContent(stage.getScene().getRoot());
|
|
||||||
|
|
||||||
dateSelection.showAndWait()
|
dateSelection.showAndWait()
|
||||||
.ifPresent(date -> {
|
.ifPresent(date -> {
|
||||||
try {
|
try {
|
||||||
garden.plantAsCrop(selectedPlant, date);
|
garden.plantAsCrop(selectedPlant, date);
|
||||||
} catch (IOException | HardinessZoneNotSetException | PlantNotFoundException e) {
|
} catch (IOException | HardinessZoneNotSetException | PlantNotFoundException e) {
|
||||||
LOG.log(Level.SEVERE, "Couldn't save Crop", e);
|
LOG.log(Level.SEVERE, "Couldn't save Crop", e);
|
||||||
}
|
}
|
||||||
plantsRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "MyGarden.fxml"));
|
plantsRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "MyGarden.fxml"));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -237,11 +233,11 @@ public class PlantsController {
|
|||||||
RadioButton radioButton = new RadioButton(season.getName());
|
RadioButton radioButton = new RadioButton(season.getName());
|
||||||
radioButton.setToggleGroup(seasonGroup);
|
radioButton.setToggleGroup(seasonGroup);
|
||||||
radioButton.setPadding(new Insets(0, 0, 10, 0));
|
radioButton.setPadding(new Insets(0, 0, 10, 0));
|
||||||
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((observable, oldValue, newValue) -> {
|
||||||
if (season.equals(Seasons.AllSEASONS)) {
|
if (season.equals(Seasons.ALLSEASONS)) {
|
||||||
fillPlantListWithHardinessZone();
|
fillPlantListWithHardinessZone();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -272,7 +268,7 @@ public class PlantsController {
|
|||||||
list_plants.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
list_plants.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
selectedPlant = newValue;
|
selectedPlant = newValue;
|
||||||
description_plant.setText(selectedPlant.description());
|
description_plant.setText(getPlantDescription());
|
||||||
selectSowDay_button.setDisable(false);
|
selectSowDay_button.setDisable(false);
|
||||||
Image img1;
|
Image img1;
|
||||||
if (selectedPlant.image() != null) {
|
if (selectedPlant.image() != null) {
|
||||||
@@ -291,6 +287,20 @@ public class PlantsController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates {@link String} of the plant information.
|
||||||
|
* @return return {@link Plant} description
|
||||||
|
*/
|
||||||
|
private String getPlantDescription() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Name: ").append(selectedPlant.name())
|
||||||
|
.append("\nDescription:\n").append(selectedPlant.description())
|
||||||
|
.append("\nLight Level: ").append(selectedPlant.light())
|
||||||
|
.append("\nSoil: ").append(selectedPlant.soil())
|
||||||
|
.append("\nSpacing: ").append(selectedPlant.spacing());
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clears the ListView of entries
|
* clears the ListView of entries
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import javafx.scene.control.*;
|
|||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SelectSowDayController {
|
public class SelectSowDayController {
|
||||||
private Plant selectedPlant;
|
private Plant selectedPlant;
|
||||||
@@ -17,12 +16,20 @@ public class SelectSowDayController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private RadioButton harvest_radio;
|
private RadioButton harvest_radio;
|
||||||
|
@FXML
|
||||||
|
private RadioButton sow_radio;
|
||||||
|
@FXML
|
||||||
|
public ToggleGroup phase_group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if sow date radio button was selected return sow date
|
||||||
|
* if sow date was not selected get sow from harvest day and return sow date
|
||||||
|
* @return {@link LocalDate} of the sow date
|
||||||
|
*/
|
||||||
public LocalDate retrieveResult() {
|
public LocalDate retrieveResult() {
|
||||||
LocalDate sowDate = datepicker.getValue();
|
LocalDate sowDate = datepicker.getValue();
|
||||||
if (harvest_radio.isSelected()) {
|
if (harvest_radio.isSelected()) {
|
||||||
//ToDo method to get current lifecycle group in plant
|
sowDate = selectedPlant.sowDateFromHarvestDate(sowDate);
|
||||||
sowDate = selectedPlant.sowDateFromHarvestDate(datepicker.getValue(), 0);
|
|
||||||
}
|
}
|
||||||
return sowDate;
|
return sowDate;
|
||||||
}
|
}
|
||||||
@@ -46,8 +53,15 @@ public class SelectSowDayController {
|
|||||||
Callback<DatePicker, DateCell> dayCellFactory = getDayCellFactory();
|
Callback<DatePicker, DateCell> dayCellFactory = getDayCellFactory();
|
||||||
datepicker.setDayCellFactory(dayCellFactory);
|
datepicker.setDayCellFactory(dayCellFactory);
|
||||||
datepicker.setEditable(false);
|
datepicker.setEditable(false);
|
||||||
|
|
||||||
|
sow_radio.setUserData(GrowthPhaseType.SOW);
|
||||||
|
harvest_radio.setUserData(GrowthPhaseType.HARVEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable save button when date picker is empty
|
||||||
|
* @param saveButton {@link Button} to be disabled
|
||||||
|
*/
|
||||||
public void initSaveButton(Button saveButton) {
|
public void initSaveButton(Button saveButton) {
|
||||||
saveButton.disableProperty().bind(datepicker.valueProperty().isNull());
|
saveButton.disableProperty().bind(datepicker.valueProperty().isNull());
|
||||||
}
|
}
|
||||||
@@ -61,35 +75,28 @@ public class SelectSowDayController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* date picker disable/enable dates according to selected plant: sow or harvest day
|
* date picker disable/enable dates according to selected plant: sow or harvest day
|
||||||
|
*
|
||||||
* @return cellFactory of datePicker
|
* @return cellFactory of datePicker
|
||||||
*/
|
*/
|
||||||
private Callback<DatePicker, DateCell> getDayCellFactory() {
|
private Callback<DatePicker, DateCell> getDayCellFactory() {
|
||||||
|
|
||||||
return (datePicker) -> new DateCell() {
|
return (datePicker) -> new DateCell() {
|
||||||
|
private final LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateItem(LocalDate item, boolean empty) {
|
public void updateItem(LocalDate item, boolean empty) {
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
setDisable(true);
|
setDisable(true);
|
||||||
setStyle("-fx-background-color: #ffc0cb;");
|
setStyle("-fx-background-color: #ffc0cb;");
|
||||||
List<LocalDate> dates;
|
|
||||||
LocalDate today = LocalDate.now();
|
if (item.compareTo(today) > 0 && (!harvest_radio.isSelected() || selectedPlant.sowDateFromHarvestDate(item).compareTo(today) >= 0)) {
|
||||||
if (harvest_radio.isSelected()) {
|
GrowthPhaseType selectedPhase = (GrowthPhaseType) phase_group.getSelectedToggle().getUserData();
|
||||||
dates = selectedPlant.getDateListOfGrowthPhase(GrowthPhaseType.HARVEST);
|
|
||||||
} else {
|
if (selectedPlant.isDateInPhase(item, selectedPhase)) {
|
||||||
dates = selectedPlant.getDateListOfGrowthPhase(GrowthPhaseType.SOW);
|
|
||||||
}
|
|
||||||
for (LocalDate date : dates) {
|
|
||||||
if (item.getMonth() == date.getMonth()
|
|
||||||
&& item.getDayOfMonth() == date.getDayOfMonth()
|
|
||||||
&& item.compareTo(today) > 0) {
|
|
||||||
setDisable(false);
|
setDisable(false);
|
||||||
setStyle("-fx-background-color: #32CD32;");
|
setStyle("-fx-background-color: #32CD32;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((harvest_radio.isSelected() && selectedPlant.sowDateFromHarvestDate(item, 0).compareTo(today) < 0)) {
|
|
||||||
setDisable(true);
|
|
||||||
setStyle("-fx-background-color: #ffc0cb;");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A;
|
private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A;
|
||||||
private static Settings instance;
|
private static Settings instance;
|
||||||
|
private final BooleanProperty showTutorial = new SimpleBooleanProperty(false);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
instance = new Settings();
|
instance = new Settings();
|
||||||
@@ -23,4 +26,16 @@ public class Settings {
|
|||||||
public void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
|
public void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
|
||||||
this.currentHardinessZone = currentHardinessZone;
|
this.currentHardinessZone = currentHardinessZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowTutorial (boolean showTutorial) {
|
||||||
|
this.showTutorial.setValue(showTutorial);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanProperty getShowTutorialProperty() {
|
||||||
|
return this.showTutorial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getShowTutorial() {
|
||||||
|
return this.showTutorial.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.control.CheckBox;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class SettingsController implements Initializable {
|
||||||
|
Settings settings = Settings.getInstance();
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ComboBox<HardinessZone> selectHardinessZone_comboBox;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox showTutorial_checkBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save selected values to {@link Settings}
|
||||||
|
*/
|
||||||
|
public void saveSettings() {
|
||||||
|
settings.setShowTutorial(showTutorial_checkBox.isSelected());
|
||||||
|
settings.setCurrentHardinessZone(selectHardinessZone_comboBox.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save default values form {@link Settings}
|
||||||
|
* @param location location
|
||||||
|
* @param resources resources
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
showTutorial_checkBox.setSelected(settings.getShowTutorial());
|
||||||
|
selectHardinessZone_comboBox.getItems().addAll(HardinessZone.values());
|
||||||
|
selectHardinessZone_comboBox.setValue(settings.getCurrentHardinessZone());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
|
||||||
|
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.PlantList;
|
||||||
|
import ch.zhaw.gartenverwaltung.models.Garden;
|
||||||
|
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.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.control.*;
|
||||||
|
import javafx.util.Callback;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class TaskFormularController implements Initializable {
|
||||||
|
private Crop crop;
|
||||||
|
private Plant plant;
|
||||||
|
private Task task = null;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GardenSchedule gardenSchedule;
|
||||||
|
@Inject
|
||||||
|
private Garden garden;
|
||||||
|
@Inject
|
||||||
|
private PlantList plantList;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextArea description_area;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private DatePicker end_datePicker;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField interval_field;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private DatePicker start_datePicker;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField taskName_field;
|
||||||
|
|
||||||
|
@AfterInject
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
|
||||||
|
public Task returnResult(Crop crop) {
|
||||||
|
int interval = 0;
|
||||||
|
if (!(interval_field.getText().isEmpty() || interval_field.getText().equals(""))) {
|
||||||
|
interval = Integer.parseInt(interval_field.getText());
|
||||||
|
}
|
||||||
|
Task task = new Task(taskName_field.getText(), description_area.getText(),
|
||||||
|
start_datePicker.getValue(), end_datePicker.getValue(),
|
||||||
|
interval, crop.getCropId().get());
|
||||||
|
if (this.task != null) return this.task.updateTask(task);
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCorp(Crop crop) throws HardinessZoneNotSetException, IOException {
|
||||||
|
this.crop = crop;
|
||||||
|
this.plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskValue(Task task) {
|
||||||
|
this.task = task;
|
||||||
|
taskName_field.setText(task.getName());
|
||||||
|
description_area.setText(task.getDescription());
|
||||||
|
start_datePicker.setValue(task.getStartDate());
|
||||||
|
end_datePicker.setValue(task.getEndDate().orElse(null));
|
||||||
|
if(task.getInterval().orElse(null)!=null) {
|
||||||
|
interval_field.setText(task.getInterval().get().toString());
|
||||||
|
} else {
|
||||||
|
interval_field.setText(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Callback<DatePicker, DateCell> getDayCellFactoryStartDate() {
|
||||||
|
|
||||||
|
return (datePicker) -> new DateCell() {
|
||||||
|
private final LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateItem(LocalDate item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
setDisable(true);
|
||||||
|
setStyle("-fx-background-color: #ffc0cb;");
|
||||||
|
|
||||||
|
if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0 && item.compareTo(crop.getStartDate().plusDays(plant.timeToHarvest(0))) < 0) {
|
||||||
|
setDisable(false);
|
||||||
|
setStyle("-fx-background-color: #32CD32;");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end_datePicker.getValue() != null && item.compareTo(end_datePicker.getValue()) > 0) {
|
||||||
|
setDisable(true);
|
||||||
|
setStyle("-fx-background-color: #ffc0cb;");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Callback<DatePicker, DateCell> getDayCellFactoryEndDate() {
|
||||||
|
|
||||||
|
return (datePicker) -> new DateCell() {
|
||||||
|
private final LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateItem(LocalDate item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
setDisable(true);
|
||||||
|
setStyle("-fx-background-color: #ffc0cb;");
|
||||||
|
|
||||||
|
if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0 && item.compareTo(crop.getStartDate().plusDays(plant.timeToHarvest(0))) < 0) {
|
||||||
|
setDisable(false);
|
||||||
|
setStyle("-fx-background-color: #32CD32;");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start_datePicker.getValue() != null && item.compareTo(start_datePicker.getValue()) < 0) {
|
||||||
|
setDisable(true);
|
||||||
|
setStyle("-fx-background-color: #ffc0cb;");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initSaveButton(Button button) {
|
||||||
|
interval_field.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
if (!newValue.matches("\\d*")) {
|
||||||
|
interval_field.setText(newValue.replaceAll("[^\\d]", ""));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
button.disableProperty().bind(start_datePicker.valueProperty().isNull()
|
||||||
|
.or(taskName_field.textProperty().isEmpty())
|
||||||
|
.or(description_area.textProperty().isEmpty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
start_datePicker.setDayCellFactory(getDayCellFactoryStartDate());
|
||||||
|
start_datePicker.setEditable(false);
|
||||||
|
|
||||||
|
end_datePicker.setDayCellFactory(getDayCellFactoryEndDate());
|
||||||
|
end_datePicker.setEditable(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
|
||||||
|
public class TextFieldFormularController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label description_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField text_area;
|
||||||
|
|
||||||
|
|
||||||
|
public void setDescription_label(String string) {
|
||||||
|
description_label.setText(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValueTextArea(String string) {
|
||||||
|
text_area.setText(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return text_area.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initSaveButton(Button button) {
|
||||||
|
text_area.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
if (newValue.matches("\\d*\\.?\\d*")) {
|
||||||
|
text_area.setText(newValue);
|
||||||
|
} else {
|
||||||
|
text_area.setText(oldValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
button.disableProperty().bind(text_area.textProperty().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class TutorialController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button previousPageButton;
|
||||||
|
@FXML
|
||||||
|
public Button nextPageButton;
|
||||||
|
@FXML
|
||||||
|
public StackPane tourPages;
|
||||||
|
public ImageView imgAddNewPlant;
|
||||||
|
public ImageView imgTaskList;
|
||||||
|
public ImageView imgSelectDate;
|
||||||
|
|
||||||
|
private int page = 0;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void initialize() {
|
||||||
|
switchViews();
|
||||||
|
setButtonAbilities();
|
||||||
|
|
||||||
|
Image placeholder = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
||||||
|
imgAddNewPlant.setImage(placeholder);
|
||||||
|
imgSelectDate.setImage(placeholder);
|
||||||
|
imgTaskList.setImage(placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void viewNextPage() {
|
||||||
|
page++;
|
||||||
|
switchViews();
|
||||||
|
setButtonAbilities();
|
||||||
|
}
|
||||||
|
public void viewPreviousPage() {
|
||||||
|
page--;
|
||||||
|
switchViews();
|
||||||
|
setButtonAbilities();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setButtonAbilities() {
|
||||||
|
previousPageButton.setDisable(page <= 0);
|
||||||
|
nextPageButton.setDisable(page >= tourPages.getChildren().size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void switchViews() {
|
||||||
|
tourPages.getChildren().forEach(node -> node.setOpacity(0));
|
||||||
|
tourPages.getChildren().get(page).setOpacity(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeTutorial() {
|
||||||
|
Stage root = (Stage) tourPages.getScene().getWindow();
|
||||||
|
root.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotates a method to be executed after all dependencies annotates with {@link Inject}
|
* Annotates a method to be executed after all dependencies annotated with {@link Inject}
|
||||||
* have been injected.
|
* have been injected.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import ch.zhaw.gartenverwaltung.models.GardenSchedule;
|
|||||||
import ch.zhaw.gartenverwaltung.models.PlantListModel;
|
import ch.zhaw.gartenverwaltung.models.PlantListModel;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.DialogPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
@@ -22,6 +23,10 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class responsible for bootstrapping the application wide dependencies
|
||||||
|
* and injecting them into JavaFX Controllers.
|
||||||
|
*/
|
||||||
public class AppLoader {
|
public class AppLoader {
|
||||||
/**
|
/**
|
||||||
* Caching the panes
|
* Caching the panes
|
||||||
@@ -31,17 +36,24 @@ public class AppLoader {
|
|||||||
/**
|
/**
|
||||||
* Application-wide dependencies
|
* Application-wide dependencies
|
||||||
*/
|
*/
|
||||||
private final PlantList plantList = new JsonPlantList();
|
private final Map<String, Object> dependencies = new HashMap<>();
|
||||||
private final CropList cropList = new JsonCropList();
|
|
||||||
private final TaskList taskList = new JsonTaskList();
|
|
||||||
|
|
||||||
private final GardenSchedule gardenSchedule = new GardenSchedule(taskList, plantList);
|
|
||||||
private final Garden garden = new Garden(gardenSchedule, cropList);
|
|
||||||
|
|
||||||
|
|
||||||
public AppLoader() throws IOException {
|
public AppLoader() throws IOException {
|
||||||
}
|
PlantList plantList = new JsonPlantList();
|
||||||
|
CropList cropList = new JsonCropList();
|
||||||
|
TaskList taskList = new JsonTaskList();
|
||||||
|
GardenSchedule gardenSchedule = new GardenSchedule(taskList, plantList);
|
||||||
|
|
||||||
|
dependencies.put(PlantList.class.getSimpleName(), plantList);
|
||||||
|
dependencies.put(CropList.class.getSimpleName(), cropList);
|
||||||
|
dependencies.put(TaskList.class.getSimpleName(), taskList);
|
||||||
|
|
||||||
|
dependencies.put(PlantListModel.class.getSimpleName(), new PlantListModel(plantList));
|
||||||
|
|
||||||
|
dependencies.put(GardenSchedule.class.getSimpleName(), gardenSchedule);
|
||||||
|
dependencies.put(Garden.class.getSimpleName(), new Garden(gardenSchedule, cropList));
|
||||||
|
dependencies.put(AppLoader.class.getSimpleName(), this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads and returns a {@link Pane} (cached).
|
* Loads and returns a {@link Pane} (cached).
|
||||||
@@ -72,7 +84,28 @@ public class AppLoader {
|
|||||||
public Object loadSceneToStage(String fxmlFile, Stage appendee) throws IOException {
|
public Object loadSceneToStage(String fxmlFile, Stage appendee) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(HelloApplication.class.getResource(fxmlFile)));
|
FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(HelloApplication.class.getResource(fxmlFile)));
|
||||||
Pane root = loader.load();
|
Pane root = loader.load();
|
||||||
appendee.setScene(new Scene(root));
|
Scene scene = new Scene(root);
|
||||||
|
String css = Objects.requireNonNull(this.getClass().getResource("styles.css")).toExternalForm();
|
||||||
|
appendee.setScene(scene);
|
||||||
|
scene.getStylesheets().add(css);
|
||||||
|
Object controller = loader.getController();
|
||||||
|
annotationInject(controller);
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the given fxml-file from resources (no caching) and appendeds it's
|
||||||
|
* contents to the given {@link DialogPane}.
|
||||||
|
* Performs dependency-injection.
|
||||||
|
*
|
||||||
|
* @param fxmlFile The file name to be loaded
|
||||||
|
* @param appendee The {@link DialogPane} to which the FXML contents are to be appended.
|
||||||
|
* @return The controller of the loaded scene.
|
||||||
|
* @throws IOException if the file could not be loaded
|
||||||
|
*/
|
||||||
|
public Object loadPaneToDialog(String fxmlFile, DialogPane appendee) throws IOException {
|
||||||
|
FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(HelloApplication.class.getResource(fxmlFile)));
|
||||||
|
appendee.setContent(loader.load());
|
||||||
Object controller = loader.getController();
|
Object controller = loader.getController();
|
||||||
annotationInject(controller);
|
annotationInject(controller);
|
||||||
return controller;
|
return controller;
|
||||||
@@ -113,26 +146,18 @@ public class AppLoader {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Arrays.stream(controller.getClass().getMethods())
|
Arrays.stream(controller.getClass().getMethods())
|
||||||
.filter(method -> method.isAnnotationPresent(AfterInject.class))
|
.filter(method -> method.isAnnotationPresent(AfterInject.class) && method.getParameterCount() == 0)
|
||||||
.forEach(afterInjectMethod -> {
|
.forEach(afterInjectMethod -> {
|
||||||
if (afterInjectMethod.getParameterCount() == 0) {
|
try {
|
||||||
try {
|
afterInjectMethod.invoke(controller);
|
||||||
afterInjectMethod.invoke(controller);
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
// TODO: Log
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getAppDependency(Class<?> type) {
|
private Object getAppDependency(Class<?> type) {
|
||||||
return switch (type.getSimpleName()) {
|
return dependencies.get(type.getSimpleName());
|
||||||
case "Garden" -> garden;
|
|
||||||
case "PlantList" -> plantList;
|
|
||||||
case "PlantListModel" -> new PlantListModel(plantList);
|
|
||||||
case "GardenSchedule" -> gardenSchedule;
|
|
||||||
case "AppLoader" -> this;
|
|
||||||
default -> null;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,20 @@ package ch.zhaw.gartenverwaltung.bootstrap;
|
|||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.event.EventType;
|
import javafx.event.EventType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an event that should lead to a view being changed.
|
||||||
|
*/
|
||||||
public class ChangeViewEvent extends Event {
|
public class ChangeViewEvent extends Event {
|
||||||
private final String view;
|
private final String view;
|
||||||
|
|
||||||
public static final EventType<ChangeViewEvent> CHANGE_MAIN_VIEW = new EventType<>("CHANGE_MAIN_VIEW");
|
public static final EventType<ChangeViewEvent> CHANGE_MAIN_VIEW = new EventType<>("CHANGE_MAIN_VIEW");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an Event that should lead to the main view being changed.
|
||||||
|
*
|
||||||
|
* @param eventType The {@link EventType<ChangeViewEvent>} specifying which view should be changed.
|
||||||
|
* @param view The filename of the View to be changed to
|
||||||
|
*/
|
||||||
public ChangeViewEvent(EventType<? extends Event> eventType, String view) {
|
public ChangeViewEvent(EventType<? extends Event> eventType, String view) {
|
||||||
super(eventType);
|
super(eventType);
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotates a Field to be injected from the application-dependencies
|
* Annotates a Field to be injected from the application-dependencies.
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a List of {@link Crop}s.
|
||||||
|
* The interface specifies the operations to add/update and remove entries.
|
||||||
|
*/
|
||||||
public interface CropList {
|
public interface CropList {
|
||||||
/**
|
/**
|
||||||
* Yields a list of all {@link Crop}s in the database.
|
* Yields a list of all {@link Crop}s in the database.
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
package ch.zhaw.gartenverwaltung.io;
|
package ch.zhaw.gartenverwaltung.io;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an sequential ID starting from the given initial Value.
|
||||||
|
*/
|
||||||
public class IdProvider {
|
public class IdProvider {
|
||||||
private long currentId;
|
private long currentId;
|
||||||
public IdProvider(long initialValue) {
|
public IdProvider(long initialValue) {
|
||||||
currentId = initialValue;
|
currentId = initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Yields the next ID in the sequence.
|
||||||
|
* @return The next ID
|
||||||
|
*/
|
||||||
public long incrementAndGet() {
|
public long incrementAndGet() {
|
||||||
return ++currentId;
|
return ++currentId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the {@link CropList} interface for reading and writing {@link Crop} objects
|
||||||
|
* from and to a local JSON file.
|
||||||
|
* The reads are cached to minimize file-io operations.
|
||||||
|
*/
|
||||||
public class JsonCropList implements CropList {
|
public class JsonCropList implements CropList {
|
||||||
private final URL dataSource;
|
private final URL dataSource;
|
||||||
|
|
||||||
@@ -40,7 +45,7 @@ public class JsonCropList implements CropList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor. Uses a file from the app resources.
|
||||||
*/
|
*/
|
||||||
public JsonCropList() {
|
public JsonCropList() {
|
||||||
this.dataSource = getClass().getResource("user-crops.json");
|
this.dataSource = getClass().getResource("user-crops.json");
|
||||||
@@ -53,6 +58,7 @@ public class JsonCropList implements CropList {
|
|||||||
public JsonCropList(URL dataSource) {
|
public JsonCropList(URL dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the {@link PlantList} interface for loading {@link Plant} objects
|
* Implements the {@link PlantList} interface for reading {@link Plant} objects
|
||||||
* from a JSON file.
|
* from a local JSON file.
|
||||||
* The reads are cached to minimize file-io operations.
|
* The reads are cached to minimize file-io operations.
|
||||||
*/
|
*/
|
||||||
public class JsonPlantList implements PlantList {
|
public class JsonPlantList implements PlantList {
|
||||||
private final URL dataSource = getClass().getResource("plantdb.json");
|
private final URL dataSource;
|
||||||
|
|
||||||
private HardinessZone currentZone;
|
private HardinessZone currentZone;
|
||||||
private Map<Long, Plant> plantMap = Collections.emptyMap();
|
private Map<Long, Plant> plantMap = Collections.emptyMap();
|
||||||
@@ -44,6 +44,21 @@ public class JsonPlantList implements PlantList {
|
|||||||
imageModule.addDeserializer(Image.class, new PlantImageDeserializer());
|
imageModule.addDeserializer(Image.class, new PlantImageDeserializer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor. Uses a file from the app resources.
|
||||||
|
*/
|
||||||
|
public JsonPlantList() {
|
||||||
|
this.dataSource = getClass().getResource("plantdb.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to use a specified {@link URL} as a {@link #dataSource}
|
||||||
|
* @param dataSource A {@link URL} to the file to be used as a data source
|
||||||
|
*/
|
||||||
|
public JsonPlantList(URL dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no data is currently loaded, or the specified zone differs
|
* If no data is currently loaded, or the specified zone differs
|
||||||
* from the {@link #currentZone}, data is loaded from {@link #dataSource}.
|
* from the {@link #currentZone}, data is loaded from {@link #dataSource}.
|
||||||
@@ -60,7 +75,7 @@ public class JsonPlantList implements PlantList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PlantList#getPlantById(long)
|
* @see PlantList#getPlantById(HardinessZone, long)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Optional<Plant> getPlantById(HardinessZone zone, long id) throws HardinessZoneNotSetException, IOException {
|
public Optional<Plant> getPlantById(HardinessZone zone, long id) throws HardinessZoneNotSetException, IOException {
|
||||||
|
|||||||
@@ -13,22 +13,24 @@ import java.net.URISyntaxException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the {@link TaskList} interface for loading and writing {@link Task} objects
|
* Implements the {@link TaskList} interface for reading and writing {@link Task} objects
|
||||||
* from and to a JSON file.
|
* from and to a local JSON file.
|
||||||
* The reads are cached to minimize file-io operations.
|
* The reads are cached to minimize file-io operations.
|
||||||
*/
|
*/
|
||||||
public class JsonTaskList implements TaskList {
|
public class JsonTaskList implements TaskList {
|
||||||
IdProvider idProvider;
|
IdProvider idProvider;
|
||||||
private final URL dataSource = getClass().getResource("taskdb.json");
|
private final URL dataSource;
|
||||||
private final static String INVALID_DATASOURCE_MSG = "Invalid datasource specified!";
|
private final static String INVALID_DATASOURCE_MSG = "Invalid datasource specified!";
|
||||||
|
|
||||||
private Map<Long, Task> taskMap = Collections.emptyMap();
|
private Map<Long, Task> taskMap = Collections.emptyMap();
|
||||||
|
private final List<TaskListObserver> subscribers = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creating constant objects required to deserialize the {@link LocalDate} classes
|
* Creating constant objects required to deserialize the {@link LocalDate} classes
|
||||||
@@ -43,6 +45,21 @@ public class JsonTaskList implements TaskList {
|
|||||||
timeModule.addSerializer(LocalDate.class, dateSerializer);
|
timeModule.addSerializer(LocalDate.class, dateSerializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor. Uses a file from the app resources.
|
||||||
|
*/
|
||||||
|
public JsonTaskList() {
|
||||||
|
this.dataSource = getClass().getResource("taskdb.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to use a specified {@link URL} as a {@link #dataSource}
|
||||||
|
* @param dataSource A {@link URL} to the file to be used as a data source
|
||||||
|
*/
|
||||||
|
public JsonTaskList(URL dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no data is currently loaded, data is loaded from {@link #dataSource}.
|
* If no data is currently loaded, data is loaded from {@link #dataSource}.
|
||||||
* In any case, the values of {@link #taskMap} are returned.
|
* In any case, the values of {@link #taskMap} are returned.
|
||||||
@@ -79,7 +96,9 @@ public class JsonTaskList implements TaskList {
|
|||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
taskMap.values().removeIf(task -> task.getCropId() == cropId);
|
taskMap.entrySet().removeIf(entry -> entry.getValue().getCropId() == cropId);
|
||||||
|
writeTaskListToFile();
|
||||||
|
notifySubscribers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,10 +115,11 @@ public class JsonTaskList implements TaskList {
|
|||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
if(task.getId() == 0) {
|
long id = task.getId().orElse(idProvider.incrementAndGet());
|
||||||
task.withId(idProvider.incrementAndGet());
|
|
||||||
}
|
taskMap.put(id, task.withId(id));
|
||||||
writeTaskListToFile();
|
writeTaskListToFile();
|
||||||
|
notifySubscribers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,10 +134,30 @@ public class JsonTaskList implements TaskList {
|
|||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
if(taskMap.containsKey(task.getId())){
|
Long taskId = task.getId().orElseThrow(IOException::new);
|
||||||
taskMap.remove(task.getId());
|
if(taskMap.containsKey(taskId)){
|
||||||
|
taskMap.remove(taskId);
|
||||||
writeTaskListToFile();
|
writeTaskListToFile();
|
||||||
}
|
}
|
||||||
|
notifySubscribers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @param observer The change handler
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void subscribe(TaskListObserver observer) {
|
||||||
|
subscribers.add(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the change handler method on all registered observers.
|
||||||
|
*/
|
||||||
|
private void notifySubscribers() {
|
||||||
|
for (TaskListObserver subscriber : subscribers) {
|
||||||
|
subscriber.onChange(taskMap.values().stream().toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,7 +195,7 @@ public class JsonTaskList implements TaskList {
|
|||||||
|
|
||||||
taskMap = result.stream()
|
taskMap = result.stream()
|
||||||
.collect(HashMap::new,
|
.collect(HashMap::new,
|
||||||
(res, task) -> res.put(task.getId(), task),
|
(res, task) -> res.put(task.getId().orElse(0L), task),
|
||||||
(existing, replacement) -> {});
|
(existing, replacement) -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A database of {@link Plant}s.
|
* A List of {@link Plant}s.
|
||||||
* The interface specifies the minimal required operations.
|
* The interface specifies the minimal required operations.
|
||||||
*/
|
*/
|
||||||
public interface PlantList {
|
public interface PlantList {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import java.time.LocalDate;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A database of {@link Task}s.
|
* Represents a List of {@link Task}s.
|
||||||
* The interface specifies the minimal required operations.
|
* The interface specifies the operations to add/update and remove entries.
|
||||||
*/
|
*/
|
||||||
public interface TaskList {
|
public interface TaskList {
|
||||||
/**
|
/**
|
||||||
@@ -51,4 +51,22 @@ public interface TaskList {
|
|||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
void removeTask(Task task) throws IOException;
|
void removeTask(Task task) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an observer to be notified of Changes in the TaskList
|
||||||
|
* @param observer The change handler
|
||||||
|
*/
|
||||||
|
void subscribe(TaskListObserver observer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies an observer for a TaskList
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
interface TaskListObserver {
|
||||||
|
/**
|
||||||
|
* Method which will be called when changes occur.
|
||||||
|
* @param newTaskList The new values
|
||||||
|
*/
|
||||||
|
void onChange(List<Task> newTaskList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by the Jackson Library to deserialize a String to a {@link GrowthPhaseType}
|
||||||
|
*/
|
||||||
public class GrowthPhaseTypeDeserializer extends StdDeserializer<GrowthPhaseType> {
|
public class GrowthPhaseTypeDeserializer extends StdDeserializer<GrowthPhaseType> {
|
||||||
public GrowthPhaseTypeDeserializer(Class<?> vc) {
|
public GrowthPhaseTypeDeserializer(Class<?> vc) {
|
||||||
super(vc);
|
super(vc);
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by the Jackson Library to deserialize a String to a {@link HardinessZone}
|
||||||
|
*/
|
||||||
public class HardinessZoneDeserializer extends StdDeserializer<HardinessZone> {
|
public class HardinessZoneDeserializer extends StdDeserializer<HardinessZone> {
|
||||||
public HardinessZoneDeserializer(Class<?> vc) {
|
public HardinessZoneDeserializer(Class<?> vc) {
|
||||||
super(vc);
|
super(vc);
|
||||||
|
|||||||
@@ -13,18 +13,17 @@ import java.io.InputStream;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by the Jackson Library to deserialize a String to a {@link Image}
|
||||||
|
*/
|
||||||
public class PlantImageDeserializer extends JsonDeserializer<Image> {
|
public class PlantImageDeserializer extends JsonDeserializer<Image> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
public Image deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||||
Image result = null;
|
Image result = null;
|
||||||
URL imageUrl = PlantList.class.getResource(String.format("images/%s", parser.getText()));
|
InputStream is = PlantList.class.getResourceAsStream(String.format("images/%s", parser.getText()));
|
||||||
if (imageUrl != null) {
|
if (is != null) {
|
||||||
try (InputStream is = new FileInputStream(new File(imageUrl.toURI()))) {
|
result = new Image(is);
|
||||||
result = new Image(is);
|
|
||||||
} catch (IllegalArgumentException | URISyntaxException e) {
|
|
||||||
throw new IOException(String.format("Cannot find Image \"%s\"\n", imageUrl.getFile()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,19 @@ public class Garden {
|
|||||||
plantedCrops.clear();
|
plantedCrops.clear();
|
||||||
plantedCrops.addAll(cropList.getCrops());
|
plantedCrops.addAll(cropList.getCrops());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the {@link Crop} from the file and the cache
|
||||||
|
*
|
||||||
|
* @param crop The crop which is being updated
|
||||||
|
* @throws IOException If the database cannot be accessed
|
||||||
|
*/
|
||||||
|
public void updateCrop(Crop crop) throws IOException {
|
||||||
|
cropList.saveCrop(crop);
|
||||||
|
plantedCrops.clear();
|
||||||
|
plantedCrops.addAll(cropList.getCrops());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of {@link Crop}s which are currently in the gardenplan.
|
* Returns a list of {@link Crop}s which are currently in the gardenplan.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.time.LocalDate;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GardenSchedule {
|
public class GardenSchedule {
|
||||||
@@ -19,6 +20,7 @@ public class GardenSchedule {
|
|||||||
* Comparators to create sorted Task List
|
* Comparators to create sorted Task List
|
||||||
*/
|
*/
|
||||||
static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate);
|
static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate);
|
||||||
|
static final Comparator<Task> sortByNextExecution = Comparator.comparing(Task::getNextExecution);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to create Database Objects.
|
* Constructor to create Database Objects.
|
||||||
@@ -46,7 +48,8 @@ public class GardenSchedule {
|
|||||||
*/
|
*/
|
||||||
public void planTasksForCrop(Crop crop) throws PlantNotFoundException, HardinessZoneNotSetException, IOException {
|
public void planTasksForCrop(Crop crop) throws PlantNotFoundException, HardinessZoneNotSetException, IOException {
|
||||||
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).orElseThrow(PlantNotFoundException::new);
|
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).orElseThrow(PlantNotFoundException::new);
|
||||||
for (GrowthPhase growthPhase : plant.lifecycle()) {
|
int growPhaseGroup = plant.getGrowphaseGroupForDate(crop.getStartDate());
|
||||||
|
for (GrowthPhase growthPhase : plant.lifecycleForGroup(growPhaseGroup)) {
|
||||||
for (TaskTemplate taskTemplate : growthPhase.taskTemplates()) {
|
for (TaskTemplate taskTemplate : growthPhase.taskTemplates()) {
|
||||||
addTask(taskTemplate.generateTask(crop.getStartDate(), crop.getCropId().orElse(0L)));
|
addTask(taskTemplate.generateTask(crop.getStartDate(), crop.getCropId().orElse(0L)));
|
||||||
}
|
}
|
||||||
@@ -135,10 +138,27 @@ public class GardenSchedule {
|
|||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public List<List<Task>> getTasksUpcomingWeek() throws IOException {
|
public List<List<Task>> getTasksUpcomingWeek() throws IOException {
|
||||||
|
final int listLength = 7;
|
||||||
|
List<Task> weekTasks = taskList.getTaskList(LocalDate.now(), LocalDate.now().plusDays(listLength - 1));
|
||||||
List<List<Task>> dayTaskList = new ArrayList<>();
|
List<List<Task>> dayTaskList = new ArrayList<>();
|
||||||
for(int i = 0; i < 7; i++) {
|
for(int i = 0; i < listLength; i++) {
|
||||||
LocalDate date = LocalDate.now().plusDays(i);
|
LocalDate date = LocalDate.now().plusDays(i);
|
||||||
dayTaskList.add(taskList.getTaskList(date, date));
|
dayTaskList.add(new ArrayList<>());
|
||||||
|
final int finalI = i;
|
||||||
|
weekTasks.forEach(task -> {
|
||||||
|
if (task.getNextExecution() == null) {
|
||||||
|
task.isDone();
|
||||||
|
} else {
|
||||||
|
LocalDate checkDate = task.getNextExecution();
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) {
|
||||||
|
dayTaskList.get(finalI).add(task);
|
||||||
|
}
|
||||||
|
checkDate = checkDate.plusDays(task.getInterval().orElse(0));
|
||||||
|
} while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength)));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return dayTaskList;
|
return dayTaskList;
|
||||||
}
|
}
|
||||||
@@ -149,11 +169,8 @@ public class GardenSchedule {
|
|||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public List<List<Task>> getTasksUpcomingWeekForCrop(Long cropId) throws IOException {
|
public List<List<Task>> getTasksUpcomingWeekForCrop(Long cropId) throws IOException {
|
||||||
List<List<Task>> dayTaskList = new ArrayList<>();
|
List<List<Task>> dayTaskList = getTasksUpcomingWeek();
|
||||||
for(int i = 0; i < 7; i++) {
|
dayTaskList.forEach(taskList -> taskList.removeIf(task -> task.getCropId() != cropId));
|
||||||
LocalDate date = LocalDate.now().plusDays(i);
|
|
||||||
dayTaskList.add(filterListByCrop(taskList.getTaskList(date, date), cropId));
|
|
||||||
}
|
|
||||||
return dayTaskList;
|
return dayTaskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +182,7 @@ public class GardenSchedule {
|
|||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public List<Task> getFilteredTaskList(LocalDate start, LocalDate end) throws IOException {
|
public List<Task> getFilteredTaskList(LocalDate start, LocalDate end) throws IOException {
|
||||||
return getSortedTaskList(taskList.getTaskList(start, end), sortByStartDate);
|
return getSortedTaskList(taskList.getTaskList(start, end), sortByNextExecution);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,6 +192,6 @@ public class GardenSchedule {
|
|||||||
* @return a sorted coppy of the given Tasklist
|
* @return a sorted coppy of the given Tasklist
|
||||||
*/
|
*/
|
||||||
private List<Task> getSortedTaskList(List<Task> taskList, Comparator<Task> comparator) {
|
private List<Task> getSortedTaskList(List<Task> taskList, Comparator<Task> comparator) {
|
||||||
return taskList.stream().sorted(comparator).collect(Collectors.toList());
|
return taskList.stream().filter(task -> task.getNextExecution() != null).sorted(comparator).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package ch.zhaw.gartenverwaltung.types;
|
|||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.LinkedList;
|
import java.time.MonthDay;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -39,14 +39,23 @@ public record Plant(
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGrowphaseGroupForDate(LocalDate date) {
|
||||||
|
for(GrowthPhase growthPhase : lifecycle){
|
||||||
|
MonthDay plantingDate = MonthDay.of(date.getMonth().getValue(), date.getDayOfMonth());
|
||||||
|
if(plantingDate.isAfter(growthPhase.startDate()) && plantingDate.isBefore(growthPhase.endDate())){
|
||||||
|
return growthPhase.group();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0; // TODO implement
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get sow date from given harvest day from lifecycle group
|
* get sow date from given harvest day from lifecycle group
|
||||||
* @param harvestDate date of the harvest
|
* @param harvestDate date of the harvest
|
||||||
* @param group lifecycle group
|
|
||||||
* @return LocaleDate of sow date
|
* @return LocaleDate of sow date
|
||||||
*/
|
*/
|
||||||
public LocalDate sowDateFromHarvestDate(LocalDate harvestDate, int group) {
|
public LocalDate sowDateFromHarvestDate(LocalDate harvestDate) {
|
||||||
return harvestDate.minusDays(timeToHarvest(group));
|
return harvestDate.minusDays(timeToHarvest(lifecycleGroupFromHarvestDate(harvestDate)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,49 +66,55 @@ public record Plant(
|
|||||||
public int timeToHarvest(int group) {
|
public int timeToHarvest(int group) {
|
||||||
List<GrowthPhase> activeLifecycle = lifecycleForGroup(group);
|
List<GrowthPhase> activeLifecycle = lifecycleForGroup(group);
|
||||||
GrowthPhase sow = activeLifecycle.stream()
|
GrowthPhase sow = activeLifecycle.stream()
|
||||||
.filter(growthPhase -> !growthPhase.type().equals(GrowthPhaseType.SOW))
|
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.SOW))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
GrowthPhase harvest = activeLifecycle.stream()
|
GrowthPhase harvest = activeLifecycle.stream()
|
||||||
.filter(growthPhase -> !growthPhase.type().equals(GrowthPhaseType.HARVEST))
|
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.HARVEST))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
int currentYear = LocalDate.now().getYear();
|
int currentYear = LocalDate.now().getYear();
|
||||||
return (int) DAYS.between(harvest.startDate().atYear(currentYear), sow.startDate().atYear(currentYear));
|
return (int) DAYS.between(sow.startDate().atYear(currentYear),harvest.startDate().atYear(currentYear));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int lifecycleGroupFromHarvestDate(LocalDate harvestDate) {
|
||||||
|
return lifecycle.stream()
|
||||||
|
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.HARVEST) &&
|
||||||
|
dateInRange(harvestDate, growthPhase.startDate(), growthPhase.endDate()))
|
||||||
|
.map(GrowthPhase::group)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* filter out the given growthPhase out of the lifecycle
|
* Checks if the given {@link LocalDate} is within a {@link GrowthPhase} of the given {@link GrowthPhaseType}
|
||||||
* create list of dates for this growthPhase and return it
|
*
|
||||||
* @param growthPhase the wanted growthPhase
|
* @param date The date to check.
|
||||||
* @return a list of dates of the current year
|
* @param phase The {@link GrowthPhaseType} to match against
|
||||||
|
* @return Whether the date is within the given {@link GrowthPhaseType}
|
||||||
*/
|
*/
|
||||||
public List<LocalDate> getDateListOfGrowthPhase(GrowthPhaseType growthPhase) {
|
public boolean isDateInPhase(LocalDate date, GrowthPhaseType phase) {
|
||||||
List<LocalDate> dates = new LinkedList<>();
|
return lifecycle.stream()
|
||||||
for (GrowthPhase growth : lifecycle) {
|
.filter(growthPhase -> growthPhase.type().equals(phase))
|
||||||
if (growth.type().equals(growthPhase)) {
|
.anyMatch(growthPhase -> dateInRange(date, growthPhase.startDate(), growthPhase.endDate()));
|
||||||
dates = addDatesFromMonthDay(growth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dates;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transform monthDay value of the given growthPhase to localDate
|
* Checks if the given {@link LocalDate} is within the given {@link MonthDay} range.
|
||||||
* return a list of dates from start to end of growth phase
|
* (regardless of year)
|
||||||
* @param growthPhase the current growthPhase
|
*
|
||||||
* @return a list of dates of the current year
|
* @param subject The date to check
|
||||||
|
* @param min The start of the date-range
|
||||||
|
* @param max The end of the date-range
|
||||||
|
* @return Whether the subject is within the range.
|
||||||
*/
|
*/
|
||||||
private List<LocalDate> addDatesFromMonthDay(GrowthPhase growthPhase) {
|
private boolean dateInRange(LocalDate subject, MonthDay min, MonthDay max) {
|
||||||
List<LocalDate> dates = new LinkedList<>();
|
return subject.getMonth().compareTo(min.getMonth()) >= 0 &&
|
||||||
LocalDate today = LocalDate.now();
|
subject.getMonth().compareTo(max.getMonth()) <= 0 &&
|
||||||
LocalDate start = growthPhase.startDate().atYear(today.getYear());
|
// if the day is less than the minimum day, the minimum month must not be equal
|
||||||
LocalDate end = growthPhase.endDate().atYear(today.getYear());
|
(subject.getDayOfMonth() >= min.getDayOfMonth() || !subject.getMonth().equals(min.getMonth())) &&
|
||||||
while (!start.isAfter(end)) {
|
// if the day is greater than the maximum day, the maximum month must not be equal
|
||||||
dates.add(start);
|
(subject.getDayOfMonth() <= max.getDayOfMonth() || !subject.getMonth().equals(max.getMonth()));
|
||||||
start = start.plusDays(1);
|
|
||||||
}
|
|
||||||
return dates;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package ch.zhaw.gartenverwaltung.types;
|
|||||||
import java.time.MonthDay;
|
import java.time.MonthDay;
|
||||||
|
|
||||||
public enum Seasons {
|
public enum Seasons {
|
||||||
AllSEASONS("--01-01", "--12-31", "All Seasons"),
|
ALLSEASONS("--01-01", "--12-31", "All Seasons"),
|
||||||
SPRING("--03-01", "--05-30", "Spring"),
|
SPRING("--03-01", "--05-30", "Spring"),
|
||||||
SUMMER("--06-01", "--08-30", "Summer"),
|
SUMMER("--06-01", "--08-30", "Summer"),
|
||||||
AUTUMN("--09-01", "--11-30", "Autumn"),
|
AUTUMN("--09-01", "--11-30", "Autumn"),
|
||||||
|
|||||||
@@ -9,13 +9,16 @@ import java.util.Optional;
|
|||||||
* May be created using the builder pattern.
|
* May be created using the builder pattern.
|
||||||
*/
|
*/
|
||||||
public class Task {
|
public class Task {
|
||||||
private long id;
|
private Long id;
|
||||||
private final String name;
|
private String name;
|
||||||
private final String description;
|
private String description;
|
||||||
private final LocalDate startDate;
|
private LocalDate startDate;
|
||||||
private Integer interval;
|
private Integer interval;
|
||||||
private LocalDate endDate;
|
private LocalDate endDate;
|
||||||
|
private LocalDate nextExecution;
|
||||||
|
private LocalDate nextNotification;
|
||||||
private long cropId;
|
private long cropId;
|
||||||
|
private boolean done;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* default constructor
|
* default constructor
|
||||||
@@ -25,12 +28,16 @@ public class Task {
|
|||||||
name= "";
|
name= "";
|
||||||
description= "";
|
description= "";
|
||||||
startDate = LocalDate.now();
|
startDate = LocalDate.now();
|
||||||
|
endDate = startDate;
|
||||||
|
nextExecution = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task(String name, String description, LocalDate startDate, long cropId) {
|
public Task(String name, String description, LocalDate startDate, long cropId) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
|
this.endDate = startDate;
|
||||||
|
nextExecution = startDate;
|
||||||
this.cropId = cropId;
|
this.cropId = cropId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +45,7 @@ public class Task {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
|
nextExecution = startDate;
|
||||||
this.endDate = endDate;
|
this.endDate = endDate;
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
this.cropId = cropId;
|
this.cropId = cropId;
|
||||||
@@ -58,11 +66,33 @@ public class Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInTimePeriode(LocalDate searchStartDate, LocalDate searchEndDate){
|
public boolean isInTimePeriode(LocalDate searchStartDate, LocalDate searchEndDate){
|
||||||
return startDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate);
|
return endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void done(){
|
||||||
|
if(interval != null && interval != 0 && !nextExecution.plusDays(interval).isAfter(endDate)){
|
||||||
|
nextExecution = nextExecution.plusDays(interval);
|
||||||
|
} else {
|
||||||
|
nextExecution = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDone(){
|
||||||
|
return nextExecution == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextExecution(LocalDate nextExecution) {
|
||||||
|
this.nextExecution = nextExecution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextNotification(LocalDate nextNotification) {
|
||||||
|
this.nextNotification = nextNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
public long getId() { return id; }
|
public LocalDate getNextNotification() { return nextNotification; }
|
||||||
|
public LocalDate getNextExecution() { return nextExecution; }
|
||||||
|
public Optional<Long> getId() { return Optional.ofNullable(id); }
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
public String getDescription() { return description; }
|
public String getDescription() { return description; }
|
||||||
public LocalDate getStartDate() { return startDate; }
|
public LocalDate getStartDate() { return startDate; }
|
||||||
@@ -74,4 +104,14 @@ public class Task {
|
|||||||
public Optional<LocalDate> getEndDate() {
|
public Optional<LocalDate> getEndDate() {
|
||||||
return Optional.ofNullable(endDate);
|
return Optional.ofNullable(endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task updateTask(Task task) {
|
||||||
|
this.name = task.getName();
|
||||||
|
this.description = task.getDescription();
|
||||||
|
this.startDate = task.getStartDate();
|
||||||
|
this.endDate = task.getEndDate().orElse(null);
|
||||||
|
this.interval = task.getInterval().orElse(0);
|
||||||
|
this.cropId = task.getCropId();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ public class TaskTemplate {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private Integer interval;
|
private Integer interval;
|
||||||
|
|
||||||
// TODO: reconsider if we need this
|
|
||||||
@JsonProperty
|
|
||||||
private boolean isOptional = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
* (Used by deserializer)
|
* (Used by deserializer)
|
||||||
@@ -34,6 +30,7 @@ public class TaskTemplate {
|
|||||||
public void setRelativeEndDate(Integer relativeEndDate) {
|
public void setRelativeEndDate(Integer relativeEndDate) {
|
||||||
this.relativeEndDate = relativeEndDate;
|
this.relativeEndDate = relativeEndDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInterval(Integer interval) {
|
public void setInterval(Integer interval) {
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
}
|
}
|
||||||
@@ -45,13 +42,14 @@ public class TaskTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Task generateTask(LocalDate realStartDate, long cropId) {
|
public Task generateTask(LocalDate realStartDate, long cropId) {
|
||||||
Task task = new Task(name, description, realStartDate.plusDays(relativeStartDate), cropId);
|
LocalDate endDate = relativeEndDate != null ? realStartDate.plusDays(relativeEndDate) : realStartDate;
|
||||||
if (relativeEndDate != null) {
|
|
||||||
task.withEndDate(realStartDate.plusDays(relativeEndDate));
|
if (interval == null) {
|
||||||
|
this.interval = 0;
|
||||||
}
|
}
|
||||||
if (interval != null) {
|
|
||||||
task.withInterval(interval);
|
return new Task(name, description, realStartDate.plusDays(relativeStartDate), cropId)
|
||||||
}
|
.withInterval(interval)
|
||||||
return task;
|
.withEndDate(endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.ListView?>
|
||||||
<?import javafx.scene.control.ScrollPane?>
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
@@ -12,13 +13,11 @@
|
|||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?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">
|
||||||
<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>
|
<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">
|
<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>
|
<content>
|
||||||
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="503.0" prefWidth="897.0">
|
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="781.0" prefWidth="897.0">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
@@ -80,27 +79,27 @@
|
|||||||
<ImageView fx:id="imageView" fitHeight="300.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
|
<ImageView fx:id="imageView" fitHeight="300.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label text="Growth Phases:">
|
<Label text="Tasks:">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<VBox fx:id="growthPhases_vbox" prefHeight="135.0" prefWidth="879.0">
|
<ListView fx:id="taskList_listView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="877.0" VBox.vgrow="ALWAYS">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</VBox>
|
</ListView>
|
||||||
<Button mnemonicParsing="false" onAction="#editTaskList" prefHeight="25.0" prefWidth="92.0" text="Edit Tasklist">
|
<Button fx:id="addTask_button" mnemonicParsing="false" onAction="#addTask" prefHeight="25.0" prefWidth="45.0">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<Label text="Pests:" />
|
<Label text="Pests:" />
|
||||||
<VBox fx:id="pests_vbox" prefHeight="200.0" prefWidth="100.0">
|
<ListView fx:id="pests_listView" maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</VBox>
|
</ListView>
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" VBox.vgrow="NEVER">
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" VBox.vgrow="NEVER">
|
||||||
<children>
|
<children>
|
||||||
<Label text="Area:">
|
<Label text="Area:">
|
||||||
@@ -108,12 +107,12 @@
|
|||||||
<Insets right="60.0" />
|
<Insets right="60.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Label fx:id="area_label" text="Label">
|
<Label fx:id="area_label" minWidth="-Infinity" prefWidth="50.0" text="Label">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets right="10.0" />
|
<Insets right="10.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Add Area" />
|
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Set Area" />
|
||||||
</children>
|
</children>
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
@@ -126,12 +125,12 @@
|
|||||||
<Insets right="40.0" />
|
<Insets right="40.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Label fx:id="location_label" text="Label">
|
<Label fx:id="location_label" minHeight="-Infinity" prefWidth="50.0" text="Label">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets right="10.0" />
|
<Insets right="10.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Button fx:id="location_button" mnemonicParsing="false" onAction="#setLocation" prefHeight="25.0" prefWidth="115.0" text="Add Location" />
|
<Button fx:id="location_button" mnemonicParsing="false" onAction="#setLocation" prefHeight="25.0" prefWidth="115.0" text="Set Location" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -2,42 +2,210 @@
|
|||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.layout.Pane?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
<?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="1091.0" prefWidth="1060.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.HomeController">
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="729.0" prefWidth="1060.0"
|
|
||||||
xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.HomeController">
|
|
||||||
<children>
|
<children>
|
||||||
<VBox layoutX="75.0" layoutY="73.0" prefHeight="729.0" prefWidth="1060.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<ScrollPane fitToWidth="true" prefHeight="1157.0" prefWidth="1060.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<content>
|
||||||
<Label text="Gartenverwaltung">
|
<VBox prefHeight="1091.0" prefWidth="1058.0">
|
||||||
<font>
|
|
||||||
<Font size="34.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label prefHeight="106.0" prefWidth="1040.0" text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." wrapText="true" />
|
|
||||||
<Label text="Tutorial">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="18.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Pane prefHeight="200.0" prefWidth="200.0">
|
|
||||||
<children>
|
<children>
|
||||||
<VBox prefHeight="200.0" prefWidth="1040.0">
|
<Pane prefHeight="1085.0" prefWidth="1018.0">
|
||||||
<children>
|
<children>
|
||||||
<Label text="Task 1" wrapText="true" />
|
<VBox prefHeight="1047.0" prefWidth="1019.0">
|
||||||
<Label text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." wrapText="true" />
|
<children>
|
||||||
|
<Label text="Garden Management">
|
||||||
|
<font>
|
||||||
|
<Font size="34.0" />
|
||||||
|
</font>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="30.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<Label alignment="TOP_LEFT" prefHeight="22.0" prefWidth="1039.0" text="This Application was created to help the user manage his or her garden. For this the Application has many functionalities:" wrapText="true">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<Label text="Base Functionalities:">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label text="- The user can select a plant he wants to cultivate.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="62.0" text="- The user can filter the plants according to seasons, hardiness zone and search query">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="62.0" text="- The user can select the harverst or sow date. ">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="102.0" text="- The user can get a detailed information of the plant he wants to harvest.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="122.0" text="- The user can get view the task list of the given plant.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="142.0" text="- The user can get the tasks of the next seven days in the scheduler.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="42.0" text="Advanced Functionalities:">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="62.0" text="- The user can edit the task list and add custom tasks.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="212.0" text="- The user can set the area (sqare meter) for the plants.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="232.0" text="- The user can set the location (PLZ) for the plants.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="162.0" text="- The user can set the pesticide which will be used, which will create additonal tasks.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="192.0" text="Weather Forcast:">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="212.0" text="- According to the location the weather forcast will crate or delete tasks.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="10.0" layoutY="272.0" text="- The user receives notifications that aditional tasks werde created or some tasks were deleted.">
|
||||||
|
<font>
|
||||||
|
<Font size="14.0" />
|
||||||
|
</font>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<Label text="Created by:">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="imageViewElias" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="30.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</ImageView>
|
||||||
|
<Label text="Elias Csomor" />
|
||||||
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="15.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="imageViewPhilippe" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="30.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</ImageView>
|
||||||
|
<Label text="Philippe Giavarini" />
|
||||||
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="15.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="imageViewDavid" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="30.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</ImageView>
|
||||||
|
<Label text="David Guler" />
|
||||||
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="15.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="imageViewGian" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="30.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</ImageView>
|
||||||
|
<Label text="Gian-Andrea Hutter" />
|
||||||
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="15.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="imageViewRoman" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="30.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</ImageView>
|
||||||
|
<Label text="Roman Schenk" />
|
||||||
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="15.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Pane>
|
||||||
</children>
|
</children>
|
||||||
</Pane>
|
<padding>
|
||||||
</children>
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
<padding>
|
</padding>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
</VBox>
|
||||||
</padding>
|
</content>
|
||||||
</VBox>
|
</ScrollPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|||||||
@@ -7,13 +7,14 @@
|
|||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="938.0" prefWidth="1110.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MainFXMLController">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="938.0" prefWidth="1110.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MainFXMLController">
|
||||||
<children>
|
<children>
|
||||||
<HBox maxWidth="35.0" minHeight="35.0" prefHeight="38.0" prefWidth="1110.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<HBox fx:id="menubar" maxWidth="35.0" minHeight="40.0" prefHeight="38.0" prefWidth="1110.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="home_button" mnemonicParsing="false" onAction="#goToHome" prefHeight="38.0" prefWidth="121.0" text="Home" HBox.hgrow="NEVER" />
|
<Button fx:id="home_button" mnemonicParsing="false" onAction="#goToHome" prefHeight="38.0" prefWidth="38.0" HBox.hgrow="NEVER" />
|
||||||
<Button fx:id="plants_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToPlants" prefHeight="38.0" prefWidth="121.0" text="Plants" />
|
|
||||||
<Button fx:id="myGarden_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMyPlants" prefHeight="38.0" prefWidth="121.0" text="My Garden" />
|
<Button fx:id="myGarden_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMyPlants" prefHeight="38.0" prefWidth="121.0" text="My Garden" />
|
||||||
<Button fx:id="mySchedule_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMySchedule" prefHeight="38.0" prefWidth="121.0" text="My Schedule" />
|
<Button fx:id="mySchedule_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMySchedule" prefHeight="38.0" prefWidth="121.0" text="My Schedule" />
|
||||||
<Pane maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
|
<Button fx:id="tutorial_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#showTutorial" prefHeight="38.0" prefWidth="121.0" text="Tutorial" />
|
||||||
|
<Pane fx:id="menu_pane" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
|
||||||
|
<Button fx:id="settings_button" mnemonicParsing="false" onAction="#openSettings" prefHeight="38.0" prefWidth="38.0" HBox.hgrow="NEVER" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<AnchorPane fx:id="mainPane" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="35.0" />
|
<AnchorPane fx:id="mainPane" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="35.0" />
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.ListView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?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.MyGardenController" fx:id="myGardenRoot">
|
<AnchorPane fx:id="myGardenRoot" 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.MyGardenController">
|
||||||
<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 +20,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" />
|
<ListView fx:id="myGarden_listView" maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.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" />
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ListView?>
|
<?import javafx.scene.control.ListView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
|
||||||
<?import javafx.scene.layout.GridPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.layout.Pane?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
|
||||||
<?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="572.0" prefWidth="867.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyScheduleController">
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="572.0" prefWidth="867.0"
|
|
||||||
xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyScheduleController">
|
|
||||||
<children>
|
<children>
|
||||||
<Label layoutX="14.0" layoutY="14.0" text="MySchedule">
|
<Label layoutX="14.0" layoutY="14.0" text="MySchedule">
|
||||||
<font>
|
<font>
|
||||||
@@ -22,41 +18,18 @@
|
|||||||
</Label>
|
</Label>
|
||||||
<HBox layoutY="31.0" prefHeight="541.0" prefWidth="867.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0">
|
<HBox layoutY="31.0" prefHeight="541.0" prefWidth="867.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0">
|
||||||
<children>
|
<children>
|
||||||
<ListView fx:id="scheduledPlants_listview" maxWidth="1.7976931348623157E308" prefHeight="522.0" prefWidth="365.0" HBox.hgrow="NEVER" />
|
<ListView fx:id="scheduledPlants_listview" maxWidth="1.7976931348623157E308" prefHeight="522.0" prefWidth="271.0" HBox.hgrow="NEVER">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</HBox.margin></ListView>
|
||||||
<VBox maxWidth="1.7976931348623157E308" prefHeight="537.0" prefWidth="650.0" HBox.hgrow="ALWAYS">
|
<VBox maxWidth="1.7976931348623157E308" prefHeight="537.0" prefWidth="650.0" HBox.hgrow="ALWAYS">
|
||||||
<children>
|
<children>
|
||||||
<GridPane alignment="CENTER_LEFT" gridLinesVisible="true" maxWidth="1.7976931348623157E308" prefHeight="403.0" prefWidth="575.0" VBox.vgrow="ALWAYS">
|
<ListView fx:id="week_listView" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
|
||||||
<columnConstraints>
|
<VBox.margin>
|
||||||
<ColumnConstraints fillWidth="false" hgrow="NEVER" maxWidth="278.0" minWidth="100.0" prefWidth="173.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="402.0" />
|
</VBox.margin>
|
||||||
</columnConstraints>
|
</ListView>
|
||||||
<rowConstraints>
|
<Pane prefHeight="131.0" prefWidth="593.0" VBox.vgrow="NEVER">
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<Label fx:id="day1_label" alignment="CENTER" prefHeight="32.0" prefWidth="173.0" text="Label" />
|
|
||||||
<Label fx:id="day2_label" alignment="CENTER" prefHeight="29.0" prefWidth="173.0" text="Label" GridPane.rowIndex="1" />
|
|
||||||
<Label fx:id="day3_label" alignment="CENTER" prefHeight="32.0" prefWidth="172.0" text="Label" GridPane.rowIndex="2" />
|
|
||||||
<Label fx:id="day4_label" alignment="CENTER" prefHeight="35.0" prefWidth="173.0" text="Label" GridPane.rowIndex="3" />
|
|
||||||
<Label fx:id="day5_label" alignment="CENTER" prefHeight="31.0" prefWidth="173.0" text="Label" GridPane.rowIndex="4" />
|
|
||||||
<Label fx:id="day6_label" alignment="CENTER" prefHeight="31.0" prefWidth="173.0" text="Label" GridPane.rowIndex="5" />
|
|
||||||
<Label fx:id="day7_label" alignment="CENTER" prefHeight="35.0" prefWidth="173.0" text="Label" GridPane.rowIndex="6" />
|
|
||||||
<Pane fx:id="day1_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" />
|
|
||||||
<Pane fx:id="day2_pane" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
|
||||||
<Pane fx:id="day3_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
|
||||||
<Pane fx:id="day4_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
|
||||||
<Pane fx:id="day5_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
|
||||||
<Pane fx:id="day6_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="5" />
|
|
||||||
<Pane fx:id="day7_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
<Pane prefHeight="119.0" prefWidth="575.0" VBox.vgrow="NEVER">
|
|
||||||
<children>
|
<children>
|
||||||
<Label alignment="TOP_LEFT" layoutX="14.0" layoutY="14.0" prefHeight="17.0" prefWidth="550.0" text="Importants Information:" wrapText="true">
|
<Label alignment="TOP_LEFT" layoutX="14.0" layoutY="14.0" prefHeight="17.0" prefWidth="550.0" text="Importants Information:" wrapText="true">
|
||||||
<font>
|
<font>
|
||||||
@@ -65,6 +38,9 @@
|
|||||||
</Label>
|
</Label>
|
||||||
<Label fx:id="information_label" alignment="TOP_LEFT" layoutX="14.0" layoutY="31.0" maxWidth="1.7976931348623157E308" prefHeight="82.0" prefWidth="550.0" text="Label" wrapText="true" />
|
<Label fx:id="information_label" alignment="TOP_LEFT" layoutX="14.0" layoutY="31.0" maxWidth="1.7976931348623157E308" prefHeight="82.0" prefWidth="550.0" text="Label" wrapText="true" />
|
||||||
</children>
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
</Pane>
|
</Pane>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
<Font name="System Bold" size="17.0" />
|
<Font name="System Bold" size="17.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
<TitledPane animated="false" text="Saison">
|
<TitledPane animated="false" text="Seasons">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -18,15 +18,15 @@
|
|||||||
<children>
|
<children>
|
||||||
<VBox alignment="CENTER_LEFT" prefHeight="88.0" prefWidth="155.0">
|
<VBox alignment="CENTER_LEFT" prefHeight="88.0" prefWidth="155.0">
|
||||||
<children>
|
<children>
|
||||||
<RadioButton fx:id="sow_radio" mnemonicParsing="false" selected="true" text="Sow" toggleGroup="$group">
|
<RadioButton fx:id="sow_radio" mnemonicParsing="false" selected="true" text="Sow" toggleGroup="$phase_group">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
<toggleGroup>
|
<toggleGroup>
|
||||||
<ToggleGroup fx:id="group" />
|
<ToggleGroup fx:id="phase_group" />
|
||||||
</toggleGroup>
|
</toggleGroup>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton fx:id="harvest_radio" mnemonicParsing="false" text="Harvest" toggleGroup="$group" />
|
<RadioButton fx:id="harvest_radio" mnemonicParsing="false" text="Harvest" toggleGroup="$phase_group" />
|
||||||
</children>
|
</children>
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets top="10.0" />
|
<Insets top="10.0" />
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.CheckBox?>
|
||||||
|
<?import javafx.scene.control.ComboBox?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="80.0" prefWidth="374.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.SettingsController">
|
||||||
|
<children>
|
||||||
|
<VBox layoutX="14.0" layoutY="14.0" prefHeight="73.0" prefWidth="374.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<HBox prefHeight="23.0" prefWidth="334.0">
|
||||||
|
<children>
|
||||||
|
<Label maxWidth="1.7976931348623157E308" text="Show Tutorial Menu" HBox.hgrow="ALWAYS" />
|
||||||
|
<CheckBox fx:id="showTutorial_checkBox" mnemonicParsing="false" />
|
||||||
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets left="10.0" right="10.0" top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="20.0" prefHeight="23.0" prefWidth="334.0">
|
||||||
|
<children>
|
||||||
|
<Label maxWidth="1.7976931348623157E308" text="Select Default Hardiness Zone" HBox.hgrow="ALWAYS" />
|
||||||
|
<ComboBox fx:id="selectHardinessZone_comboBox" prefWidth="150.0" promptText="Hardniness Zone" />
|
||||||
|
</children>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.DatePicker?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TextArea?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="259.0" prefWidth="390.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.TaskFormularController">
|
||||||
|
<children>
|
||||||
|
<VBox layoutX="14.0" layoutY="14.0" prefHeight="272.0" prefWidth="390.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||||
|
</padding>
|
||||||
|
<children>
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="35.0" prefWidth="560.0">
|
||||||
|
<children>
|
||||||
|
<Label maxWidth="1.7976931348623157E308" text="Task name:" HBox.hgrow="ALWAYS" />
|
||||||
|
<TextField fx:id="taskName_field" promptText="Task Name" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<HBox prefHeight="77.0" prefWidth="350.0">
|
||||||
|
<children>
|
||||||
|
<Label maxWidth="1.7976931348623157E308" text="Description:" HBox.hgrow="ALWAYS" />
|
||||||
|
<TextArea fx:id="description_area" prefHeight="73.0" prefWidth="206.0" promptText="Description" wrapText="true" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0">
|
||||||
|
<children>
|
||||||
|
<Label maxWidth="1.7976931348623157E308" text="Start Date:" HBox.hgrow="ALWAYS" />
|
||||||
|
<DatePicker fx:id="start_datePicker" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="143.0" prefHeight="35.0" prefWidth="560.0">
|
||||||
|
<children>
|
||||||
|
<Label maxWidth="1.7976931348623157E308" text="End Date:" HBox.hgrow="ALWAYS" />
|
||||||
|
<DatePicker fx:id="end_datePicker" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0">
|
||||||
|
<children>
|
||||||
|
<Label maxWidth="1.7976931348623157E308" text="Interval:" HBox.hgrow="ALWAYS" />
|
||||||
|
<TextField fx:id="interval_field" promptText="Interval (e.g. 0, 1, 3 ...)" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="64.0" prefWidth="298.0" xmlns="http://javafx.com/javafx/17"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.TextFieldFormularController">
|
||||||
|
<children>
|
||||||
|
<HBox alignment="CENTER" layoutX="153.0" layoutY="33.0" prefHeight="100.0" prefWidth="200.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="description_label" maxWidth="1.7976931348623157E308" text="Label" HBox.hgrow="ALWAYS" />
|
||||||
|
<TextField fx:id="text_area" HBox.hgrow="NEVER" />
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ButtonBar?>
|
||||||
|
<?import javafx.scene.control.CheckBox?>
|
||||||
|
<?import javafx.scene.control.Separator?>
|
||||||
|
<?import javafx.scene.image.ImageView?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.StackPane?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
<?import javafx.scene.text.Text?>
|
||||||
|
<?import javafx.scene.text.TextFlow?>
|
||||||
|
|
||||||
|
<BorderPane maxHeight="470.0" maxWidth="724.0" minHeight="470.0" minWidth="724.0" prefHeight="470.0" prefWidth="724.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.TutorialController">
|
||||||
|
<bottom>
|
||||||
|
<HBox alignment="CENTER" prefHeight="0.0" prefWidth="724.0" BorderPane.alignment="CENTER">
|
||||||
|
<children>
|
||||||
|
<CheckBox mnemonicParsing="false" text="Don't show again" />
|
||||||
|
<Separator prefWidth="50.0" visible="false" HBox.hgrow="ALWAYS" />
|
||||||
|
<ButtonBar prefHeight="40.0" prefWidth="200.0">
|
||||||
|
<buttons>
|
||||||
|
<Button cancelButton="true" contentDisplay="CENTER" graphicTextGap="5.0" mnemonicParsing="false" text="Close" onAction="#closeTutorial"/>
|
||||||
|
<Button fx:id="previousPageButton" mnemonicParsing="false" text="Previous" onAction="#viewPreviousPage"/>
|
||||||
|
<Button fx:id="nextPageButton" defaultButton="true" mnemonicParsing="false" text="Next" onAction="#viewNextPage" />
|
||||||
|
</buttons>
|
||||||
|
</ButtonBar>
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</padding>
|
||||||
|
</HBox>
|
||||||
|
</bottom>
|
||||||
|
<center>
|
||||||
|
<StackPane fx:id="tourPages" prefHeight="150.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
|
<children>
|
||||||
|
<VBox layoutX="30.0" layoutY="26.0" opacity="0.0" prefHeight="200.0" prefWidth="100.0">
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Managing Your Crops">
|
||||||
|
<font>
|
||||||
|
<Font size="24.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<Separator prefWidth="200.0">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="15.0" top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Separator>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="In the "My Garden" tab, you can see all of the plants you're planning on growing.">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="20.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Text>
|
||||||
|
<HBox prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<TextFlow lineSpacing="4.0" prefHeight="90.0" prefWidth="500.0">
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="To get started, click on the "Add new Plant" button in the bottom left. This will open a list of all the plants you can grow. Use the search bar at the top, the filters on the left, or simply browse the list until you've found a plant you want to grow in your garden." wrappingWidth="345.80316162109375" />
|
||||||
|
</children>
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets bottom="20.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</TextFlow>
|
||||||
|
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
||||||
|
<ImageView fx:id="imgAddNewPlant" fitHeight="98.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<HBox prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Once you've found what you're looking for, click the "Select Sow/Harvest Date" button at the bottom of the window. In the subsequently shown dialog, you can select the date you'd like to sow or harvest the crop. The date selector shows possible dates in green. Confirm your selection with the "Save" button." />
|
||||||
|
</children>
|
||||||
|
</TextFlow>
|
||||||
|
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
||||||
|
<ImageView fx:id="imgSelectDate" fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
<opaqueInsets>
|
||||||
|
<Insets />
|
||||||
|
</opaqueInsets>
|
||||||
|
</VBox>
|
||||||
|
<VBox prefHeight="200.0" prefWidth="100.0">
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Managing Your Tasks">
|
||||||
|
<font>
|
||||||
|
<Font size="24.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<Separator prefWidth="200.0">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="15.0" top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Separator>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="In the "My Schedule" tab, you can see all of the tasks you need to complete for a successful harvest.">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="20.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Text>
|
||||||
|
<HBox prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<TextFlow lineSpacing="4.0" prefHeight="90.0" prefWidth="500.0">
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="You can view the tasks for a specific crop by selecting it from the left sidebar. To see all tasks again, click the "Clear Filter" button at the bottom." wrappingWidth="345.80316162109375" />
|
||||||
|
</children>
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets bottom="20.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</TextFlow>
|
||||||
|
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
||||||
|
<ImageView fx:id="imgTaskList" fitHeight="98.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<HBox prefHeight="100.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="You can also add your own custom tasks, by clicking the "Add Task" button. In the subsequently shown dialog, you can enter the corresponding details. Note: If you want to make a task recurring, you need to set both an interval (in days) AND an end date, so the task won't repeat for all eternity." />
|
||||||
|
</children>
|
||||||
|
</TextFlow>
|
||||||
|
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
||||||
|
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
|
</children></HBox>
|
||||||
|
</children>
|
||||||
|
<opaqueInsets>
|
||||||
|
<Insets />
|
||||||
|
</opaqueInsets>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets />
|
||||||
|
</BorderPane.margin>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||||
|
</padding>
|
||||||
|
</StackPane>
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
#home_button, #myGarden_button,
|
||||||
|
#mySchedule_button, #settings_button,
|
||||||
|
#tutorial_button, #menu_pane {
|
||||||
|
-fx-text-fill: white;
|
||||||
|
-fx-background-color: rgb(0,128,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#menubar {
|
||||||
|
-fx-background-color: rgb(0,128,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#home_button:hover, #myGarden_button:hover,
|
||||||
|
#mySchedule_button:hover, #settings_button:hover,
|
||||||
|
#tutorial_button:hover,
|
||||||
|
#home_button:focused, #myGarden_button:focused,
|
||||||
|
#mySchedule_button:focused, #settings_button:focused,
|
||||||
|
#tutorial_button:focused{
|
||||||
|
-fx-background-color: darkgreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
.root, .split-pane {
|
||||||
|
-fx-background-color: linear-gradient(green 0%, lawngreen 33%, lightgreen 66%, #eee 100%);
|
||||||
|
}./
|
||||||
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 26 KiB |
@@ -32,8 +32,7 @@
|
|||||||
"relativeStartDate": -14,
|
"relativeStartDate": -14,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -54,8 +53,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
||||||
"interval": 21,
|
"interval": 21
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -76,8 +74,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -106,8 +103,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 0,
|
"relativeEndDate": 0,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -130,8 +126,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": 15,
|
"interval": 15
|
||||||
"isOptional": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -152,8 +147,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 14,
|
"relativeEndDate": 14,
|
||||||
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -184,17 +178,15 @@
|
|||||||
"litersPerSqM": 15,
|
"litersPerSqM": 15,
|
||||||
"interval": 4,
|
"interval": 4,
|
||||||
"notes": [
|
"notes": [
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "hilling",
|
"name": "Plant Sets",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 0,
|
"relativeEndDate": 0,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Plant the sets about 5cm deep into the soil.",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -217,8 +209,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": 15,
|
"interval": 15
|
||||||
"isOptional": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -232,7 +223,6 @@
|
|||||||
"litersPerSqM": 0,
|
"litersPerSqM": 0,
|
||||||
"interval": null,
|
"interval": null,
|
||||||
"notes": [
|
"notes": [
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
@@ -241,8 +231,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 14,
|
"relativeEndDate": 14,
|
||||||
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -256,5 +245,86 @@
|
|||||||
"measures": "less water"
|
"measures": "less water"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "Test Potato",
|
||||||
|
"description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.",
|
||||||
|
"light": 6,
|
||||||
|
"spacing": "35",
|
||||||
|
"soil": "sandy",
|
||||||
|
"image": "potato.jpg",
|
||||||
|
"pests": [
|
||||||
|
{
|
||||||
|
"name": "Rot",
|
||||||
|
"description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
||||||
|
"measures": "Less water."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"lifecycle": [
|
||||||
|
{
|
||||||
|
"startDate": "12-01",
|
||||||
|
"endDate": "12-02",
|
||||||
|
"type": "SOW",
|
||||||
|
"zone": "ZONE_8A",
|
||||||
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 0,
|
||||||
|
"interval": null,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
|
"taskTemplates": [
|
||||||
|
{
|
||||||
|
"name": "Germinate",
|
||||||
|
"relativeStartDate": -3,
|
||||||
|
"relativeEndDate": 0,
|
||||||
|
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
||||||
|
"interval": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startDate": "12-03",
|
||||||
|
"endDate": "12-15",
|
||||||
|
"type": "PLANT",
|
||||||
|
"zone": "ZONE_8A",
|
||||||
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 25,
|
||||||
|
"interval": 7,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
|
"taskTemplates": [
|
||||||
|
{
|
||||||
|
"name": "hilling",
|
||||||
|
"relativeStartDate": 0,
|
||||||
|
"relativeEndDate": 10,
|
||||||
|
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
||||||
|
"interval": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"startDate": "12-16",
|
||||||
|
"endDate": "12-18",
|
||||||
|
"type": "HARVEST",
|
||||||
|
"zone": "ZONE_8A",
|
||||||
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 0,
|
||||||
|
"interval": null,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
|
"taskTemplates": [
|
||||||
|
{
|
||||||
|
"name": "Harvest",
|
||||||
|
"relativeStartDate": 0,
|
||||||
|
"relativeEndDate": 4,
|
||||||
|
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
||||||
|
"interval": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,56 +1,68 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id" : 1,
|
"id": 1,
|
||||||
"name" : "sow plant",
|
"name": "sow plant",
|
||||||
"description": "Plant the seeds, crops in de bed.",
|
"description": "Plant the seeds, crops in de bed.",
|
||||||
"startDate" : "2022-05-01",
|
"startDate": "2022-05-01",
|
||||||
"endDate" : "2022-05-01",
|
"nextExecution": "2022-05-01",
|
||||||
"interval" : 0,
|
"nextNotification": "2022-05-01",
|
||||||
"cropId" : 0
|
"endDate": "2022-05-01",
|
||||||
|
"interval": null,
|
||||||
|
"cropId": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 2,
|
"id": 2,
|
||||||
"name" : "water plant",
|
"name": "water plant",
|
||||||
"description": "water the plant, so that the soil is wet around the plant.",
|
"description": "water the plant, so that the soil is wet around the plant.",
|
||||||
"startDate" : "2022-05-01",
|
"startDate": "2022-05-01",
|
||||||
"endDate" : "2022-09-01",
|
"nextExecution": "2022-05-01",
|
||||||
"interval" : 2,
|
"nextNotification": "2022-05-01",
|
||||||
"cropId" : 0
|
"endDate": "2022-09-01",
|
||||||
|
"interval": 2,
|
||||||
|
"cropId": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 3,
|
"id": 3,
|
||||||
"name" : "fertilize plant",
|
"name": "fertilize plant",
|
||||||
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
||||||
"startDate" : "2022-06-01",
|
"startDate": "2022-06-01",
|
||||||
"endDate" : "2022-08-01",
|
"nextExecution": "2022-06-01",
|
||||||
"interval" : 28,
|
"nextNotification": "2022-06-01",
|
||||||
"cropId" : 0
|
"endDate": "2022-08-01",
|
||||||
|
"interval": 28,
|
||||||
|
"cropId": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 4,
|
"id": 4,
|
||||||
"name" : "covering plant",
|
"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",
|
"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",
|
"startDate": "2022-07-01",
|
||||||
"endDate" : "2022-07-01",
|
"nextExecution": "2022-07-01",
|
||||||
"interval" : 0,
|
"nextNotification": "2022-07-01",
|
||||||
"cropId" : 0
|
"endDate": "2022-07-01",
|
||||||
|
"interval": null,
|
||||||
|
"cropId": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 5,
|
"id": 5,
|
||||||
"name" : "look after plant",
|
"name": "look after plant",
|
||||||
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
||||||
"startDate" : "2022-05-01",
|
"startDate": "2022-05-01",
|
||||||
"endDate" : "2022-09-01",
|
"nextExecution": "2022-05-01",
|
||||||
"interval" : 5,
|
"nextNotification": "2022-05-01",
|
||||||
"cropId" : 0
|
"endDate": "2022-09-01",
|
||||||
|
"interval": 5,
|
||||||
|
"cropId": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 6,
|
"id": 6,
|
||||||
"name" : "harvest plant",
|
"name": "harvest plant",
|
||||||
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
||||||
"startDate" : "2022-09-01",
|
"startDate": "2022-09-01",
|
||||||
"endDate" : "2022-09-01",
|
"nextExecution": "2022-09-01",
|
||||||
"interval" : 0,
|
"nextNotification": "2022-09-01",
|
||||||
"cropId" : 0
|
"endDate": "2022-09-01",
|
||||||
|
"interval": null,
|
||||||
|
"cropId": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -28,8 +28,9 @@ public class JsonCropListTest {
|
|||||||
/**
|
/**
|
||||||
* Files to isolate the test-units
|
* Files to isolate the test-units
|
||||||
*/
|
*/
|
||||||
private final URL dbDataSource = this.getClass().getResource("user-crops.json");
|
private final URL dbDataSource = this.getClass().getResource("test-user-crops.json");
|
||||||
private final URL testFile = this.getClass().getResource("test-user-crops.json");
|
private final URL testFile = this.getClass().getResource("template-user-crops.json");
|
||||||
|
private final URL corruptTestFile = this.getClass().getResource("corrupt-template-user-crops.json");
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void connectToDb() throws URISyntaxException, IOException {
|
void connectToDb() throws URISyntaxException, IOException {
|
||||||
@@ -101,5 +102,13 @@ public class JsonCropListTest {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void detectCorruptJsonResource(){
|
||||||
|
JsonCropList tL = new JsonCropList(corruptTestFile);
|
||||||
|
Assertions.assertThrows(InvalidJsonException.class, () -> {
|
||||||
|
tL.getCrops();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,23 @@ import org.junit.jupiter.api.DisplayName;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class JsonPlantListTest {
|
public class JsonPlantListTest {
|
||||||
|
private final URL testFile = this.getClass().getResource("test-plantdb.json");
|
||||||
PlantList testDatabase;
|
PlantList testDatabase;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void connectToDb() {
|
void connectToDb() {
|
||||||
testDatabase = new JsonPlantList();
|
assertNotNull(testFile);
|
||||||
|
testDatabase = new JsonPlantList(testFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -57,6 +63,8 @@ public class JsonPlantListTest {
|
|||||||
void getPlantByIdAndZone() {
|
void getPlantByIdAndZone() {
|
||||||
Optional<Plant> testPlant;
|
Optional<Plant> testPlant;
|
||||||
try {
|
try {
|
||||||
|
assertThrows(HardinessZoneNotSetException.class, () -> testDatabase.getPlantById(null,1).get());
|
||||||
|
|
||||||
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_8A, 1);
|
testPlant = testDatabase.getPlantById(HardinessZone.ZONE_8A, 1);
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
} catch (IOException | HardinessZoneNotSetException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -90,5 +98,16 @@ public class JsonPlantListTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDefaultConstructor(){
|
||||||
|
JsonPlantList db = new JsonPlantList();
|
||||||
|
try {
|
||||||
|
assertNotNull(db.getPlantList(HardinessZone.ZONE_8A));
|
||||||
|
} catch (IOException | HardinessZoneNotSetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package ch.zhaw.gartenverwaltung.io;
|
|||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@@ -14,31 +16,33 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
public class JsonTaskListTest {
|
public class JsonTaskListTest {
|
||||||
|
|
||||||
TaskList testDatabase;
|
TaskList testDatabase;
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
|
||||||
private final URL dbDataSource = this.getClass().getResource("taskdb.json");
|
private final URL dbDataSource = this.getClass().getResource("test-taskdb.json");
|
||||||
private final URL testFile = this.getClass().getResource("test-taskdb.json");
|
private final URL testFile = this.getClass().getResource("template-taskdb.json");
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void connectToDb() throws URISyntaxException, IOException {
|
void connectToDb() throws URISyntaxException, IOException {
|
||||||
assertNotNull(testFile);
|
assertNotNull(testFile);
|
||||||
assertNotNull(dbDataSource);
|
assertNotNull(dbDataSource);
|
||||||
Files.copy(Path.of(testFile.toURI()), Path.of(dbDataSource.toURI()), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(Path.of(testFile.toURI()), Path.of(dbDataSource.toURI()), StandardCopyOption.REPLACE_EXISTING);
|
||||||
testDatabase = new JsonTaskList();
|
testDatabase = new JsonTaskList(dbDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Check if results are retrieved completely")
|
@DisplayName("Check if results are retrieved completely")
|
||||||
void getTasks() {
|
void getTasks() {
|
||||||
|
|
||||||
List<Task> taskList = null;
|
List<Task> taskList;
|
||||||
try {
|
try {
|
||||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
|
||||||
LocalDate.parse("31.05.2022", formatter));
|
LocalDate.parse("2022-05-31", formatter));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -47,17 +51,16 @@ public class JsonTaskListTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("disabled until adding works.")
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Add task.")
|
@DisplayName("Add task.")
|
||||||
void addTask() {
|
void addTask() {
|
||||||
Task task = new Task("Testtask", "This is a test Task.", LocalDate.parse("01.05.2022", formatter), 1);
|
Task task = new Task("Testtask", "This is a test Task.", LocalDate.parse("2022-05-01", formatter), 1);
|
||||||
try {
|
try {
|
||||||
testDatabase.saveTask(task);
|
testDatabase.saveTask(task);
|
||||||
List<Task> taskList = null;
|
List<Task> taskList;
|
||||||
try {
|
try {
|
||||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
|
||||||
LocalDate.parse("31.05.2022", formatter));
|
LocalDate.parse("2022-05-31", formatter));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -72,13 +75,13 @@ public class JsonTaskListTest {
|
|||||||
@Test
|
@Test
|
||||||
@DisplayName("Remove task.")
|
@DisplayName("Remove task.")
|
||||||
void removeTask() {
|
void removeTask() {
|
||||||
Task task = new Task("Dummy", "Dummy", LocalDate.parse("31.05.2022", formatter), 1).withId(2);
|
Task task = new Task("Dummy", "Dummy", LocalDate.parse("2022-05-31", formatter), 1).withId(2);
|
||||||
try {
|
try {
|
||||||
testDatabase.removeTask(task);
|
testDatabase.removeTask(task);
|
||||||
List<Task> taskList = null;
|
List<Task> taskList;
|
||||||
|
|
||||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
|
||||||
LocalDate.parse("31.05.2022", formatter));
|
LocalDate.parse("2022-05-31", formatter));
|
||||||
|
|
||||||
Assertions.assertEquals(2, taskList.size());
|
Assertions.assertEquals(2, taskList.size());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -90,7 +93,7 @@ public class JsonTaskListTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getTaskForCrop() {
|
void getTaskForCrop() {
|
||||||
List<Task> taskList = null;
|
List<Task> taskList;
|
||||||
try {
|
try {
|
||||||
taskList = testDatabase.getTaskForCrop(0);
|
taskList = testDatabase.getTaskForCrop(0);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -101,10 +104,10 @@ public class JsonTaskListTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Disabled until removing works")
|
|
||||||
@Test
|
@Test
|
||||||
void removeTasksForCrop() {
|
void removeTasksForCrop() {
|
||||||
List<Task> taskList = null;
|
List<Task> taskList;
|
||||||
try {
|
try {
|
||||||
testDatabase.removeTasksForCrop(0);
|
testDatabase.removeTasksForCrop(0);
|
||||||
taskList = testDatabase.getTaskForCrop(0);
|
taskList = testDatabase.getTaskForCrop(0);
|
||||||
@@ -114,4 +117,27 @@ public class JsonTaskListTest {
|
|||||||
|
|
||||||
Assertions.assertEquals(0, taskList.size());
|
Assertions.assertEquals(0, taskList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDefaultConstructor(){
|
||||||
|
JsonTaskList db = new JsonTaskList();
|
||||||
|
try {
|
||||||
|
assertNotNull(db.getTaskForCrop(0));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSubscription() {
|
||||||
|
TaskList.TaskListObserver mockObs = Mockito.mock(TaskList.TaskListObserver.class);
|
||||||
|
testDatabase.subscribe(mockObs);
|
||||||
|
try {
|
||||||
|
testDatabase.removeTasksForCrop(0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
verify(mockObs, times(1)).onChange(ArgumentMatchers.anyList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
public class GardenPlanModelTest {
|
public class GardenPlanModelTest {
|
||||||
private final URL dbDataSource = JsonCropList.class.getResource("user-crops.json");
|
private final URL dbDataSource = JsonCropListTest.class.getResource("test-user-crops.json");
|
||||||
private final URL testFile = JsonCropList.class.getResource("test-user-crops.json");
|
private final URL testFile = JsonCropListTest.class.getResource("template-user-crops.json");
|
||||||
|
|
||||||
CropList cropList;
|
CropList cropList;
|
||||||
List<Crop> exampleCrops;
|
List<Crop> exampleCrops;
|
||||||
@@ -55,8 +55,8 @@ public class GardenPlanModelTest {
|
|||||||
new GrowthPhase(MonthDay.of(2, 8), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
|
new GrowthPhase(MonthDay.of(2, 8), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
|
||||||
new GrowthPhase(MonthDay.of(10, 2), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())));
|
new GrowthPhase(MonthDay.of(10, 2), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())));
|
||||||
|
|
||||||
exampleCropOnion = new Crop(examplePlantOnion.id(), LocalDate.of(2023,3,1));
|
exampleCropOnion = new Crop(examplePlantOnion.id(), LocalDate.of(2023, 3, 1))
|
||||||
exampleCropOnion.withId(3);
|
.withId(3);
|
||||||
examplePlantCarrot = new Plant(
|
examplePlantCarrot = new Plant(
|
||||||
1,
|
1,
|
||||||
"Early Carrot",
|
"Early Carrot",
|
||||||
@@ -67,18 +67,18 @@ public class GardenPlanModelTest {
|
|||||||
"sandy to loamy, loose soil, free of stones",
|
"sandy to loamy, loose soil, free of stones",
|
||||||
new ArrayList<>(),
|
new ArrayList<>(),
|
||||||
List.of(new GrowthPhase(MonthDay.of(4, 4), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())));
|
List.of(new GrowthPhase(MonthDay.of(4, 4), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())));
|
||||||
exampleCropCarrot = new Crop(examplePlantCarrot.id(), LocalDate.now());
|
exampleCropCarrot = new Crop(examplePlantCarrot.id(), LocalDate.now())
|
||||||
exampleCropCarrot.withId(5);
|
.withId(5);
|
||||||
|
|
||||||
exampleCrop1 = new Crop(1, LocalDate.of(2023,2,25));
|
exampleCrop1 = new Crop(1, LocalDate.of(2023, 2, 25))
|
||||||
exampleCrop1.withId(0);
|
.withId(0)
|
||||||
exampleCrop1.withArea(0.5);
|
.withArea(0.5);
|
||||||
exampleCrop2 = new Crop(1,LocalDate.of(2023,3,1));
|
exampleCrop2 = new Crop(1, LocalDate.of(2023, 3, 1))
|
||||||
exampleCrop2.withId(1);
|
.withId(1)
|
||||||
exampleCrop2.withArea(0.5);
|
.withArea(0.5);
|
||||||
exampleCrop3 = new Crop(0,LocalDate.of(2023,3,1));
|
exampleCrop3 = new Crop(0, LocalDate.of(2023, 3, 1))
|
||||||
exampleCrop3.withId(2);
|
.withId(2)
|
||||||
exampleCrop3.withArea(1.0);
|
.withArea(1.0);
|
||||||
|
|
||||||
exampleCrops = new ArrayList<>();
|
exampleCrops = new ArrayList<>();
|
||||||
exampleCrops.add(exampleCrop1);
|
exampleCrops.add(exampleCrop1);
|
||||||
@@ -107,7 +107,7 @@ public class GardenPlanModelTest {
|
|||||||
@Test
|
@Test
|
||||||
void plantAsCrop() throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
|
void plantAsCrop() throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
|
||||||
|
|
||||||
model.plantAsCrop(examplePlantOnion, LocalDate.of(2023,3,1));
|
model.plantAsCrop(examplePlantOnion, LocalDate.of(2023, 3, 1));
|
||||||
Optional<Crop> exampleCrop = model.getCrop(2L);
|
Optional<Crop> exampleCrop = model.getCrop(2L);
|
||||||
assertTrue(exampleCrop.isPresent());
|
assertTrue(exampleCrop.isPresent());
|
||||||
assertEquals(model.getCrops().get(2), exampleCrop.get());
|
assertEquals(model.getCrops().get(2), exampleCrop.get());
|
||||||
@@ -119,6 +119,6 @@ public class GardenPlanModelTest {
|
|||||||
exampleCrop1.withId(2);
|
exampleCrop1.withId(2);
|
||||||
exampleCrop1.withArea(1.5);
|
exampleCrop1.withArea(1.5);
|
||||||
model.removeCrop(exampleCrop1);
|
model.removeCrop(exampleCrop1);
|
||||||
assertEquals(2,model.getCrops().size());
|
assertEquals(2, model.getCrops().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,49 @@
|
|||||||
package ch.zhaw.gartenverwaltung.taskList;
|
package ch.zhaw.gartenverwaltung.models;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.io.*;
|
import ch.zhaw.gartenverwaltung.io.*;
|
||||||
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
|
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
|
||||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
import ch.zhaw.gartenverwaltung.types.*;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.MonthDay;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
class GardenScheduleTest {
|
class GardenScheduleTest {
|
||||||
|
LocalDate exampleStartDate = LocalDate.of(2020, 2, 2);
|
||||||
TaskList taskList;
|
TaskList taskList;
|
||||||
PlantList plantList;
|
PlantList plantList;
|
||||||
|
List<Plant> examplePlantList;
|
||||||
List<Task> exampleTaskList;
|
List<Task> exampleTaskList;
|
||||||
Map<Long, Plant> examplePlantMap;
|
List<TaskTemplate> exampleTaskTemplateList;
|
||||||
GardenSchedule model;
|
GardenSchedule model;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() throws IOException {
|
void setUp() throws IOException, HardinessZoneNotSetException {
|
||||||
createExampleTaskList();
|
createExampleTaskList();
|
||||||
|
createExampleTaskTemplateList();
|
||||||
|
createExamplePlantList();
|
||||||
taskList = mockTaskDatabase(exampleTaskList);
|
taskList = mockTaskDatabase(exampleTaskList);
|
||||||
plantList = mockPlantDatabase(examplePlantMap);
|
plantList = mockPlantDatabase(examplePlantList);
|
||||||
model = new GardenSchedule(taskList, plantList);
|
model = new GardenSchedule(taskList, plantList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlantList mockPlantDatabase(List<Plant> plantList) throws HardinessZoneNotSetException, IOException {
|
||||||
|
PlantList plantDatabase = mock(JsonPlantList.class);
|
||||||
|
when(plantDatabase.getPlantList(HardinessZone.ZONE_8A)).thenReturn(plantList);
|
||||||
|
when(plantDatabase.getPlantById(HardinessZone.ZONE_8A,20)).thenReturn(Optional.of(examplePlantList.get(0)));
|
||||||
|
return plantDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
private TaskList mockTaskDatabase(List<Task> exampleTaskList) throws IOException {
|
private TaskList mockTaskDatabase(List<Task> exampleTaskList) throws IOException {
|
||||||
TaskList taskList = mock(JsonTaskList.class);
|
TaskList taskList = mock(JsonTaskList.class);
|
||||||
when(taskList.getTaskList(LocalDate.MIN, LocalDate.MAX)).thenReturn(exampleTaskList);
|
when(taskList.getTaskList(LocalDate.MIN, LocalDate.MAX)).thenReturn(exampleTaskList);
|
||||||
|
when(taskList.getTaskList(LocalDate.now(), LocalDate.now().plusDays(7 - 1))).thenReturn(exampleTaskList);
|
||||||
|
|
||||||
when(taskList.getTaskList(LocalDate.now(), LocalDate.MAX)).thenReturn((exampleTaskList.subList(1, 4)));
|
when(taskList.getTaskList(LocalDate.now(), LocalDate.MAX)).thenReturn((exampleTaskList.subList(1, 4)));
|
||||||
|
|
||||||
@@ -54,18 +65,39 @@ class GardenScheduleTest {
|
|||||||
return taskList;
|
return taskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlantList mockPlantDatabase(Map<Long, Plant> examplePlantMap) {
|
void createExampleTaskTemplateList(){
|
||||||
return new PlantList() {
|
exampleTaskTemplateList = new ArrayList<>();
|
||||||
@Override
|
exampleTaskTemplateList.add(mock(TaskTemplate.class));
|
||||||
public List<Plant> getPlantList(HardinessZone zone) {
|
exampleTaskTemplateList.add(mock(TaskTemplate.class));
|
||||||
return null;
|
exampleTaskTemplateList.add(mock(TaskTemplate.class));
|
||||||
}
|
exampleTaskTemplateList.add(mock(TaskTemplate.class));
|
||||||
|
when(exampleTaskTemplateList.get(0).generateTask(exampleStartDate, 30)).thenReturn(exampleTaskList.get(0));
|
||||||
|
when(exampleTaskTemplateList.get(1).generateTask(exampleStartDate, 30)).thenReturn(exampleTaskList.get(1));
|
||||||
|
when(exampleTaskTemplateList.get(2).generateTask(exampleStartDate, 30)).thenReturn(exampleTaskList.get(2));
|
||||||
|
when(exampleTaskTemplateList.get(3).generateTask(exampleStartDate, 30)).thenReturn(exampleTaskList.get(3));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
void createExamplePlantList(){
|
||||||
public Optional<Plant> getPlantById(HardinessZone zone, long id) {
|
examplePlantList = new ArrayList<>();
|
||||||
return Optional.ofNullable(examplePlantMap.get(id));
|
examplePlantList.add(new Plant(
|
||||||
}
|
20,
|
||||||
};
|
"summertime onion",
|
||||||
|
"Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
|
||||||
|
null,
|
||||||
|
"15,30,2",
|
||||||
|
0,
|
||||||
|
"sandy to loamy, loose soil, free of stones",
|
||||||
|
new ArrayList<>(),
|
||||||
|
List.of(
|
||||||
|
new GrowthPhase(MonthDay.of(6, 4), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.HARVEST, HardinessZone.ZONE_8A, List.of(
|
||||||
|
exampleTaskTemplateList.get(0),
|
||||||
|
exampleTaskTemplateList.get(1)
|
||||||
|
)),
|
||||||
|
new GrowthPhase(MonthDay.of(4, 3), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, List.of(
|
||||||
|
exampleTaskTemplateList.get(2),
|
||||||
|
exampleTaskTemplateList.get(3)
|
||||||
|
))
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void createExampleTaskList() {
|
void createExampleTaskList() {
|
||||||
@@ -74,15 +106,9 @@ class GardenScheduleTest {
|
|||||||
exampleTaskList.add(new Task("name", "description", LocalDate.now().plusDays(1), 2L));
|
exampleTaskList.add(new Task("name", "description", LocalDate.now().plusDays(1), 2L));
|
||||||
exampleTaskList.add(new Task("name", "description", LocalDate.now(), 1L));
|
exampleTaskList.add(new Task("name", "description", LocalDate.now(), 1L));
|
||||||
exampleTaskList.add(new Task("name", "description", LocalDate.of(9019, 5, 5), 1L));
|
exampleTaskList.add(new Task("name", "description", LocalDate.of(9019, 5, 5), 1L));
|
||||||
exampleTaskList.add(new Task("name", "description", LocalDate.of(2019, 5, 5), 2L));
|
exampleTaskList.add(new Task("name", "description", LocalDate.now().minusDays(10), LocalDate.now().plusDays(4),2, 2L));
|
||||||
}
|
}
|
||||||
|
|
||||||
void createExamplePlantMap() {
|
|
||||||
examplePlantMap = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void addTask() throws IOException {
|
void addTask() throws IOException {
|
||||||
Task taskToAdd = new Task("name", "description", LocalDate.now(), 1L);
|
Task taskToAdd = new Task("name", "description", LocalDate.now(), 1L);
|
||||||
@@ -132,19 +158,22 @@ class GardenScheduleTest {
|
|||||||
assertEquals(7, dayList.size());
|
assertEquals(7, dayList.size());
|
||||||
|
|
||||||
//Check day 0
|
//Check day 0
|
||||||
assertEquals(1, dayList.get(0).size());
|
assertEquals(2, dayList.get(0).size());
|
||||||
assertEquals(exampleTaskList.get(2), dayList.get(0).get(0));
|
assertTrue(dayList.get(0).contains(exampleTaskList.get(2)));
|
||||||
|
assertTrue(dayList.get(0).contains(exampleTaskList.get(4)));
|
||||||
|
|
||||||
//Check day 1
|
//Check day 1
|
||||||
assertEquals(1, dayList.get(1).size());
|
assertEquals(1, dayList.get(1).size());
|
||||||
assertEquals(exampleTaskList.get(1), dayList.get(1).get(0));
|
assertTrue(dayList.get(1).contains(exampleTaskList.get(1)));
|
||||||
|
|
||||||
//Check day 2
|
//Check day 2
|
||||||
assertEquals(0, dayList.get(2).size());
|
assertEquals(1, dayList.get(2).size());
|
||||||
|
assertTrue(dayList.get(2).contains(exampleTaskList.get(4)));
|
||||||
//Check day 3
|
//Check day 3
|
||||||
assertEquals(0, dayList.get(3).size());
|
assertEquals(0, dayList.get(3).size());
|
||||||
//Check day 4
|
//Check day 4
|
||||||
assertEquals(0, dayList.get(4).size());
|
assertEquals(1, dayList.get(4).size());
|
||||||
|
assertTrue(dayList.get(4).contains(exampleTaskList.get(4)));
|
||||||
//Check day 5
|
//Check day 5
|
||||||
assertEquals(0, dayList.get(5).size());
|
assertEquals(0, dayList.get(5).size());
|
||||||
//Check day 6
|
//Check day 6
|
||||||
@@ -156,4 +185,18 @@ class GardenScheduleTest {
|
|||||||
model.removeTasksForCrop(1L);
|
model.removeTasksForCrop(1L);
|
||||||
verify(taskList, times(1)).removeTasksForCrop(1L);
|
verify(taskList, times(1)).removeTasksForCrop(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void planTasksForCrop() throws HardinessZoneNotSetException, PlantNotFoundException, IOException {
|
||||||
|
assertThrows(PlantNotFoundException.class,()-> model.planTasksForCrop(new Crop()));
|
||||||
|
model.planTasksForCrop(new Crop(20, exampleStartDate).withId(30));
|
||||||
|
verify(exampleTaskTemplateList.get(0), times(1)).generateTask(exampleStartDate, 30);
|
||||||
|
verify(exampleTaskTemplateList.get(1), times(1)).generateTask(exampleStartDate, 30);
|
||||||
|
verify(exampleTaskTemplateList.get(2), times(1)).generateTask(exampleStartDate, 30);
|
||||||
|
verify(exampleTaskTemplateList.get(3), times(1)).generateTask(exampleStartDate, 30);
|
||||||
|
verify(taskList, times(1)).saveTask(exampleTaskList.get(0));
|
||||||
|
verify(taskList, times(1)).saveTask(exampleTaskList.get(1));
|
||||||
|
verify(taskList, times(1)).saveTask(exampleTaskList.get(2));
|
||||||
|
verify(taskList, times(1)).saveTask(exampleTaskList.get(3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package ch.zhaw.gartenverwaltung.types;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.MonthDay;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class PlantTest {
|
||||||
|
|
||||||
|
Plant testPlant;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
List<GrowthPhase> growthPhases = new ArrayList<>();
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(2, 1), MonthDay.of(4, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.SOW, HardinessZone.ZONE_8A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(4, 2), MonthDay.of(6, 5), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(6, 3), MonthDay.of(8, 6), 0, new WateringCycle(0, 0, null), GrowthPhaseType.HARVEST, HardinessZone.ZONE_8A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(3, 1), MonthDay.of(5, 4), 1, new WateringCycle(0, 0, null), GrowthPhaseType.SOW, HardinessZone.ZONE_8A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(5, 2), MonthDay.of(7, 5), 1, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(7, 3), MonthDay.of(9, 6), 1, new WateringCycle(0, 0, null), GrowthPhaseType.HARVEST, HardinessZone.ZONE_8A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(4, 1), MonthDay.of(6, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.SOW, HardinessZone.ZONE_1A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(6, 2), MonthDay.of(8, 5), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_1A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(7, 2), MonthDay.of(9, 5), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_1A, new ArrayList<>()));
|
||||||
|
growthPhases.add(new GrowthPhase(MonthDay.of(8, 3), MonthDay.of(10, 6), 0, new WateringCycle(0, 0, null), GrowthPhaseType.HARVEST, HardinessZone.ZONE_1A, new ArrayList<>()));
|
||||||
|
|
||||||
|
testPlant = new Plant(
|
||||||
|
20,
|
||||||
|
"summertime onion",
|
||||||
|
"Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
|
||||||
|
null,
|
||||||
|
"15,30,2",
|
||||||
|
0,
|
||||||
|
"sandy to loamy, loose soil, free of stones",
|
||||||
|
new ArrayList<>(),
|
||||||
|
growthPhases);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void tearDown() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void inZone() {
|
||||||
|
assertEquals(7,testPlant.lifecycleForGroup(0).size());
|
||||||
|
testPlant.inZone(HardinessZone.ZONE_8A);
|
||||||
|
assertEquals(3,testPlant.lifecycleForGroup(0).size());
|
||||||
|
assertEquals(Arrays.asList(3,5,7),testPlant.lifecycleForGroup(1).stream().map(gp ->gp.startDate().getMonthValue()).toList() );
|
||||||
|
testPlant.inZone(HardinessZone.ZONE_1A);
|
||||||
|
assertEquals(0,testPlant.lifecycleForGroup(0).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void lifecycleForGroup() {
|
||||||
|
assertEquals(Arrays.asList(2,4,6,4,6,7,8),testPlant.lifecycleForGroup(0).stream().map(gp ->gp.startDate().getMonthValue()).toList() );
|
||||||
|
assertEquals(Arrays.asList(3,5,7),testPlant.lifecycleForGroup(1).stream().map(gp ->gp.startDate().getMonthValue()).toList() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sowDateFromHarvestDate() {
|
||||||
|
assertEquals(LocalDate.of(2022,8,1),
|
||||||
|
testPlant.sowDateFromHarvestDate(LocalDate.of(2022,12,1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void timeToHarvest() {
|
||||||
|
testPlant.inZone(HardinessZone.ZONE_8A);
|
||||||
|
assertEquals(122,testPlant.timeToHarvest(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void lifecycleGroupFromHarvestDate() {
|
||||||
|
testPlant.inZone(HardinessZone.ZONE_8A);
|
||||||
|
assertEquals(0,testPlant.lifecycleGroupFromHarvestDate(LocalDate.of(2022,6,30)));
|
||||||
|
assertEquals(1,testPlant.lifecycleGroupFromHarvestDate(LocalDate.of(2022,8,30)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isDateInPhase() {
|
||||||
|
assertTrue(testPlant.isDateInPhase(LocalDate.of(2022,6,30),GrowthPhaseType.HARVEST));
|
||||||
|
assertTrue(testPlant.isDateInPhase(LocalDate.of(2022,8,30),GrowthPhaseType.HARVEST));
|
||||||
|
assertTrue(testPlant.isDateInPhase(LocalDate.of(2022,2,1),GrowthPhaseType.SOW));
|
||||||
|
assertTrue(testPlant.isDateInPhase(LocalDate.of(2022,4,2),GrowthPhaseType.PLANT));
|
||||||
|
assertFalse(testPlant.isDateInPhase(LocalDate.of(2022,6,30),GrowthPhaseType.SOW));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package ch.zhaw.gartenverwaltung.types;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.MonthDay;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class SeasonsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getStartDate() {
|
||||||
|
assertEquals(MonthDay.of(1,1), Seasons.ALLSEASONS.getStartDate());
|
||||||
|
assertEquals(MonthDay.of(3,1), Seasons.SPRING.getStartDate());
|
||||||
|
assertEquals(MonthDay.of(6,1), Seasons.SUMMER.getStartDate());
|
||||||
|
assertEquals(MonthDay.of(9,1), Seasons.AUTUMN.getStartDate());
|
||||||
|
assertEquals(MonthDay.of(12,1), Seasons.WINTER.getStartDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getEndDate() {
|
||||||
|
assertEquals(MonthDay.of(12,31), Seasons.ALLSEASONS.getEndDate());
|
||||||
|
assertEquals(MonthDay.of(5,30), Seasons.SPRING.getEndDate());
|
||||||
|
assertEquals(MonthDay.of(8,30), Seasons.SUMMER.getEndDate());
|
||||||
|
assertEquals(MonthDay.of(11,30), Seasons.AUTUMN.getEndDate());
|
||||||
|
assertEquals(MonthDay.of(2,28), Seasons.WINTER.getEndDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getName() {
|
||||||
|
assertEquals("All Seasons", Seasons.ALLSEASONS.getName());
|
||||||
|
assertEquals("Spring", Seasons.SPRING.getName());
|
||||||
|
assertEquals("Summer", Seasons.SUMMER.getName());
|
||||||
|
assertEquals("Autumn", Seasons.AUTUMN.getName());
|
||||||
|
assertEquals("Winter", Seasons.WINTER.getName());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,257 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"id": 0,
|
|
||||||
"name": "Potato",
|
|
||||||
"description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.",
|
|
||||||
"light": 6,
|
|
||||||
"spacing": "35",
|
|
||||||
"soil": "sandy",
|
|
||||||
"image": "potato.jpg",
|
|
||||||
"pests": [
|
|
||||||
{
|
|
||||||
"name": "Rot",
|
|
||||||
"description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
|
||||||
"measures": "Less water."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"lifecycle": [
|
|
||||||
{
|
|
||||||
"startDate": "03-10",
|
|
||||||
"endDate": "04-10",
|
|
||||||
"type": "SOW",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 0,
|
|
||||||
"interval": null,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "Germinate",
|
|
||||||
"relativeStartDate": -14,
|
|
||||||
"relativeEndDate": null,
|
|
||||||
"description": "\"Take an egg carton and fill it with soil. Put the seedling deep enaugh so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.\"",
|
|
||||||
"interval": null,
|
|
||||||
"isOptional": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "04-10",
|
|
||||||
"endDate": "07-10",
|
|
||||||
"type": "PLANT",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 25,
|
|
||||||
"interval": 7,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "hilling",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": null,
|
|
||||||
"description": "\"When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.\"",
|
|
||||||
"interval": 21,
|
|
||||||
"isOptional": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "06-10",
|
|
||||||
"endDate": "08-10",
|
|
||||||
"type": "HARVEST",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 0,
|
|
||||||
"interval": null,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "Harvest",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": null,
|
|
||||||
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
|
||||||
"interval": null,
|
|
||||||
"isOptional": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"name": "Early Carrot",
|
|
||||||
"description": "Carrot, (Daucus carota), herbaceous, generally biennial plant of the Apiaceae family that produces an edible taproot. Among common varieties root shapes range from globular to long, with lower ends blunt to pointed. Besides the orange-coloured roots, white-, yellow-, and purple-fleshed varieties are known.",
|
|
||||||
"image": "carrot.jpg",
|
|
||||||
"lifecycle": [
|
|
||||||
{
|
|
||||||
"startDate": "02-20",
|
|
||||||
"endDate": "03-10",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"type": "SOW",
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 15,
|
|
||||||
"interval": 3,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "hilling",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": 0,
|
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
|
||||||
"interval": null,
|
|
||||||
"isOptional": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "03-10",
|
|
||||||
"endDate": "05-10",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"type": "PLANT",
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 25,
|
|
||||||
"interval": 3,
|
|
||||||
"notes": [
|
|
||||||
"Be careful not to pour water over the leaves, as this will lead to sunburn."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "hilling",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": null,
|
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
|
||||||
"interval": 15,
|
|
||||||
"isOptional": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "05-10",
|
|
||||||
"endDate": "05-20",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"type": "HARVEST",
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 0,
|
|
||||||
"interval": null,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "Harvesting",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": 14,
|
|
||||||
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
|
||||||
"interval": null,
|
|
||||||
"isOptional": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"soil": "sandy to loamy, loose soil, free of stones",
|
|
||||||
"spacing": "5,35,2.5",
|
|
||||||
"pests": [
|
|
||||||
{
|
|
||||||
"name": "Rot",
|
|
||||||
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
|
||||||
"measures": "less water"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"name": "Summertime Onion",
|
|
||||||
"description": "Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
|
|
||||||
"image": "onion.jpg",
|
|
||||||
"lifecycle": [
|
|
||||||
{
|
|
||||||
"startDate": "03-15",
|
|
||||||
"endDate": "04-10",
|
|
||||||
"type": "SOW",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 15,
|
|
||||||
"interval": 4,
|
|
||||||
"notes": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "hilling",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": 0,
|
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
|
||||||
"interval": null,
|
|
||||||
"isOptional": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "04-10",
|
|
||||||
"endDate": "07-10",
|
|
||||||
"type": "PLANT",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 25,
|
|
||||||
"interval": 3,
|
|
||||||
"notes": [
|
|
||||||
""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "hilling",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": null,
|
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
|
||||||
"interval": 15,
|
|
||||||
"isOptional": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "07-10",
|
|
||||||
"endDate": "09-20",
|
|
||||||
"type": "HARVEST",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 0,
|
|
||||||
"interval": null,
|
|
||||||
"notes": [
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "Harvesting",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": 14,
|
|
||||||
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
|
||||||
"interval": null,
|
|
||||||
"isOptional": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"soil": "sandy to loamy, loose soil, free of stones",
|
|
||||||
"spacing": "15,30,2",
|
|
||||||
"pests": [
|
|
||||||
{
|
|
||||||
"name": "Rot",
|
|
||||||
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
|
||||||
"measures": "less water"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"plantId": 1,
|
||||||
|
"startDate": "2023-02-25",
|
||||||
|
"area": 0.5
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id" : 1,
|
"id" : 1,
|
||||||
"name" : "sow plant",
|
"name" : "sow plant",
|
||||||
"description": "Plant the seeds, crops in de bed.",
|
"description": "Plant the seeds, crops in de bed.",
|
||||||
"startDate" : "2022-05-01",
|
"startDate" : "2022-05-01",
|
||||||
"endDate" : "2022-05-01",
|
"endDate" : "2022-05-01",
|
||||||
"interval" : 0,
|
"interval" : 0,
|
||||||
"cropId" : 0
|
"cropId" : 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"cropId": 0,
|
||||||
|
"plantId": 1,
|
||||||
|
"startDate": "2023-02-25",
|
||||||
|
"area": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cropId": 1,
|
||||||
|
"plantId": 1,
|
||||||
|
"startDate": "2023-03-01",
|
||||||
|
"area": 0.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cropId": 2,
|
||||||
|
"plantId": 0,
|
||||||
|
"startDate": "2023-03-25",
|
||||||
|
"area": 1.5
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -31,9 +31,8 @@
|
|||||||
"name": "Germinate",
|
"name": "Germinate",
|
||||||
"relativeStartDate": -14,
|
"relativeStartDate": -14,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "\"Take an egg carton and fill it with soil. Put the seedling deep enaugh so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.\"",
|
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -53,9 +52,8 @@
|
|||||||
"name": "hilling",
|
"name": "hilling",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "\"When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.\"",
|
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
||||||
"interval": 21,
|
"interval": 21
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -76,8 +74,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -94,6 +91,7 @@
|
|||||||
"endDate": "03-10",
|
"endDate": "03-10",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"type": "SOW",
|
"type": "SOW",
|
||||||
|
"group": 0,
|
||||||
"wateringCycle": {
|
"wateringCycle": {
|
||||||
"litersPerSqM": 15,
|
"litersPerSqM": 15,
|
||||||
"interval": 3,
|
"interval": 3,
|
||||||
@@ -105,8 +103,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 0,
|
"relativeEndDate": 0,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -115,6 +112,7 @@
|
|||||||
"endDate": "05-10",
|
"endDate": "05-10",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"type": "PLANT",
|
"type": "PLANT",
|
||||||
|
"group": 0,
|
||||||
"wateringCycle": {
|
"wateringCycle": {
|
||||||
"litersPerSqM": 25,
|
"litersPerSqM": 25,
|
||||||
"interval": 3,
|
"interval": 3,
|
||||||
@@ -128,8 +126,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": 15,
|
"interval": 15
|
||||||
"isOptional": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -138,6 +135,7 @@
|
|||||||
"endDate": "05-20",
|
"endDate": "05-20",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"type": "HARVEST",
|
"type": "HARVEST",
|
||||||
|
"group": 0,
|
||||||
"wateringCycle": {
|
"wateringCycle": {
|
||||||
"litersPerSqM": 0,
|
"litersPerSqM": 0,
|
||||||
"interval": null,
|
"interval": null,
|
||||||
@@ -149,8 +147,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 14,
|
"relativeEndDate": 14,
|
||||||
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -190,8 +187,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 0,
|
"relativeEndDate": 0,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -214,8 +210,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": 15,
|
"interval": 15
|
||||||
"isOptional": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -238,8 +233,7 @@
|
|||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 14,
|
"relativeEndDate": 14,
|
||||||
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
||||||
"interval": null,
|
"interval": null
|
||||||
"isOptional": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,56 +1,2 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"id" : 1,
|
|
||||||
"name" : "sow plant",
|
|
||||||
"description": "Plant the seeds, crops in de bed.",
|
|
||||||
"startDate" : "2022-05-01",
|
|
||||||
"endDate" : "2022-05-01",
|
|
||||||
"interval" : 0,
|
|
||||||
"cropId" : 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 2,
|
|
||||||
"name" : "water plant",
|
|
||||||
"description": "water the plant, so that the soil is wet around the plant.",
|
|
||||||
"startDate" : "2022-05-01",
|
|
||||||
"endDate" : "2022-09-01",
|
|
||||||
"interval" : 2,
|
|
||||||
"cropId" : 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 3,
|
|
||||||
"name" : "fertilize plant",
|
|
||||||
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
|
||||||
"startDate" : "2022-06-01",
|
|
||||||
"endDate" : "2022-08-01",
|
|
||||||
"interval" : 28,
|
|
||||||
"cropId" : 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 4,
|
|
||||||
"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",
|
|
||||||
"endDate" : "2022-07-01",
|
|
||||||
"interval" : 0,
|
|
||||||
"cropId" : 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 5,
|
|
||||||
"name" : "look after plant",
|
|
||||||
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
|
||||||
"startDate" : "2022-05-01",
|
|
||||||
"endDate" : "2022-09-01",
|
|
||||||
"interval" : 5,
|
|
||||||
"cropId" : 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id" : 6,
|
|
||||||
"name" : "harvest plant",
|
|
||||||
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
|
||||||
"startDate" : "2022-09-01",
|
|
||||||
"endDate" : "2022-09-01",
|
|
||||||
"interval" : 0,
|
|
||||||
"cropId" : 0
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
@@ -1,20 +1,2 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"cropId": 0,
|
|
||||||
"plantId": 1,
|
|
||||||
"startDate": "2023-02-25",
|
|
||||||
"area": 0.5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cropId": 1,
|
|
||||||
"plantId": 1,
|
|
||||||
"startDate": "2023-03-01",
|
|
||||||
"area": 0.5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cropId": 2,
|
|
||||||
"plantId": 0,
|
|
||||||
"startDate": "2023-03-25",
|
|
||||||
"area": 1.5
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
[
|
|
||||||
]
|
|
||||||