Compare commits

...

8 Commits

Author SHA1 Message Date
Elias Csomor 56020a7529 Setup Platform for runLater in GardenSchedule
Otherwise Test planTaskForCrop crashes due to unitialized Platform
2022-12-09 17:35:41 +01:00
Elias Csomor 5830ee5180 fixing execution and notification dates in test db 2022-12-09 17:13:05 +01:00
David Guler b3c7dd67e8 fix: remove "done" field from json serialisation 2022-12-09 15:27:21 +01:00
giavaphi 59c5d4be5a Merge pull request #80 from schrom01/feature_guiOverhaul_M3
css style update
2022-12-09 14:20:02 +01:00
giavaphi 035f5d7fcd Merge pull request #79 from schrom01/feature_updaeTaskListViewOnUpdate_M3
update tasks with subscription from JsonTaskList
2022-12-09 14:18:56 +01:00
giavaphi 4d2057d0df fix update scheduler 2022-12-09 14:16:12 +01:00
giavaphi f54b39b1f2 updated style 2022-12-09 06:59:37 +01:00
giavaphi 45035e565c update tasks with subscription from JsonTaskList 2022-12-09 01:27:37 +01:00
24 changed files with 321 additions and 72 deletions

View File

@ -3,6 +3,7 @@ package ch.zhaw.gartenverwaltung;
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
import ch.zhaw.gartenverwaltung.io.PlantList;
import ch.zhaw.gartenverwaltung.io.TaskList;
import ch.zhaw.gartenverwaltung.models.Garden;
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
@ -28,6 +29,7 @@ import javafx.stage.Stage;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -128,7 +130,14 @@ public class CropDetailController {
}
area_label.setText(String.valueOf(crop.getArea()));
setTaskListProperty(crop);
initializeTaskListProperty(crop);
TaskList.TaskListObserver taskListObserver = newTaskList -> {
taskListProperty.clear();
taskListProperty.addAll(gardenSchedule.getTaskListForCrop(crop.getCropId().get()));
};
gardenSchedule.setTaskListObserver(taskListObserver);
taskList_listView.itemsProperty().bind(taskListProperty);
pestListProperty.addAll(plant.pests());
@ -185,10 +194,10 @@ public class CropDetailController {
}
/**
* update task list
* initialize task list
* @param crop {@link Crop} that is selected
*/
private void setTaskListProperty(Crop crop) {
private void initializeTaskListProperty(Crop crop) {
crop.getCropId().ifPresent(id -> {
List<Task> taskList;
try {
@ -222,6 +231,8 @@ public class CropDetailController {
Button edit = new Button();
Button delete = new Button();
edit.getStyleClass().add("button-class");
delete.getStyleClass().add("button-class");
HBox.setHgrow(edit, Priority.NEVER);
HBox.setHgrow(delete, Priority.NEVER);
setIconToButton(edit, "editIcon.png");
@ -305,6 +316,10 @@ public class CropDetailController {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType saveTask;
if(newTask) {
saveTask = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
@ -326,13 +341,15 @@ public class CropDetailController {
if (newTask) {
try {
gardenSchedule.addTask(task);
setTaskListProperty(this.crop);
} catch (IOException e) {
e.printStackTrace();
}
} else {
//ToDo method to edit task
setTaskListProperty(this.crop);
try {
gardenSchedule.addTask(givenTask.updateTask(task));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
@ -351,6 +368,10 @@ public class CropDetailController {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(save, ButtonType.CANCEL);
@ -382,12 +403,18 @@ public class CropDetailController {
alert.setTitle("Delete " + task.getName());
alert.setHeaderText("Are you sure want to delete this Task?");
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
alert.showAndWait()
.ifPresent(buttonType -> {
if (buttonType == ButtonType.OK) {
try {
gardenSchedule.removeTask(task);
setTaskListProperty(this.crop);
//setTaskListProperty(this.crop);
} catch (IOException e) {
// TODO: Show error alert
LOG.log(Level.SEVERE, "Could not remove crop.", e);

View File

@ -22,13 +22,14 @@ public class Main extends Application {
AppLoader appLoader = new AppLoader();
backgroundTasks = new BackgroundTasks((TaskList) appLoader.getAppDependency(TaskList.class),(CropList) appLoader.getAppDependency(CropList.class), (PlantList) appLoader.getAppDependency(PlantList.class));
// TODO reduce period
backGroundTaskTimer.scheduleAtFixedRate(backgroundTasks, 0, 1000);
appLoader.loadSceneToStage("MainFXML.fxml", stage);
stage.setTitle("Gartenverwaltung");
stage.show();
backGroundTaskTimer.scheduleAtFixedRate(backgroundTasks, 0, 60000);
}
@Override

View File

@ -16,6 +16,7 @@ import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import java.io.IOException;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -89,6 +90,10 @@ public class MainFXMLController {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType saveSettings = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(saveSettings, ButtonType.CANCEL);
@ -156,7 +161,12 @@ public class MainFXMLController {
}
private void styleChangeButton(Button button) {
//ToDo changeStyle of the menu buttons
/*home_button.setStyle("-fx-background-color: rgb(0,128,0)");
myGarden_button.setStyle("-fx-background-color: rgb(0,128,0)");
mySchedule_button.setStyle("-fx-background-color: rgb(0,128,0)");
settings_button.setStyle("-fx-background-color: rgb(0,128,0)");
tutorial_button.setStyle("-fx-background-color: rgb(0,128,0)");
button.setStyle("-fx-background-color: darkgreen");*/
}
/**

View File

@ -117,6 +117,9 @@ public class MyGardenController {
Button details = new Button();
Button delete = new Button();
details.getStyleClass().add("button-class");
delete.getStyleClass().add("button-class");
setIconToButton(details, "detailsIcon.png");
setIconToButton(delete, "deleteIcon.png");
details.setOnAction(getGoToCropDetailEvent(crop));
@ -186,6 +189,12 @@ public class MyGardenController {
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Delete " + plant.name());
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
alert.setHeaderText("Are you sure want to delete this Crop?");
alert.setContentText("Deleting this crop will remove all associated tasks from your schedule.");

View File

@ -32,7 +32,6 @@ import java.util.logging.Logger;
*/
public class MyScheduleController {
private static final Logger LOG = Logger.getLogger(MyScheduleController.class.getName());
private final ListProperty<List<Task>> taskListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private Crop selectedCrop = null;
@ -58,14 +57,10 @@ public class MyScheduleController {
setCellFactoryCropListView();
setCellFactoryTaskListView();
scheduledPlants_listview.itemsProperty().bind(garden.getPlantedCrops());
ListProperty<List<Task>> taskListProperty = gardenSchedule.getWeeklyTaskListProperty();
week_listView.itemsProperty().bind(taskListProperty);
lookForSelectedListEntries();
information_label.setText("");
try {
loadTaskList();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
@ -117,8 +112,8 @@ public class MyScheduleController {
super.updateItem(taskList, empty);
if (empty || taskList == null) {
setGraphic(null);
setText(null);
setGraphic(null);
} else {
setText("");
setGraphic(weekTaskVBox(taskList, this.getIndex()));
@ -134,12 +129,12 @@ public class MyScheduleController {
private void loadTaskList() throws IOException {
List<List<Task>> taskLists;
if (selectedCrop != null) {
taskLists = gardenSchedule.getTasksUpcomingWeekForCrop(selectedCrop.getCropId().get());
gardenSchedule.getTasksUpcomingWeekForCrop(selectedCrop.getCropId().get());
} else {
taskLists = gardenSchedule.getTasksUpcomingWeek();
gardenSchedule.getTasksUpcomingWeek();
}
taskListProperty.clear();
taskListProperty.addAll(taskLists);
//taskListProperty.clear();
//taskListProperty.addAll(taskLists);
}
/**
@ -169,6 +164,8 @@ public class MyScheduleController {
Pane puffer = new Pane();
HBox.setHgrow(puffer, Priority.ALWAYS);
Button button = new Button("Task completed!");
button.getStyleClass().add("button-class");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {

View File

@ -25,6 +25,7 @@ import javafx.scene.layout.VBox;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -82,6 +83,10 @@ public class PlantsController {
DialogPane dialogPane = dateSelection.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType sowButton = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(sowButton, ButtonType.CANCEL);

View File

@ -12,6 +12,7 @@ import javafx.scene.image.ImageView;
import java.io.IOException;
import java.net.URL;
import java.util.Objects;
import java.util.ResourceBundle;
/**
@ -91,6 +92,10 @@ public class SettingsController implements Initializable {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(save, ButtonType.CANCEL);

View File

@ -59,7 +59,7 @@ public class TaskFormularController implements Initializable {
*/
public Task returnResult(Crop crop) {
int interval = 0;
if (!(interval_field.getText().isEmpty() || interval_field.getText().equals(""))) {
if (interval_field.getText() != null && !(interval_field.getText().isEmpty() || interval_field.getText().equals(""))) {
interval = Integer.parseInt(interval_field.getText());
}
Task task = new Task(taskName_field.getText(), description_area.getText(),
@ -159,7 +159,7 @@ public class TaskFormularController implements Initializable {
*/
public void initSaveButton(Button button) {
interval_field.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("\\d*")) {
if (newValue != null && !newValue.matches("\\d*")) {
interval_field.setText(newValue.replaceAll("[^\\d]", ""));
}
});

View File

@ -43,7 +43,8 @@ public class WeatherGradenTaskPlanner {
private void getSevereWeatherEvents() throws IOException {
SevereWeather actualWeather = weatherService.causeSevereWeather(1);
if (SevereWeather.HAIL.equals(actualWeather)) {
createPreHailTask();
//ToDo creates hail task all 3 seconds, pls fix
//createPreHailTask();
} else if (SevereWeather.FROST.equals(actualWeather)) {
createPreFrostTask();
} else if (SevereWeather.SNOW.equals(actualWeather)) {

View File

@ -67,7 +67,7 @@ public class JsonTaskList implements TaskList {
* @see TaskList#getTaskList(LocalDate, LocalDate)
*/
@Override
public List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException{
public synchronized List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException{
if(taskMap.isEmpty()) {
loadTaskListFromFile();
}
@ -80,7 +80,7 @@ public class JsonTaskList implements TaskList {
* @return List of Tasks for given Crop
*/
@Override
public List<Task> getTaskForCrop(long cropId) throws IOException {
public synchronized List<Task> getTaskForCrop(long cropId) throws IOException {
if(taskMap.isEmpty()) {
loadTaskListFromFile();
}
@ -111,7 +111,7 @@ public class JsonTaskList implements TaskList {
* @see TaskList#saveTask(Task)
*/
@Override
public void saveTask(Task task) throws IOException {
public synchronized void saveTask(Task task) throws IOException {
if(taskMap.isEmpty()) {
loadTaskListFromFile();
}
@ -154,7 +154,7 @@ public class JsonTaskList implements TaskList {
/**
* Calls the change handler method on all registered observers.
*/
private void notifySubscribers() {
private void notifySubscribers() throws IOException {
for (TaskListObserver subscriber : subscribers) {
subscriber.onChange(taskMap.values().stream().toList());
}

View File

@ -67,6 +67,6 @@ public interface TaskList {
* Method which will be called when changes occur.
* @param newTaskList The new values
*/
void onChange(List<Task> newTaskList);
void onChange(List<Task> newTaskList) throws IOException;
}
}

View File

@ -3,6 +3,10 @@ package ch.zhaw.gartenverwaltung.models;
import ch.zhaw.gartenverwaltung.Settings;
import ch.zhaw.gartenverwaltung.io.*;
import ch.zhaw.gartenverwaltung.types.*;
import javafx.application.Platform;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import java.io.IOException;
import java.time.LocalDate;
@ -20,13 +24,36 @@ public class GardenSchedule {
*/
static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate);
static final Comparator<Task> sortByNextExecution = Comparator.comparing(Task::getNextExecution);
private final ListProperty<List<Task>> weeklyTaskListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
/**
* Constructor to create Database Objects.
*/
public GardenSchedule(TaskList taskList, PlantList plantList) {
public GardenSchedule(TaskList taskList, PlantList plantList) throws IOException {
this.taskList = taskList;
this.plantList = plantList;
TaskList.TaskListObserver taskListObserver = newTaskList -> {
Platform.runLater(() -> {
try {
getTasksUpcomingWeek();
} catch (IOException e) {
throw new RuntimeException(e);
}
});
};
setTaskListObserver(taskListObserver);
}
public ListProperty<List<Task>> getWeeklyTaskListProperty() {
return weeklyTaskListProperty;
}
/**
* subscribe task list observer to get notifications
* @param observer the task list which will be ovserved
*/
public void setTaskListObserver(TaskList.TaskListObserver observer) {
taskList.subscribe(observer);
}
/**
@ -163,18 +190,20 @@ public class GardenSchedule {
}
});
}
weeklyTaskListProperty.clear();
weeklyTaskListProperty.addAll(dayTaskList);
return dayTaskList;
}
/**
* Method to get an List of 7 Tasklists for the next 7 days. (Filtered Index 0 is Tasklist for Today.
* @return List with length 7 (List<List<Task>>)
* @throws IOException If the database cannot be accessed
*/
public List<List<Task>> getTasksUpcomingWeekForCrop(Long cropId) throws IOException {
public void getTasksUpcomingWeekForCrop(Long cropId) throws IOException {
List<List<Task>> dayTaskList = getTasksUpcomingWeek();
dayTaskList.forEach(taskList -> taskList.removeIf(task -> task.getCropId() != cropId));
return dayTaskList;
weeklyTaskListProperty.clear();
weeklyTaskListProperty.addAll(dayTaskList);
}
/**

View File

@ -1,5 +1,7 @@
package ch.zhaw.gartenverwaltung.types;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.time.LocalDate;
import java.util.Optional;
@ -105,7 +107,7 @@ public class Task {
* @return Whether the Task is within the given range
*/
public boolean isInTimePeriod(LocalDate searchStartDate, LocalDate searchEndDate) {
return endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate);
return endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate) || (nextExecution != null && nextExecution.isBefore(searchEndDate) && nextExecution.isAfter(searchStartDate));
}
/**
@ -121,6 +123,7 @@ public class Task {
}
}
@JsonIgnore
public boolean isDone(){
return nextExecution == null;
}

View File

@ -19,19 +19,19 @@
<content>
<VBox fx:id="cropDetailVBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="781.0" prefWidth="897.0" spacing="5.0">
<children>
<Button mnemonicParsing="false" onAction="#goBack" prefHeight="25.0" prefWidth="91.0" text="Go Back">
<Button styleClass="button-class" mnemonicParsing="false" onAction="#goBack" prefHeight="25.0" prefWidth="91.0" text="Go Back">
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Button>
<Label fx:id="cropName_label" text="Label">
<Label styleClass="page-title" fx:id="cropName_label" text="Label">
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Label>
<HBox maxHeight="1.7976931348623157E308" prefHeight="268.0" prefWidth="855.0" spacing="10.0" VBox.vgrow="NEVER">
<children>
<GridPane maxWidth="1.7976931348623157E308" prefHeight="231.0" prefWidth="555.0" HBox.hgrow="ALWAYS">
<GridPane styleClass="custom-container" maxWidth="1.7976931348623157E308" prefHeight="231.0" prefWidth="555.0" HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" maxWidth="284.0" minWidth="10.0" prefWidth="97.33334350585938" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="488.99999237060547" minWidth="10.0" prefWidth="481.9999898274739" />
@ -72,6 +72,9 @@
</GridPane.margin>
</Label>
</children>
<padding>
<Insets bottom="5.0" left="10.0" right="5.0" top="5.0" />
</padding>
</GridPane>
<ImageView fx:id="imageView" fitHeight="250.0" fitWidth="250.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
</children>
@ -86,7 +89,7 @@
<Insets bottom="10.0" />
</VBox.margin>
</ListView>
<Button fx:id="addTask_button" mnemonicParsing="false" onAction="#addTask" prefHeight="25.0" prefWidth="45.0" VBox.vgrow="NEVER">
<Button styleClass="button-class" fx:id="addTask_button" mnemonicParsing="false" onAction="#addTask" prefHeight="25.0" prefWidth="45.0" VBox.vgrow="NEVER">
<VBox.margin>
<Insets />
</VBox.margin>
@ -109,7 +112,7 @@
<Insets right="10.0" />
</HBox.margin>
</Label>
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Set Area" />
<Button styleClass="button-class" fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Set Area" />
</children>
<VBox.margin>
<Insets />

View File

@ -18,7 +18,7 @@
<content>
<VBox fx:id="homeVBox" prefHeight="1047.0" prefWidth="1019.0" spacing="10.0">
<children>
<Label text="Garden Management">
<Label styleClass="page-title" text="Garden Management">
<font>
<Font size="34.0" />
</font>
@ -34,7 +34,7 @@
<Insets />
</VBox.margin>
</Label>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;">
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<children>
<Label text="Base Functionalities:">
<font>
@ -79,7 +79,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;">
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<children>
<Label text="Advanced Functionalities:">
<font>
@ -114,7 +114,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;">
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<children>
<Label text="Weather Forcast:">
<font>
@ -139,7 +139,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="15.0" style="-fx-background-color: white; -fx-border-color: black;">
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="15.0">
<children>
<Label text="Created by:">
<font>

View File

@ -12,7 +12,7 @@
<children>
<VBox layoutY="49.0" prefHeight="655.0" prefWidth="1175.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label text="My Garden">
<Label styleClass="page-title" text="My Garden">
<font>
<Font name="System Bold" size="28.0" />
</font>
@ -21,7 +21,7 @@
</VBox.margin>
</Label>
<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 styleClass="button-class" fx:id="addPlant_button" mnemonicParsing="false" onAction="#addPlant" prefHeight="45.0" prefWidth="155.0" text="Add new Plant">
<VBox.margin>
<Insets />
</VBox.margin>

View File

@ -12,7 +12,7 @@
<children>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label text="MySchedule" VBox.vgrow="NEVER">
<Label styleClass="page-title" text="MySchedule" VBox.vgrow="NEVER">
<font>
<Font size="24.0" />
</font>
@ -31,7 +31,7 @@
<Insets />
</VBox.margin>
</ListView>
<VBox prefHeight="131.0" prefWidth="603.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;" VBox.vgrow="NEVER">
<VBox styleClass="custom-container" prefHeight="131.0" prefWidth="603.0" spacing="5.0" VBox.vgrow="NEVER">
<children>
<Label alignment="TOP_LEFT" maxWidth="1.7976931348623157E308" prefHeight="17.0" prefWidth="558.0" text="Importants Information:" wrapText="true" VBox.vgrow="NEVER">
<font>

View File

@ -17,7 +17,7 @@
<children>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label prefHeight="45.0" prefWidth="903.0" text="Plants" VBox.vgrow="NEVER">
<Label styleClass="page-title" prefHeight="45.0" prefWidth="903.0" text="Plants" VBox.vgrow="NEVER">
<font>
<Font name="System Bold" size="30.0" />
</font>
@ -32,14 +32,14 @@
<HBox alignment="CENTER_LEFT" minHeight="300.0" prefHeight="480.0" prefWidth="881.0" spacing="10.0" VBox.vgrow="ALWAYS">
<children>
<ListView fx:id="list_plants" maxWidth="1.7976931348623157E308" prefHeight="497.0" prefWidth="400.0" HBox.hgrow="ALWAYS" />
<Pane maxHeight="1.7976931348623157E308" maxWidth="300.0" minWidth="300.0" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: white; -fx-border-color: black;" HBox.hgrow="NEVER">
<Pane styleClass="custom-container" maxHeight="1.7976931348623157E308" maxWidth="300.0" minWidth="300.0" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="NEVER">
<children>
<ImageView fx:id="img_plant" fitWidth="300" pickOnBounds="true" preserveRatio="true" />
</children>
</Pane>
</children>
</HBox>
<VBox maxHeight="1.7976931348623157E308" prefHeight="237.0" prefWidth="879.0" style="-fx-background-color: white; -fx-border-color: black;" VBox.vgrow="ALWAYS">
<VBox styleClass="vbox" maxHeight="1.7976931348623157E308" prefHeight="237.0" prefWidth="879.0" VBox.vgrow="ALWAYS">
<children>
<Label maxHeight="1.7976931348623157E308" prefHeight="33.0" prefWidth="919.0" text="Plant Information:" VBox.vgrow="NEVER">
<font>
@ -51,7 +51,7 @@
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Button fx:id="selectSowDay_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#selectSowDate" prefHeight="38.0" prefWidth="917.0" text="Select Harvest/Sow Day" VBox.vgrow="NEVER" />
<Button styleClass="button-class" fx:id="selectSowDay_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#selectSowDate" prefHeight="38.0" prefWidth="917.0" text="Select Harvest/Sow Day" VBox.vgrow="NEVER" />
</children>
<VBox.margin>
<Insets />
@ -67,7 +67,7 @@
<Insets />
</HBox.margin>
</AnchorPane>
<AnchorPane maxWidth="300.0" minHeight="0.0" minWidth="300.0" prefHeight="160.0" prefWidth="100.0" style="-fx-border-color: black; -fx-background-color: white;">
<AnchorPane styleClass="custom-container" maxWidth="300.0" minHeight="0.0" minWidth="300.0" prefHeight="160.0" prefWidth="100.0">
<children>
<VBox layoutX="38.0" layoutY="100.0" prefHeight="850.6666666666666" prefWidth="316.6666666666667" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
@ -78,7 +78,7 @@
</Label>
<TitledPane animated="false" text="Seasons">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<AnchorPane styleClass="custom-container" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox fx:id="seasons" layoutX="37.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
@ -87,7 +87,7 @@
</TitledPane>
<TitledPane animated="false" text="Climate Zones">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<AnchorPane styleClass="custom-container" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox fx:id="climate_zones" layoutX="36.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>

View File

@ -22,9 +22,9 @@
<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" />
<Button styleClass="button-class" cancelButton="true" contentDisplay="CENTER" graphicTextGap="5.0" mnemonicParsing="false" text="Close" onAction="#closeTutorial"/>
<Button styleClass="button-class" fx:id="previousPageButton" mnemonicParsing="false" text="Previous" onAction="#viewPreviousPage"/>
<Button styleClass="button-class" fx:id="nextPageButton" defaultButton="true" mnemonicParsing="false" text="Next" onAction="#viewNextPage" />
</buttons>
</ButtonBar>
</children>

View File

@ -0,0 +1,86 @@
.myDialog *.header-panel,
.myDialog *.header-panel .label {
-fx-background-color: #D3FFB5;
-fx-font-weight: bold;
}
.myDialog {
-fx-background-color: #EAFFE2;
-fx-border-color: black;
}
.myDialog .button {
-fx-border-color: darkgreen;
-fx-border-radius: 4;
-fx-border-width: 1.5;
-fx-background-color: #D1FFB7;
-fx-font-weight: bold;
-fx-font-size: 13
}
.myDialog .check-box .box {
-fx-background-color: #D3FFB5;
-fx-border-color:grey;
-fx-border-radius: 3;
}
.myDialog .combo-box .list-cell
{
-fx-background-color: #D1FFB7;
-fx-text-fill: -fx-text-base-color;
}
.myDialog .combo-box-popup .list-view
{
-fx-background-color: darkgreen, darkgreen;
-fx-background-insets: 0, 1;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 8, 0.0 , 0 , 0 );
}
.myDialog .combo-box-popup .list-view .list-cell
{
-fx-padding: 4 0 4 5;
/* No alternate highlighting */
-fx-background-color: #EAFFE2;
}
.myDialog .combo-box-popup .list-view .list-cell:filled:selected, .combo-box-popup .list-view .list-cell:filled:selected:hover
{
-fx-background: -fx-accent;
-fx-text-fill: black;
-fx-background-color: #D1FFB7;
}
.myDialog .combo-box-popup .list-view .list-cell:filled:hover
{
-fx-text-fill: black;
-fx-background-color: #54B91C;
}
.myDialog .combo-box-base {
-fx-border-color: grey;
-fx-background-color: #D1FFB7;
}
.myDialog .combo-box-base:hover
{
-fx-color: #54B91C;
}
.myDialog .radio-button .radio {
-fx-background-color: #D3FFB5;
-fx-border-color:grey;
-fx-border-radius: 25;
}
.myDialog .date-picker .button {
-fx-border-color: none;
-fx-background-color: none;
}

View File

@ -1,10 +1,19 @@
.button-class {
-fx-border-color: darkgreen;
-fx-border-radius: 4;
-fx-border-width: 1.5;
-fx-background-color: #D1FFB7;
-fx-font-weight: bold;
-fx-font-size: 13
}
#home_button, #myGarden_button,
#mySchedule_button, #settings_button,
#tutorial_button, #menu_pane {
-fx-text-fill: white;
-fx-background-color: rgb(0,128,0);
-fx-border-color: rgb(0,128,0);
-fx-border-radius: 0;
}
#menubar {
@ -13,13 +22,64 @@
#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{
#tutorial_button:hover {
-fx-background-color: darkgreen;
}
.root, .scroll-pane, #homeVBox, #cropDetailVBox {
-fx-background-color: #e6ffe6;
-fx-background-color: #F3FFEC;
}
.list-view {
-fx-border-color: black;
-fx-background-color: #EAFFE2;
}
.list-cell:even:filled:selected:focused .label,
.list-cell:even:filled:selected .label,
.list-cell:even {
-fx-background-color: #EAFFE2;
-fx-text-fill: black;
}
.list-cell:odd:filled:selected:focused .label,
.list-cell:odd:filled:selected .label,
.list-cell:odd {
-fx-background-color: #D3FFB5;
-fx-text-fill: black;
}
#list_plants .list-cell:even:filled:selected:focused,
#list_plants .list-cell:even:filled:selected,
#list_plants .list-cell:odd:filled:selected:focused,
#list_plants .list-cell:odd:filled:selected,
#scheduledPlants_listview .list-cell:even:filled:selected:focused,
#scheduledPlants_listview .list-cell:even:filled:selected,
#scheduledPlants_listview .list-cell:odd:filled:selected:focused,
#scheduledPlants_listview .list-cell:odd:filled:selected{
-fx-background-color: #7CD14B;
-fx-text-fill: white;
-fx-font-weight: bold;
}
.vbox, .custom-container {
-fx-background-color: #EAFFE2;
-fx-border-color: black;
}
.titled-pane > .title {
-fx-background-color: #D3FFB5;
-fx-border-color: black;
}
.page-title {
-fx-font-size: 20;
-fx-font-weight: bold;
}
.radio-button .radio {
-fx-background-color: #D3FFB5;
-fx-border-color:grey;
-fx-border-radius: 25;
}

View File

@ -130,7 +130,7 @@ public class JsonTaskListTest {
}
@Test
void testSubscription() {
void testSubscription() throws IOException {
TaskList.TaskListObserver mockObs = Mockito.mock(TaskList.TaskListObserver.class);
testDatabase.subscribe(mockObs);
try {

View File

@ -3,6 +3,9 @@ package ch.zhaw.gartenverwaltung.models;
import ch.zhaw.gartenverwaltung.io.*;
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
import ch.zhaw.gartenverwaltung.types.*;
import javafx.application.Platform;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -29,6 +32,16 @@ class GardenScheduleTest {
List<TaskTemplate> exampleTaskTemplateList;
GardenSchedule model;
@BeforeAll
static void setUpAll() {
Platform.startup(()->{});
}
@AfterAll
static void tearDownAll() {
Platform.exit();
}
@BeforeEach
void setUp() throws IOException, HardinessZoneNotSetException {
createExampleTaskList();

View File

@ -26,8 +26,8 @@
"name" : "fertilize plant",
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
"startDate" : "2022-06-01",
"nextExecution": "2022-05-01",
"nextNotification": "2022-05-01",
"nextExecution": "2022-06-01",
"nextNotification": "2022-06-01",
"endDate" : "2022-08-01",
"interval" : 28,
"cropId" : 0
@ -37,8 +37,8 @@
"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",
"nextExecution": "2022-05-01",
"nextNotification": "2022-05-01",
"nextExecution": "2022-07-01",
"nextNotification": "2022-07-01",
"endDate" : "2022-07-01",
"interval" : 0,
"cropId" : 0
@ -59,8 +59,8 @@
"name" : "harvest plant",
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
"startDate" : "2022-09-01",
"nextExecution": "2022-05-01",
"nextNotification": "2022-05-01",
"nextExecution": "2022-09-01",
"nextNotification": "2022-09-01",
"endDate" : "2022-09-01",
"interval" : 0,
"cropId" : 0