diff --git a/client/src/main/java/client/scenes/recipe/IngredientListCell.java b/client/src/main/java/client/scenes/recipe/IngredientListCell.java index 7ecc9a7..bdd60ab 100644 --- a/client/src/main/java/client/scenes/recipe/IngredientListCell.java +++ b/client/src/main/java/client/scenes/recipe/IngredientListCell.java @@ -64,21 +64,18 @@ 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 @@ -118,6 +115,7 @@ public class IngredientListCell extends OrderedEditableListCell unitChoice) { - selectedIngredient.setValue(ingredient.getIngredient()); - MenuButton ingredientSelect = new MenuButton(selectedIngredient.get() == null ? - getLocaleString("app.prompt.select-ingredient") : selectedIngredient.get().getName()); + MenuButton ingredientSelect = new MenuButton(getLocaleString("app.prompt.select-ingredient")); HBox container = new HBox(amountInput, unitChoice, ingredientSelect); try { makeMenuItems(ingredientSelect, server.getIngredients(), Ingredient::getName, i -> {