diff --git a/client/src/main/java/client/scenes/recipe/IngredientListCell.java b/client/src/main/java/client/scenes/recipe/IngredientListCell.java index bdd60ab..7ecc9a7 100644 --- a/client/src/main/java/client/scenes/recipe/IngredientListCell.java +++ b/client/src/main/java/client/scenes/recipe/IngredientListCell.java @@ -64,18 +64,21 @@ public class IngredientListCell extends OrderedEditableListCell templateAmount = Optional.empty(); Optional unit = Optional.empty(); - + TextField amountInput; // Initialize the input fields with some initial data if we get a formal ingredient if (ingredient.getClass().equals(FormalIngredient.class)) { FormalIngredient formal = (FormalIngredient) ingredient; templateAmount = Optional.of(formal.getAmount()); unit = Optional.of(Unit.fromString(formal.getUnitSuffix()).orElseThrow( () -> new RuntimeException("FormalIngredient whereas invalid unit"))); + amountInput = new TextField(templateAmount.map(Object::toString).orElse(null)); + } else { + assert ingredient instanceof VagueIngredient; + amountInput = new TextField(((VagueIngredient) ingredient).getDescription()); } - // TODO initialize some other data in the case of vague ingredient // Initialize the input boxes - TextField amountInput = new TextField(templateAmount.map(Object::toString).orElse(null)); + ChoiceBox unitChoice = new ChoiceBox<>(); // initialize the current unit if it is present @@ -115,7 +118,6 @@ public class IngredientListCell extends OrderedEditableListCell unitChoice) { - MenuButton ingredientSelect = new MenuButton(getLocaleString("app.prompt.select-ingredient")); + selectedIngredient.setValue(ingredient.getIngredient()); + MenuButton ingredientSelect = new MenuButton(selectedIngredient.get() == null ? + getLocaleString("app.prompt.select-ingredient") : selectedIngredient.get().getName()); HBox container = new HBox(amountInput, unitChoice, ingredientSelect); try { makeMenuItems(ingredientSelect, server.getIngredients(), Ingredient::getName, i -> {