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.net.URISyntaxException;
import client.scenes.FoodpalApplicationCtrl;
import com.google.inject.Injector;
import client.scenes.AddQuoteCtrl;
@ -50,8 +51,9 @@ public class Main extends Application {
var overview = FXML.load(QuoteOverviewCtrl.class, "client", "scenes", "QuoteOverview.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);
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.ListView;
public class OverviewCtrl {
public class FoodpalApplicationCtrl {
private final MainCtrl mainCtrl;
// all of these aren't used with only my part of the code
@ -68,7 +68,7 @@ public class OverviewCtrl {
private Button addPreparationStepButton;
@Inject
public OverviewCtrl(MainCtrl mainCtrl) {
public FoodpalApplicationCtrl(MainCtrl mainCtrl) {
this.mainCtrl = mainCtrl;
}
@ -106,7 +106,7 @@ public class OverviewCtrl {
// Button handlers
@FXML
private void refresh() {
public void refresh() {
// TODO: someone else doing this
List<Recipe> recipes = showRecipeDetails();
recipeList.getItems().setAll(recipes);
@ -185,6 +185,25 @@ public class OverviewCtrl {
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 Scene add;
public void initialize(Stage primaryStage, Pair<QuoteOverviewCtrl, Parent> overview,
Pair<AddQuoteCtrl, Parent> add) {
private FoodpalApplicationCtrl foodpalCtrl;
private Scene foodpal;
public void initialize(Stage primaryStage,
Pair<QuoteOverviewCtrl, Parent> overview,
Pair<AddQuoteCtrl, Parent> add,
Pair<FoodpalApplicationCtrl, Parent> foodpal){
this.primaryStage = primaryStage;
this.overviewCtrl = overview.getKey();
this.overview = new Scene(overview.getValue());
this.addCtrl = add.getKey();
this.add = new Scene(add.getValue());
showOverview();
this.foodpalCtrl = foodpal.getKey();
this.foodpal = new Scene(foodpal.getValue());
showFoodpal();
primaryStage.show();
}
@ -54,4 +64,10 @@ public class MainCtrl {
primaryStage.setScene(add);
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.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>
@ -44,7 +44,7 @@
<buttons>
<ToolBar prefHeight="35.0" prefWidth="123.0">
<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="flagPlButton" onAction="#switchToPolish" text="PL" />
</items>
@ -71,8 +71,8 @@
</rowConstraints>
<children>
<Button fx:id="closeButton" onAction="#closeWindow" text="X" GridPane.columnIndex="3" />
<Button fx:id="maximizeButton" onAction="#MazimizeWindow" text="□" GridPane.columnIndex="2" />
<Button fx:id="minimizeButton" onAction="#MinimizeWindow" text="-" GridPane.columnIndex="1" />
<Button fx:id="maximizeButton" onAction="#maximizeWindow" text="□" GridPane.columnIndex="2" />
<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" />
</children>
@ -122,23 +122,23 @@
<!-- Ingredients -->
<VBox spacing="10">
<Label fx:id="ingredientsListView" text="Ingredients">
<Label text="Ingredients">
<font>
<Font name="System Bold" size="14.0" />
</font></Label>
<ListView prefHeight="167.0" prefWidth="912.0" />
</font>
</Label>
<ListView fx:id="ingredientsListView" prefHeight="167.0" prefWidth="912.0" />
<Button fx:id="addIngredientButton" onAction="#addIngredient" text="Add Ingredient" />
</VBox>
<!-- Preparation -->
<VBox spacing="10">
<Label fx:id="preparationListView" text="Preparation">
<Label text="Preparation">
<font>
<Font name="System Bold" size="14.0" />
</font></Label>
<ListView prefHeight="200.0" />
<Button fx:id="addPreparationStepButton" onAction="#addPreperationStep" text="Add Step" />
</VBox>
</font>
</Label>
<ListView fx:id="preparationListView" prefHeight="200.0" />
<Button fx:id="addPreparationStepButton" onAction="#addPreparationStep" text="Add Step" />
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="890.6666870117188" minWidth="10.0" prefWidth="854.6666870117188" />