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

continued recipe-view and controller, image path still not working

parent b7924e7c
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ public abstract class BaseController { ...@@ -16,7 +16,7 @@ public abstract class BaseController {
protected Scene currentScene; //TODO this should be static? protected Scene currentScene; //TODO this should be static?
private static View currentView = GuiController.getStartupView(); private static View currentView = GuiController.getStartupView();
protected void changeScene(final View newScene) { protected void changeScene(final View newScene, Object... args) {
if (newScene == currentView) { if (newScene == currentView) {
return; return;
} }
...@@ -28,7 +28,7 @@ public abstract class BaseController { ...@@ -28,7 +28,7 @@ public abstract class BaseController {
String newWindowTitle = newScene.getWindowTitle(); String newWindowTitle = newScene.getWindowTitle();
log.debug("Attempting to change the scene to {}", newScene); log.debug("Attempting to change the scene to {}", newScene);
Parent newParent = newScene.getScene(); Parent newParent = newScene.getScene(args);
currentScene = new Scene(newParent, sizeX, sizeY); currentScene = new Scene(newParent, sizeX, sizeY);
currentView = newScene; currentView = newScene;
......
...@@ -56,7 +56,7 @@ public class MainPageController extends BaseController { ...@@ -56,7 +56,7 @@ public class MainPageController extends BaseController {
for (Recipe recipe : recipes) { for (Recipe recipe : recipes) {
RecipeVbox recipeVbox = new RecipeVbox(recipe, categoryManager); RecipeVbox recipeVbox = new RecipeVbox(recipe, categoryManager);
recipeVbox.setOnMouseClicked(mouseEvent -> System.out.format("User selected '%s'.%n", recipe.getName())); //TODO: this needs to display the recipe view recipeVbox.setOnMouseClicked(mouseEvent -> changeScene(View.RECIPE_VIEW, recipeVbox.getAssociatedRecipe())); //TODO: this needs to display the recipe view
currentRecipesInGUI.add(recipeVbox); currentRecipesInGUI.add(recipeVbox);
} }
recipeTilePane.getChildren().addAll(currentRecipesInGUI); //... and add the new ones recipeTilePane.getChildren().addAll(currentRecipesInGUI); //... and add the new ones
......
...@@ -18,8 +18,8 @@ public class RecipeViewController extends BaseController { ...@@ -18,8 +18,8 @@ public class RecipeViewController extends BaseController {
private final Recipe recipe; private final Recipe recipe;
@FXML @FXML
private AnchorPane parent; private AnchorPane parent;
@FXML // @FXML
private Label recipeDescription; //private Label recipeDescription;
@FXML @FXML
private Label recipeName; private Label recipeName;
@FXML @FXML
...@@ -46,7 +46,8 @@ public class RecipeViewController extends BaseController { ...@@ -46,7 +46,8 @@ public class RecipeViewController extends BaseController {
loadHeader(parent); loadHeader(parent);
recipeName.setText(recipe.getName()); recipeName.setText(recipe.getName());
recipeDescription.setText(recipe.getDescription()); //recipeDescription.setText(recipe.getDescription());
//TODO: display recipe description, preparation and ingredients
//idea for solution from: https://stackoverflow.com/questions/22710053/how-can-i-show-an-image-using-the-imageview-component-in-javafx-and-fxml //idea for solution from: https://stackoverflow.com/questions/22710053/how-can-i-show-an-image-using-the-imageview-component-in-javafx-and-fxml
Image image = new Image(recipe.getImage()); Image image = new Image(recipe.getImage());
......
...@@ -40,15 +40,12 @@ public enum View { ...@@ -40,15 +40,12 @@ public enum View {
); );
case RECIPE_VIEW -> loader.setControllerFactory((callback) -> { case RECIPE_VIEW -> loader.setControllerFactory((callback) -> {
if (args== null && args.length == 1 && args[0] instanceof Recipe recipe) { if (args != null && args.length == 1 && args[0] instanceof Recipe recipe) {
return new RecipeViewController(recipe); return new RecipeViewController(recipe);
} else { } else {
throw new InvalidParameterException(); throw new InvalidParameterException();
} }
} });
);
case SHOPPINGLIST_VIEW -> loader.setControllerFactory((callback) -> case SHOPPINGLIST_VIEW -> loader.setControllerFactory((callback) ->
new ShoppingListViewController(model.getRecipeManager(), model.getShoppingList()) new ShoppingListViewController(model.getRecipeManager(), model.getShoppingList())
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<AnchorPane prefHeight="540.0" prefWidth="872.0" style="-fx-background-color: ffffff;" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mi.hdm.controllers.RecipeViewController"> <AnchorPane fx:id="parent" prefHeight="540.0" prefWidth="872.0" style="-fx-background-color: ffffff;" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mi.hdm.controllers.RecipeViewController">
<children> <children>
<VBox layoutX="410.0" layoutY="1.0" prefHeight="539.0" prefWidth="872.0" style="-fx-background-color: ffffff;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <VBox layoutX="410.0" layoutY="1.0" prefHeight="539.0" prefWidth="872.0" style="-fx-background-color: ffffff;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding> <padding>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label alignment="TOP_CENTER" prefHeight="54.0" prefWidth="207.0" text="Recipe Name" textFill="#d91c1c" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.valignment="TOP"> <Label fx:id="recipeName" alignment="TOP_CENTER" prefHeight="54.0" prefWidth="207.0" text="Recipe Name" textFill="#d91c1c" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.valignment="TOP">
<font> <font>
<Font name="Arial" size="34.0" /> <Font name="Arial" size="34.0" />
</font> </font>
...@@ -49,12 +49,12 @@ ...@@ -49,12 +49,12 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Button alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" prefHeight="41.0" prefWidth="159.0" style="-fx-background-color: ffffff; -fx-control-inner-background: transparent; -fx-border-color: d91c1c; -fx-border-radius: 5; -fx-border-width: 4;" text="Delete" textAlignment="CENTER" textFill="#d91c1c"> <Button fx:id="recipeDelete" alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" prefHeight="41.0" prefWidth="159.0" style="-fx-background-color: ffffff; -fx-control-inner-background: transparent; -fx-border-color: d91c1c; -fx-border-radius: 5; -fx-border-width: 4;" text="Delete" textAlignment="CENTER" textFill="#d91c1c">
<font> <font>
<Font name="System Bold" size="17.0" /> <Font name="System Bold" size="17.0" />
</font> </font>
</Button> </Button>
<Button alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" prefHeight="41.0" prefWidth="159.0" style="-fx-background-color: ffffff; -fx-control-inner-background: transparent; -fx-border-color: d91c1c; -fx-border-radius: 5; -fx-border-width: 4;" text="Edit" textAlignment="CENTER" textFill="#d91c1c" GridPane.columnIndex="1"> <Button fx:id="recipeDelete" alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" prefHeight="41.0" prefWidth="159.0" style="-fx-background-color: ffffff; -fx-control-inner-background: transparent; -fx-border-color: d91c1c; -fx-border-radius: 5; -fx-border-width: 4;" text="Edit" textAlignment="CENTER" textFill="#d91c1c" GridPane.columnIndex="1">
<font> <font>
<Font name="System Bold" size="17.0" /> <Font name="System Bold" size="17.0" />
</font> </font>
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</VBox.margin></ListView> </VBox.margin></ListView>
<ScrollPane prefHeight="244.0" prefWidth="393.0" style="-fx-border-color: D91C1C; -fx-border-width: 4; -fx-border-radius: 10; -fx-background-color: transparent;"> <ScrollPane prefHeight="244.0" prefWidth="393.0" style="-fx-border-color: D91C1C; -fx-border-width: 4; -fx-border-radius: 10; -fx-background-color: transparent;">
<content> <content>
<Label alignment="TOP_LEFT" contentDisplay="CENTER" lineSpacing="1.5" prefHeight="372.0" prefWidth="393.0" style="-fx-background-color: transparent;" text=" sjdfjakjfkj j kasdjfkasjdkf aorjfaksdjf alösjfailjskdf aöiejraö skjdfoakdjfpoeaijf alskjdf aroijf oajdfo oerajfija oaeijr oaiejrüoj oaejf üoaijer fjüaroifj üeorj ojeaüroit oijetiüfj üeor" wrapText="true"> <Label fx:id="recipePreparation" alignment="TOP_LEFT" contentDisplay="CENTER" lineSpacing="1.5" prefHeight="372.0" prefWidth="393.0" style="-fx-background-color: transparent;" text=" sjdfjakjfkj j kasdjfkasjdkf aorjfaksdjf alösjfailjskdf aöiejraö skjdfoakdjfpoeaijf alskjdf aroijf oajdfo oerajfija oaeijr oaiejrüoj oaejf üoaijer fjüaroifj üeorj ojeaüroit oijetiüfj üeor" wrapText="true">
<font> <font>
<Font name="Inter Regular" size="12.0" /> <Font name="Inter Regular" size="12.0" />
</font> </font>
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
<Pane layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: transparent; -fx-border-color: d91c1c; -fx-border-radius: 10; -fx-border-width: 4;"> <Pane layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: transparent; -fx-border-color: d91c1c; -fx-border-radius: 10; -fx-border-width: 4;">
<children> <children>
<ScrollBar layoutX="317.0" layoutY="5.0" orientation="VERTICAL" prefHeight="190.0" prefWidth="14.0" /> <ScrollBar layoutX="317.0" layoutY="5.0" orientation="VERTICAL" prefHeight="190.0" prefWidth="14.0" />
<TableView layoutY="-1.0" prefHeight="200.0" prefWidth="321.0" style="-fx-background-color: transparent;"> <TableView fx:id="recipeIngredients" layoutY="-1.0" prefHeight="200.0" prefWidth="321.0" style="-fx-background-color: transparent;">
<columns> <columns>
<TableColumn editable="false" prefWidth="91.0" text="C1" /> <TableColumn editable="false" prefWidth="91.0" text="C1" />
......
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