refactor: removed MainFXMLController from dependencies

Replaced MainFXMLController-based scene-changing with event-based scene-changing to remove cyclic dependency
This commit is contained in:
David Guler
2022-11-15 08:40:42 +01:00
parent 5ef3f6c587
commit 2b7cec7e6a
10 changed files with 110 additions and 40 deletions
@@ -2,6 +2,7 @@ package ch.zhaw.gartenverwaltung;
import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
import ch.zhaw.gartenverwaltung.bootstrap.ChangeViewEvent;
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
import ch.zhaw.gartenverwaltung.models.PlantListModel;
@@ -16,6 +17,7 @@ import javafx.geometry.Insets;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
@@ -39,6 +41,9 @@ public class PlantsController {
// TODO: move to model
private final ListProperty<Plant> plantListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
@FXML
public AnchorPane plantsRoot;
@FXML
private VBox seasons;
@@ -73,6 +78,8 @@ public class PlantsController {
stage.initModality(Modality.APPLICATION_MODAL);
stage.setResizable(false);
stage.showAndWait();
// TODO: change to dialog
plantsRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "MyGarden.fxml"));
}
/**