diff --git a/src/main/java/mi/hdm/TastyPages.java b/src/main/java/mi/hdm/TastyPages.java index 1fc5261f884d2413a6a4fc8ec37f8fee375db3dd..8e29204005ebcbf71a04cb53ee83d79cacc2bd2a 100644 --- a/src/main/java/mi/hdm/TastyPages.java +++ b/src/main/java/mi/hdm/TastyPages.java @@ -26,6 +26,7 @@ public class TastyPages extends Application { private final static Logger log = LogManager.getLogger(TastyPages.class); private static Stage stage; + public static final View startUpView = View.MAIN; public static void main(String[] args) { log.info("Starting TastyPages"); diff --git a/src/main/java/mi/hdm/controllers/BaseController.java b/src/main/java/mi/hdm/controllers/BaseController.java index 7633ad390711f80a7dc7bc7db0f6cbdac7dc8135..e0a2bc92126eaaf3c0bb87dc432303b54b5be9b2 100644 --- a/src/main/java/mi/hdm/controllers/BaseController.java +++ b/src/main/java/mi/hdm/controllers/BaseController.java @@ -15,8 +15,10 @@ public abstract class BaseController { private final static Stage stage = TastyPages.getApplicationStage(); protected Scene currentScene; + private static View currentView = TastyPages.startUpView; protected void changeScene(final View newScene) { + if (newScene == currentView) { return; } try { boolean wasMaximized = stage.isMaximized(); double sizeX = stage.getWidth(); @@ -27,10 +29,12 @@ public abstract class BaseController { Parent newParent = newScene.getScene(); currentScene = new Scene(newParent, sizeX, sizeY); + currentView = newScene; stage.setTitle(newWindowTitle); stage.setScene(currentScene); stage.setMaximized(wasMaximized); + log.info("new view: {}", currentView); } catch (IOException io) { log.error("IO Exception: something went wrong when changing the scene."); io.printStackTrace(); diff --git a/src/main/java/mi/hdm/controllers/View.java b/src/main/java/mi/hdm/controllers/View.java index fe0283bbd6d3c1477b98dd95390455b38d22fa9b..471e0364954c27de795a66c372dd3aff7594d2da 100644 --- a/src/main/java/mi/hdm/controllers/View.java +++ b/src/main/java/mi/hdm/controllers/View.java @@ -34,7 +34,6 @@ public enum View { } public Parent getScene() throws IOException { - //TODO: keep track of current view and don't reload it if the user selects it again! log.info("Loading FXML for '{}' view from: {}", windowTitle, path); final FXMLLoader loader = new FXMLLoader(getClass().getResource(path)); log.debug("Successfully retrieved resource from {}", path); diff --git a/src/main/resources/fxml/Meal_Plan.fxml b/src/main/resources/fxml/Meal_Plan.fxml index 4cfe21211c92d49bc2a5d7876bdfa92cc38cb5e7..75216f2110a3189df094339de60cdd2880ff0fe7 100644 --- a/src/main/resources/fxml/Meal_Plan.fxml +++ b/src/main/resources/fxml/Meal_Plan.fxml @@ -13,7 +13,7 @@ <?import javafx.scene.text.Font?> <?import javafx.scene.text.Text?> -<AnchorPane fx:id="parent" prefHeight="540.0" prefWidth="872.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mi.hdm.controllers.MealPlanController"> +<AnchorPane fx:id="parent" prefHeight="540.0" prefWidth="872.0" xmlns="http://javafx.com/javafx/14" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mi.hdm.controllers.MealPlanController"> <children> <HBox alignment="CENTER_LEFT" prefHeight="69.0" prefWidth="793.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <children> @@ -69,7 +69,7 @@ <Font name="Arial" size="17.0" /> </font> </Text> - <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: d9d9d9; -fx-background-radius: 5; -fx-control-inner-background: a; -fx-accent: d91c1c;"> + <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: #d9d9d9; -fx-background-radius: 5; -fx-control-inner-background: a; -fx-accent: d91c1c;"> <HBox.margin> <Insets left="70.0" /> </HBox.margin> @@ -83,7 +83,7 @@ <Font name="Arial" size="17.0" /> </font> </Text> - <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: d9d9d9; -fx-background-radius: 5; -fx-control-inner-background: a; -fx-accent: d91c1c;"> + <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: #d9d9d9; -fx-background-radius: 5; -fx-control-inner-background: a; -fx-accent: d91c1c;"> <HBox.margin> <Insets left="70.0" /> </HBox.margin> @@ -97,7 +97,7 @@ <Font name="Arial" size="17.0" /> </font> </Text> - <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> + <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: #d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> <HBox.margin> <Insets left="70.0" /> </HBox.margin> @@ -111,7 +111,7 @@ <Font name="Arial" size="17.0" /> </font> </Text> - <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> + <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: #d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> <HBox.margin> <Insets left="70.0" /> </HBox.margin> @@ -125,7 +125,7 @@ <Font name="Arial" size="17.0" /> </font> </Text> - <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> + <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: #d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> <HBox.margin> <Insets left="70.0" /> </HBox.margin> @@ -139,7 +139,7 @@ <Font name="Arial" size="17.0" /> </font> </Text> - <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color: d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> + <ProgressBar prefHeight="24.0" prefWidth="631.0" progress="0.0" style="-fx-background-color:#d9d9d9; -fx-control-inner-background: a; -fx-background-radius: 5; -fx-accent: d91c1c;"> <HBox.margin> <Insets left="70.0" /> </HBox.margin>