Merged Notification Branch with Weather Branch

This commit is contained in:
schrom01 2022-11-29 11:55:49 +01:00
parent 1faf1c10de
commit fd28ca7cc2
6 changed files with 18 additions and 11 deletions

View File

@ -26,7 +26,7 @@ tasks.withType(JavaCompile) {
application { application {
mainModule = 'ch.zhaw.gartenverwaltung' mainModule = 'ch.zhaw.gartenverwaltung'
mainClass = 'ch.zhaw.gartenverwaltung.HelloApplication' mainClass = 'ch.zhaw.gartenverwaltung.Main'
} }
javafx { javafx {

View File

@ -2,13 +2,16 @@ package ch.zhaw.gartenverwaltung;
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader; import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
import ch.zhaw.gartenverwaltung.backgroundtasks.BackgroundTasks; 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.application.Application;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.io.IOException; import java.io.IOException;
import java.util.Timer; import java.util.Timer;
public class HelloApplication extends Application { public class Main extends Application {
Timer backGroundTaskTimer = new Timer(); Timer backGroundTaskTimer = new Timer();
BackgroundTasks backgroundTasks; BackgroundTasks backgroundTasks;
@ -16,7 +19,7 @@ public class HelloApplication extends Application {
public void start(Stage stage) throws IOException { public void start(Stage stage) throws IOException {
AppLoader appLoader = new AppLoader(); 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); backGroundTaskTimer.scheduleAtFixedRate(backgroundTasks, 0, 1000);
appLoader.loadSceneToStage("MainFXML.fxml", stage); appLoader.loadSceneToStage("MainFXML.fxml", stage);

View File

@ -1,4 +1,4 @@
package ch.zhaw.gartenverwaltung.io; package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
public enum SevereWeather { public enum SevereWeather {
FROST,SNOW,HAIL,NO_SEVERE_WEATHER,RAIN FROST,SNOW,HAIL,NO_SEVERE_WEATHER,RAIN

View File

@ -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.models.PlantNotFoundException;
import ch.zhaw.gartenverwaltung.types.*; import ch.zhaw.gartenverwaltung.types.*;

View File

@ -1,4 +1,4 @@
package ch.zhaw.gartenverwaltung.io; package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
public class WeatherService { public class WeatherService {
private static final int NO_RAIN = 0; private static final int NO_RAIN = 0;

View File

@ -1,6 +1,6 @@
package ch.zhaw.gartenverwaltung.bootstrap; package ch.zhaw.gartenverwaltung.bootstrap;
import ch.zhaw.gartenverwaltung.HelloApplication; import ch.zhaw.gartenverwaltung.Main;
import ch.zhaw.gartenverwaltung.io.*; import ch.zhaw.gartenverwaltung.io.*;
import ch.zhaw.gartenverwaltung.models.Garden; import ch.zhaw.gartenverwaltung.models.Garden;
import ch.zhaw.gartenverwaltung.models.GardenSchedule; import ch.zhaw.gartenverwaltung.models.GardenSchedule;
@ -77,7 +77,7 @@ public class AppLoader {
* @throws IOException if the file could not be loaded * @throws IOException if the file could not be loaded
*/ */
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(Main.class.getResource(fxmlFile)));
Pane root = loader.load(); Pane root = loader.load();
Scene scene = new Scene(root); Scene scene = new Scene(root);
String css = Objects.requireNonNull(this.getClass().getResource("styles.css")).toExternalForm(); 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 * @throws IOException if the file could not be loaded
*/ */
public Object loadPaneToDialog(String fxmlFile, DialogPane appendee) throws IOException { 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()); appendee.setContent(loader.load());
Object controller = loader.getController(); Object controller = loader.getController();
annotationInject(controller); annotationInject(controller);
@ -114,7 +114,7 @@ public class AppLoader {
* @throws IOException if the file could not be loaded * @throws IOException if the file could not be loaded
*/ */
public void loadAndCacheFxml(String fxmlFile) throws IOException { 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(); Pane pane = loader.load();
panes.put(fxmlFile, pane); panes.put(fxmlFile, pane);
annotationInject(loader.getController()); 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()); return dependencies.get(type.getSimpleName());
} }
} }