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 89e6482d0419f4e82d0b3dd6735bb351d1316ed1..aa4f1d9a0c72f61bd9e320a3c9ec4834f040d9e1 100644 --- a/src/main/resources/fxml/Meal_Plan.fxml +++ b/src/main/resources/fxml/Meal_Plan.fxml @@ -11,7 +11,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> <VBox layoutY="69.0" prefHeight="445.0" prefWidth="872.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"> <children> @@ -50,7 +50,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> @@ -64,7 +64,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> @@ -78,7 +78,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> @@ -92,7 +92,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> @@ -106,7 +106,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> @@ -120,7 +120,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>