Show foodpalApplication when running

This commit is contained in:
Mei Chang van der Werff 2025-12-01 15:39:01 +01:00
commit 1c8f5780d9
4 changed files with 62 additions and 25 deletions

View file

@ -20,6 +20,7 @@ import static com.google.inject.Guice.createInjector;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import client.scenes.FoodpalApplicationCtrl;
import com.google.inject.Injector; import com.google.inject.Injector;
import client.scenes.AddQuoteCtrl; import client.scenes.AddQuoteCtrl;
@ -50,8 +51,9 @@ public class Main extends Application {
var overview = FXML.load(QuoteOverviewCtrl.class, "client", "scenes", "QuoteOverview.fxml"); var overview = FXML.load(QuoteOverviewCtrl.class, "client", "scenes", "QuoteOverview.fxml");
var add = FXML.load(AddQuoteCtrl.class, "client", "scenes", "AddQuote.fxml"); var add = FXML.load(AddQuoteCtrl.class, "client", "scenes", "AddQuote.fxml");
var foodpal = FXML.load(FoodpalApplicationCtrl.class, "client", "scenes", "FoodpalApplication.fxml");
var mainCtrl = INJECTOR.getInstance(MainCtrl.class); var mainCtrl = INJECTOR.getInstance(MainCtrl.class);
mainCtrl.initialize(primaryStage, overview, add); mainCtrl.initialize(primaryStage, overview, add, foodpal);
} }
} }

View file

@ -12,7 +12,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
public class OverviewCtrl { public class FoodpalApplicationCtrl {
private final MainCtrl mainCtrl; private final MainCtrl mainCtrl;
// all of these aren't used with only my part of the code // all of these aren't used with only my part of the code
@ -68,7 +68,7 @@ public class OverviewCtrl {
private Button addPreparationStepButton; private Button addPreparationStepButton;
@Inject @Inject
public OverviewCtrl(MainCtrl mainCtrl) { public FoodpalApplicationCtrl(MainCtrl mainCtrl) {
this.mainCtrl = mainCtrl; this.mainCtrl = mainCtrl;
} }
@ -106,7 +106,7 @@ public class OverviewCtrl {
// Button handlers // Button handlers
@FXML @FXML
private void refresh() { public void refresh() {
// TODO: someone else doing this // TODO: someone else doing this
List<Recipe> recipes = showRecipeDetails(); List<Recipe> recipes = showRecipeDetails();
recipeList.getItems().setAll(recipes); recipeList.getItems().setAll(recipes);
@ -185,6 +185,25 @@ public class OverviewCtrl {
System.out.println("Switch language to PL"); System.out.println("Switch language to PL");
} }
@FXML
private void closeWindow() {
System.out.println("Close window");
}
@FXML
private void maximizeWindow() {
System.out.println("Maximize window");
}
@FXML
private void minimizeWindow() {
System.out.println("Minimize window");
}
@FXML
private void MakePrintable() {
System.out.println("Recipe printed");
}
} }

View file

@ -30,16 +30,26 @@ public class MainCtrl {
private AddQuoteCtrl addCtrl; private AddQuoteCtrl addCtrl;
private Scene add; private Scene add;
public void initialize(Stage primaryStage, Pair<QuoteOverviewCtrl, Parent> overview, private FoodpalApplicationCtrl foodpalCtrl;
Pair<AddQuoteCtrl, Parent> add) { private Scene foodpal;
public void initialize(Stage primaryStage,
Pair<QuoteOverviewCtrl, Parent> overview,
Pair<AddQuoteCtrl, Parent> add,
Pair<FoodpalApplicationCtrl, Parent> foodpal){
this.primaryStage = primaryStage; this.primaryStage = primaryStage;
this.overviewCtrl = overview.getKey(); this.overviewCtrl = overview.getKey();
this.overview = new Scene(overview.getValue()); this.overview = new Scene(overview.getValue());
this.addCtrl = add.getKey(); this.addCtrl = add.getKey();
this.add = new Scene(add.getValue()); this.add = new Scene(add.getValue());
showOverview(); this.foodpalCtrl = foodpal.getKey();
this.foodpal = new Scene(foodpal.getValue());
showFoodpal();
primaryStage.show(); primaryStage.show();
} }
@ -54,4 +64,10 @@ public class MainCtrl {
primaryStage.setScene(add); primaryStage.setScene(add);
add.setOnKeyPressed(e -> addCtrl.keyPressed(e)); add.setOnKeyPressed(e -> addCtrl.keyPressed(e));
} }
public void showFoodpal(){
primaryStage.setTitle("FoodPal");
primaryStage.setScene(foodpal);
foodpalCtrl.refresh();
}
} }

View file

@ -15,7 +15,7 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<BorderPane prefHeight="800.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.OverviewCtrl"> <BorderPane prefHeight="800.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.FoodpalApplicationCtrl">
<!-- TOP BAR --> <!-- TOP BAR -->
<top> <top>
@ -44,7 +44,7 @@
<buttons> <buttons>
<ToolBar prefHeight="35.0" prefWidth="123.0"> <ToolBar prefHeight="35.0" prefWidth="123.0">
<items> <items>
<Button fx:id="flagEnButton" minWidth="33.0" onAction="#switchToEngelish" prefHeight="25.0" prefWidth="33.0" text="EN" /> <Button fx:id="flagEnButton" minWidth="33.0" onAction="#switchToEnglish" prefHeight="25.0" prefWidth="33.0" text="EN" />
<Button fx:id="flagNlButton" onAction="#switchToDutch" text="NL" /> <Button fx:id="flagNlButton" onAction="#switchToDutch" text="NL" />
<Button fx:id="flagPlButton" onAction="#switchToPolish" text="PL" /> <Button fx:id="flagPlButton" onAction="#switchToPolish" text="PL" />
</items> </items>
@ -71,8 +71,8 @@
</rowConstraints> </rowConstraints>
<children> <children>
<Button fx:id="closeButton" onAction="#closeWindow" text="X" GridPane.columnIndex="3" /> <Button fx:id="closeButton" onAction="#closeWindow" text="X" GridPane.columnIndex="3" />
<Button fx:id="maximizeButton" onAction="#MazimizeWindow" text="□" GridPane.columnIndex="2" /> <Button fx:id="maximizeButton" onAction="#maximizeWindow" text="□" GridPane.columnIndex="2" />
<Button fx:id="minimizeButton" onAction="#MinimizeWindow" text="-" GridPane.columnIndex="1" /> <Button fx:id="minimizeButton" onAction="#minimizeWindow" text="-" GridPane.columnIndex="1" />
<Button fx:id="refreshButton" onAction="#refresh" prefHeight="25.0" prefWidth="34.0" text="⟳" GridPane.columnIndex="3" GridPane.rowIndex="2" /> <Button fx:id="refreshButton" onAction="#refresh" prefHeight="25.0" prefWidth="34.0" text="⟳" GridPane.columnIndex="3" GridPane.rowIndex="2" />
</children> </children>
@ -122,24 +122,24 @@
<!-- Ingredients --> <!-- Ingredients -->
<VBox spacing="10"> <VBox spacing="10">
<Label fx:id="ingredientsListView" text="Ingredients"> <Label text="Ingredients">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font></Label> </font>
<ListView prefHeight="167.0" prefWidth="912.0" /> </Label>
<ListView fx:id="ingredientsListView" prefHeight="167.0" prefWidth="912.0" />
<Button fx:id="addIngredientButton" onAction="#addIngredient" text="Add Ingredient" /> <Button fx:id="addIngredientButton" onAction="#addIngredient" text="Add Ingredient" />
</VBox> </VBox>
<!-- Preparation --> <!-- Preparation -->
<VBox spacing="10"> <Label text="Preparation">
<Label fx:id="preparationListView" text="Preparation"> <font>
<font> <Font name="System Bold" size="14.0" />
<Font name="System Bold" size="14.0" /> </font>
</font></Label> </Label>
<ListView prefHeight="200.0" /> <ListView fx:id="preparationListView" prefHeight="200.0" />
<Button fx:id="addPreparationStepButton" onAction="#addPreperationStep" text="Add Step" /> <Button fx:id="addPreparationStepButton" onAction="#addPreparationStep" text="Add Step" />
</VBox> <GridPane>
<GridPane>
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="890.6666870117188" minWidth="10.0" prefWidth="854.6666870117188" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="890.6666870117188" minWidth="10.0" prefWidth="854.6666870117188" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="445.3333740234375" minWidth="10.0" prefWidth="57.33331298828125" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="445.3333740234375" minWidth="10.0" prefWidth="57.33331298828125" />