Compare commits
No commits in common. "bb77c832891fd3c08cce2fd5763e5f83b60738e7" and "a32f4cd7814a4e669da60462dfa14120710c52eb" have entirely different histories.
bb77c83289
...
a32f4cd781
1 changed files with 5 additions and 9 deletions
|
|
@ -64,21 +64,18 @@ public class IngredientListCell extends OrderedEditableListCell<RecipeIngredient
|
|||
|
||||
Optional<Double> templateAmount = Optional.empty();
|
||||
Optional<Unit> 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<Unit> unitChoice = new ChoiceBox<>();
|
||||
|
||||
// initialize the current unit if it is present
|
||||
|
|
@ -118,6 +115,7 @@ public class IngredientListCell extends OrderedEditableListCell<RecipeIngredient
|
|||
menu.setText(getLocaleString("app.prompt.new-ingredient")); // otherwise the text label on menu refuses to update
|
||||
selectedIngredient.setValue(null); // indicate null to signal a new ingredient creation
|
||||
logger.info("Making new ingredient");
|
||||
// TODO printError() integration
|
||||
TextField newIngredientNameInput = makeNewIngredientNameField(selectedIngredient::set);
|
||||
container.getChildren().add(newIngredientNameInput);
|
||||
});
|
||||
|
|
@ -137,9 +135,7 @@ public class IngredientListCell extends OrderedEditableListCell<RecipeIngredient
|
|||
}
|
||||
}
|
||||
private HBox makeInputLine(RecipeIngredient ingredient, TextField amountInput, ChoiceBox<Unit> 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 -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue