From fd28ca7cc2862116f27720e2c07148a1587f9b16 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Tue, 29 Nov 2022 11:55:49 +0100 Subject: [PATCH] Merged Notification Branch with Weather Branch --- build.gradle | 2 +- .../{HelloApplication.java => Main.java} | 7 +++++-- .../{io => backgroundtasks/weather}/SevereWeather.java | 2 +- .../weather}/WeatherGradenTaskPlanner.java | 6 +++++- .../weather}/WeatherService.java | 2 +- .../ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java | 10 +++++----- 6 files changed, 18 insertions(+), 11 deletions(-) rename src/main/java/ch/zhaw/gartenverwaltung/{HelloApplication.java => Main.java} (68%) rename src/main/java/ch/zhaw/gartenverwaltung/{io => backgroundtasks/weather}/SevereWeather.java (56%) rename src/main/java/ch/zhaw/gartenverwaltung/{io => backgroundtasks/weather}/WeatherGradenTaskPlanner.java (93%) rename src/main/java/ch/zhaw/gartenverwaltung/{io => backgroundtasks/weather}/WeatherService.java (92%) diff --git a/build.gradle b/build.gradle index 8c3b14a..e789fc4 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ tasks.withType(JavaCompile) { application { mainModule = 'ch.zhaw.gartenverwaltung' - mainClass = 'ch.zhaw.gartenverwaltung.HelloApplication' + mainClass = 'ch.zhaw.gartenverwaltung.Main' } javafx { diff --git a/src/main/java/ch/zhaw/gartenverwaltung/HelloApplication.java b/src/main/java/ch/zhaw/gartenverwaltung/Main.java similarity index 68% rename from src/main/java/ch/zhaw/gartenverwaltung/HelloApplication.java rename to src/main/java/ch/zhaw/gartenverwaltung/Main.java index 1d8ed5a..1b3dfc0 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/HelloApplication.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/Main.java @@ -2,13 +2,16 @@ package ch.zhaw.gartenverwaltung; import ch.zhaw.gartenverwaltung.bootstrap.AppLoader; import ch.zhaw.gartenverwaltung.backgroundtasks.BackgroundTasks; +import ch.zhaw.gartenverwaltung.io.PlantList; +import ch.zhaw.gartenverwaltung.io.TaskList; +import ch.zhaw.gartenverwaltung.models.Garden; import javafx.application.Application; import javafx.stage.Stage; import java.io.IOException; import java.util.Timer; -public class HelloApplication extends Application { +public class Main extends Application { Timer backGroundTaskTimer = new Timer(); BackgroundTasks backgroundTasks; @@ -16,7 +19,7 @@ public class HelloApplication extends Application { public void start(Stage stage) throws IOException { AppLoader appLoader = new AppLoader(); - backgroundTasks = new BackgroundTasks(appLoader.getTaskList(), appLoader.getGarden(), appLoader.getPlantList()); + backgroundTasks = new BackgroundTasks((TaskList) appLoader.getAppDependency(TaskList.class),(Garden) appLoader.getAppDependency(Garden.class), (PlantList) appLoader.getAppDependency(PlantList.class)); backGroundTaskTimer.scheduleAtFixedRate(backgroundTasks, 0, 1000); appLoader.loadSceneToStage("MainFXML.fxml", stage); diff --git a/src/main/java/ch/zhaw/gartenverwaltung/io/SevereWeather.java b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/SevereWeather.java similarity index 56% rename from src/main/java/ch/zhaw/gartenverwaltung/io/SevereWeather.java rename to src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/SevereWeather.java index 239e34a..fa075e7 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/io/SevereWeather.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/SevereWeather.java @@ -1,4 +1,4 @@ -package ch.zhaw.gartenverwaltung.io; +package ch.zhaw.gartenverwaltung.backgroundtasks.weather; public enum SevereWeather { FROST,SNOW,HAIL,NO_SEVERE_WEATHER,RAIN diff --git a/src/main/java/ch/zhaw/gartenverwaltung/io/WeatherGradenTaskPlanner.java b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java similarity index 93% rename from src/main/java/ch/zhaw/gartenverwaltung/io/WeatherGradenTaskPlanner.java rename to src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java index adf33fb..edf9d1e 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/io/WeatherGradenTaskPlanner.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java @@ -1,5 +1,9 @@ -package ch.zhaw.gartenverwaltung.io; +package ch.zhaw.gartenverwaltung.backgroundtasks.weather; +import ch.zhaw.gartenverwaltung.io.CropList; +import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException; +import ch.zhaw.gartenverwaltung.io.PlantList; +import ch.zhaw.gartenverwaltung.io.TaskList; import ch.zhaw.gartenverwaltung.models.PlantNotFoundException; import ch.zhaw.gartenverwaltung.types.*; diff --git a/src/main/java/ch/zhaw/gartenverwaltung/io/WeatherService.java b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherService.java similarity index 92% rename from src/main/java/ch/zhaw/gartenverwaltung/io/WeatherService.java rename to src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherService.java index 510b292..89fdf76 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/io/WeatherService.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherService.java @@ -1,4 +1,4 @@ -package ch.zhaw.gartenverwaltung.io; +package ch.zhaw.gartenverwaltung.backgroundtasks.weather; public class WeatherService { private static final int NO_RAIN = 0; diff --git a/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java b/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java index f461714..2499d8b 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java @@ -1,6 +1,6 @@ package ch.zhaw.gartenverwaltung.bootstrap; -import ch.zhaw.gartenverwaltung.HelloApplication; +import ch.zhaw.gartenverwaltung.Main; import ch.zhaw.gartenverwaltung.io.*; import ch.zhaw.gartenverwaltung.models.Garden; import ch.zhaw.gartenverwaltung.models.GardenSchedule; @@ -77,7 +77,7 @@ public class AppLoader { * @throws IOException if the file could not be loaded */ 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(Main.class.getResource(fxmlFile))); Pane root = loader.load(); Scene scene = new Scene(root); String css = Objects.requireNonNull(this.getClass().getResource("styles.css")).toExternalForm(); @@ -99,7 +99,7 @@ public class AppLoader { * @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))); + FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(Main.class.getResource(fxmlFile))); appendee.setContent(loader.load()); Object controller = loader.getController(); annotationInject(controller); @@ -114,7 +114,7 @@ public class AppLoader { * @throws IOException if the file could not be loaded */ public void loadAndCacheFxml(String fxmlFile) throws IOException { - FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(HelloApplication.class.getResource(fxmlFile))); + FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(Main.class.getResource(fxmlFile))); Pane pane = loader.load(); panes.put(fxmlFile, pane); annotationInject(loader.getController()); @@ -152,7 +152,7 @@ public class AppLoader { }); } - private Object getAppDependency(Class type) { + public Object getAppDependency(Class type) { return dependencies.get(type.getSimpleName()); } }