Skip to content
Snippets Groups Projects
Commit a59575b3 authored by Blersch Lara's avatar Blersch Lara
Browse files

keeping track of currentScene and don't reload it

parent 24cbfbb3
No related branches found
No related tags found
No related merge requests found
......@@ -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");
......
......@@ -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();
......
......@@ -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);
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment