Merge pull request #71 from schrom01/feature_guiOverhaul_M3

Feature_OverhaulGUI_Scheduler_M3
This commit is contained in:
gulerdav 2022-11-28 11:58:26 +01:00 committed by GitHub Enterprise
commit 2452e42b72
15 changed files with 314 additions and 165 deletions

View File

@ -22,6 +22,7 @@ import javafx.scene.control.*;
import javafx.scene.image.Image; 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.Pane;
import javafx.scene.layout.Priority; import javafx.scene.layout.Priority;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -87,7 +88,7 @@ public class CropDetailController {
private ListView<Pest> pests_listView; private ListView<Pest> pests_listView;
@FXML @FXML
void addTask() throws IOException { void addTask() throws IOException, HardinessZoneNotSetException {
createTaskDialog(true, null); createTaskDialog(true, null);
} }
@ -136,7 +137,7 @@ public class CropDetailController {
if (plant.image() != null) { if (plant.image() != null) {
imageView.setImage(plant.image()); imageView.setImage(plant.image());
} }
area_label.setText(""); area_label.setText(String.valueOf(crop.getArea()));
location_label.setText(""); location_label.setText("");
setTaskListProperty(crop); setTaskListProperty(crop);
@ -205,22 +206,28 @@ public class CropDetailController {
} }
private HBox createTaskHBox(Task task) { private HBox createTaskHBox(Task task) {
HBox hBox = new HBox(); HBox hBox = new HBox(10);
Label taskName = new Label(task.getName()+": "); Label taskName = new Label(task.getName()+": ");
taskName.setMinWidth(100);
taskName.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
taskName.setStyle("-fx-font-weight: bold"); taskName.setStyle("-fx-font-weight: bold");
Label taskDescription = new Label(task.getDescription()); Label taskDescription = new Label(task.getDescription());
taskDescription.setWrapText(true); taskDescription.setWrapText(true);
taskDescription.setMaxWidth(2000); taskDescription.setMaxSize(600, Double.MAX_VALUE);
HBox.setHgrow(taskDescription, Priority.ALWAYS); Pane puffer = new Pane();
HBox.setHgrow(puffer, Priority.ALWAYS);
Button edit = new Button(); Button edit = new Button();
Button delete = new Button(); Button delete = new Button();
HBox.setHgrow(edit, Priority.NEVER);
HBox.setHgrow(delete, Priority.NEVER);
setIconToButton(edit, "editIcon.png"); setIconToButton(edit, "editIcon.png");
setIconToButton(delete, "deleteIcon.png"); setIconToButton(delete, "deleteIcon.png");
edit.setOnAction(getEditTaskEvent(task)); edit.setOnAction(getEditTaskEvent(task));
delete.setOnAction(deleteTask(task)); delete.setOnAction(deleteTask(task));
hBox.getChildren().addAll(taskName, taskDescription, edit, delete); hBox.getChildren().addAll(taskName, taskDescription, puffer, edit, delete);
return hBox; return hBox;
} }
@ -229,12 +236,15 @@ public class CropDetailController {
label.setStyle("-fx-font-weight: bold"); label.setStyle("-fx-font-weight: bold");
HBox hBox = new HBox(); HBox hBox = new HBox();
hBox.fillHeightProperty(); hBox.fillHeightProperty();
Label label1 = new Label(pest.description()); Label description = new Label(pest.description());
label1.setAlignment(Pos.TOP_LEFT); description.setAlignment(Pos.TOP_LEFT);
label1.setWrapText(true); description.setWrapText(true);
label1.setMaxWidth(600); description.setMaxWidth(600);
Pane puffer = new Pane();
HBox.setHgrow(puffer, Priority.ALWAYS);
Button button = new Button("Get Counter Measures"); Button button = new Button("Get Counter Measures");
hBox.getChildren().addAll(label, label1, button); HBox.setHgrow(button, Priority.NEVER);
hBox.getChildren().addAll(label, description, puffer, button);
return hBox; return hBox;
} }
@ -255,7 +265,7 @@ public class CropDetailController {
return (event) -> { return (event) -> {
try { try {
createTaskDialog(false, task); createTaskDialog(false, task);
} catch (IOException e) { } catch (IOException | HardinessZoneNotSetException e) {
e.printStackTrace(); e.printStackTrace();
} }
}; };
@ -267,7 +277,7 @@ public class CropDetailController {
}; };
} }
private void createTaskDialog(boolean newTask, Task givenTask) throws IOException { private void createTaskDialog(boolean newTask, Task givenTask) throws IOException, HardinessZoneNotSetException {
Dialog<Task> dialog = new Dialog<>(); Dialog<Task> dialog = new Dialog<>();
dialog.setTitle("Set Task"); dialog.setTitle("Set Task");
dialog.setHeaderText("Add/Edit Task:"); dialog.setHeaderText("Add/Edit Task:");
@ -289,7 +299,7 @@ public class CropDetailController {
if (!newTask) { if (!newTask) {
controller.setTaskValue(givenTask); controller.setTaskValue(givenTask);
} }
dialog.setResultConverter(button -> button.equals(saveTask) ? controller.returnResult() : null); dialog.setResultConverter(button -> button.equals(saveTask) ? controller.returnResult(this.crop) : null);
dialog.showAndWait() dialog.showAndWait()
.ifPresent(task -> { .ifPresent(task -> {
@ -334,8 +344,11 @@ public class CropDetailController {
//ToDo method to set location //ToDo method to set location
location_label.setText(string); location_label.setText(string);
} else { } else {
System.out.println(string); try {
//ToDo method to set area of crop in garden garden.updateCrop(this.crop.withArea(Double.parseDouble(string)));
} catch (IOException e) {
e.printStackTrace();
}
area_label.setText(string); area_label.setText(string);
} }
}); });

View File

@ -51,7 +51,6 @@ public class MyGardenController {
@AfterInject @AfterInject
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void init() { public void init() {
System.out.println("once");
setIconToButton(addPlant_button, "addIcon.png"); setIconToButton(addPlant_button, "addIcon.png");
myGarden_listView.itemsProperty().bind(garden.getPlantedCrops()); myGarden_listView.itemsProperty().bind(garden.getPlantedCrops());
setCellFactory(); setCellFactory();

View File

@ -9,11 +9,14 @@ import ch.zhaw.gartenverwaltung.models.GardenSchedule;
import ch.zhaw.gartenverwaltung.types.Crop; import ch.zhaw.gartenverwaltung.types.Crop;
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.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;
@ -24,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;
@ -35,46 +39,7 @@ public class MyScheduleController {
private PlantList plantList; private PlantList plantList;
@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;
@ -85,10 +50,11 @@ public class MyScheduleController {
@AfterInject @AfterInject
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void init() { public void init() {
setCellFactoryListView(); setCellFactoryCropListView();
setCellFactoryTaskListView();
scheduledPlants_listview.itemsProperty().bind(garden.getPlantedCrops()); scheduledPlants_listview.itemsProperty().bind(garden.getPlantedCrops());
week_listView.itemsProperty().bind(taskListProperty);
lookForSelectedListEntries(); lookForSelectedListEntries();
setDayLabels();
information_label.setText(""); information_label.setText("");
try { try {
loadTaskList(); loadTaskList();
@ -108,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) {
@ -141,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) {
@ -148,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);
}
});
} }

View File

@ -1,23 +1,35 @@
package ch.zhaw.gartenverwaltung; 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.Crop;
import ch.zhaw.gartenverwaltung.types.Plant;
import ch.zhaw.gartenverwaltung.types.Task; import ch.zhaw.gartenverwaltung.types.Task;
import javafx.beans.binding.Binding;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.util.Callback; import javafx.util.Callback;
import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class TaskFormularController implements Initializable { public class TaskFormularController implements Initializable {
private Crop crop; private Crop crop;
private Plant plant;
private Task task = null;
@Inject
private GardenSchedule gardenSchedule;
@Inject
private Garden garden;
@Inject
private PlantList plantList;
@FXML @FXML
private TextArea description_area; private TextArea description_area;
@ -34,19 +46,28 @@ public class TaskFormularController implements Initializable {
@FXML @FXML
private TextField taskName_field; private TextField taskName_field;
@AfterInject
@SuppressWarnings("unused")
public Task returnResult() { 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(), Task task = new Task(taskName_field.getText(), description_area.getText(),
start_datePicker.getValue(), end_datePicker.getValue(), start_datePicker.getValue(), end_datePicker.getValue(),
Integer.parseInt(interval_field.getText()), crop.getCropId().get()); interval, crop.getCropId().get());
if (this.task != null) return this.task.updateTask(task);
return task; return task;
} }
public void setCorp(Crop crop) { public void setCorp(Crop crop) throws HardinessZoneNotSetException, IOException {
this.crop = crop; this.crop = crop;
this.plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
} }
public void setTaskValue(Task task) { public void setTaskValue(Task task) {
this.task = task;
taskName_field.setText(task.getName()); taskName_field.setText(task.getName());
description_area.setText(task.getDescription()); description_area.setText(task.getDescription());
start_datePicker.setValue(task.getStartDate()); start_datePicker.setValue(task.getStartDate());
@ -69,7 +90,7 @@ public class TaskFormularController implements Initializable {
setDisable(true); setDisable(true);
setStyle("-fx-background-color: #ffc0cb;"); setStyle("-fx-background-color: #ffc0cb;");
if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0) { if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0 && item.compareTo(crop.getStartDate().plusDays(plant.timeToHarvest(0))) < 0) {
setDisable(false); setDisable(false);
setStyle("-fx-background-color: #32CD32;"); setStyle("-fx-background-color: #32CD32;");
} }
@ -93,7 +114,7 @@ public class TaskFormularController implements Initializable {
setDisable(true); setDisable(true);
setStyle("-fx-background-color: #ffc0cb;"); setStyle("-fx-background-color: #ffc0cb;");
if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0) { if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0 && item.compareTo(crop.getStartDate().plusDays(plant.timeToHarvest(0))) < 0) {
setDisable(false); setDisable(false);
setStyle("-fx-background-color: #32CD32;"); setStyle("-fx-background-color: #32CD32;");
} }
@ -114,12 +135,8 @@ public class TaskFormularController implements Initializable {
}); });
button.disableProperty().bind(start_datePicker.valueProperty().isNull() button.disableProperty().bind(start_datePicker.valueProperty().isNull()
.or(end_datePicker.valueProperty().isNull())
.or(taskName_field.textProperty().isEmpty()) .or(taskName_field.textProperty().isEmpty())
.or(description_area.textProperty().isEmpty()) .or(description_area.textProperty().isEmpty()));
.or(interval_field.textProperty().isEmpty()));
} }
@Override @Override

View File

@ -27,6 +27,15 @@ public class TextFieldFormularController {
} }
public void initSaveButton(Button button) { 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()); button.disableProperty().bind(text_area.textProperty().isEmpty());
} }
} }

View File

@ -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.
* *

View File

@ -152,7 +152,7 @@ public class GardenSchedule {
dayTaskList.get(finalI).add(task); dayTaskList.get(finalI).add(task);
} }
checkDate = checkDate.plusDays(task.getInterval().orElse(0)); checkDate = checkDate.plusDays(task.getInterval().orElse(0));
} while (task.getInterval().isPresent() && checkDate.isBefore(LocalDate.now().plusDays(listLength))); } while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength)));
}); });
} }
return dayTaskList; return dayTaskList;

View File

@ -10,14 +10,15 @@ import java.util.Optional;
*/ */
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 nextExecution;
private LocalDate nextNotification; private LocalDate nextNotification;
private long cropId; private long cropId;
private boolean done;
/** /**
* default constructor * default constructor
@ -69,7 +70,7 @@ public class Task {
} }
public void done(){ public void done(){
if(interval != null && !nextExecution.plusDays(interval).isAfter(endDate)){ if(interval != null && interval != 0 && !nextExecution.plusDays(interval).isAfter(endDate)){
nextExecution = nextExecution.plusDays(interval); nextExecution = nextExecution.plusDays(interval);
} else { } else {
nextExecution = null; nextExecution = null;
@ -103,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;
}
} }

View File

@ -42,7 +42,7 @@ public class TaskTemplate {
} }
public Task generateTask(LocalDate realStartDate, long cropId) { public Task generateTask(LocalDate realStartDate, long cropId) {
LocalDate endDate = relativeEndDate != null ? realStartDate.plusDays(relativeEndDate) : null; LocalDate endDate = relativeEndDate != null ? realStartDate.plusDays(relativeEndDate) : realStartDate;
if (interval == null) { if (interval == null) {
this.interval = 0; this.interval = 0;

View File

@ -107,7 +107,7 @@
<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>
@ -125,7 +125,7 @@
<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>

View File

@ -7,14 +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="40.0" HBox.hgrow="NEVER" /> <Button fx:id="home_button" mnemonicParsing="false" onAction="#goToHome" prefHeight="38.0" prefWidth="38.0" HBox.hgrow="NEVER" />
<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" />
<Button fx:id="tutorial_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#showTutorial" prefHeight="38.0" prefWidth="121.0" text="Tutorial" /> <Button fx:id="tutorial_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#showTutorial" prefHeight="38.0" prefWidth="121.0" text="Tutorial" />
<Pane maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" /> <Pane fx:id="menu_pane" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
<Button fx:id="settings_button" maxHeight="1.7976931348623157E308" mnemonicParsing="false" onAction="#openSettings" prefHeight="38.0" prefWidth="40.0" HBox.hgrow="NEVER" /> <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" />

View File

@ -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>

View File

@ -9,9 +9,7 @@
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?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">
<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> <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"> <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> <padding>
@ -27,7 +25,7 @@
<HBox prefHeight="77.0" prefWidth="350.0"> <HBox prefHeight="77.0" prefWidth="350.0">
<children> <children>
<Label maxWidth="1.7976931348623157E308" text="Description:" HBox.hgrow="ALWAYS" /> <Label maxWidth="1.7976931348623157E308" text="Description:" HBox.hgrow="ALWAYS" />
<TextArea fx:id="description_area" prefHeight="73.0" prefWidth="206.0" promptText="Description" /> <TextArea fx:id="description_area" prefHeight="73.0" prefWidth="206.0" promptText="Description" wrapText="true" />
</children> </children>
</HBox> </HBox>
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0"> <HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0">

View File

@ -1,6 +1,25 @@
.button{ /*
-fx-text-fill: rgb(49, 89, 23);
-fx-border-color: rgb(49, 89, 23); #home_button, #myGarden_button,
-fx-border-radius: 5; #mySchedule_button, #settings_button,
-fx-padding: 3 6 6 6; #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%);
}./

View File

@ -245,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
}
]
}
]
} }
] ]