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

updatet setImage in recipe creator and editor, might be not correct yet in recipe creator

parent 1e9627de
No related branches found
No related tags found
No related merge requests found
......@@ -226,8 +226,9 @@ public class RecipeEditorController extends BaseController {
recipe.setCategoriesFromObjects(List.copyOf(selectedCategories));
String prepTime = prepTimeTextField.getText();
recipe.setPreparationTimeMins( isInteger(prepTime) ? Integer.parseInt(prepTime) : null);
//recipe.setImage(imagePathTextField.getText());
//TODO: set Image properly
if (Files.exists(Paths.get(new URI(imagePathTextField.getText())))) {
recipe.setImage(new URL(imagePathTextField.getText()));
}
log.info("Recipe '{}' was edited.", recipe.getName());
changeSceneToRecipe();
} catch (InvalidRecipeException e) {
......@@ -244,6 +245,11 @@ public class RecipeEditorController extends BaseController {
a.show();
log.error(e.getMessage());
log.error("Recipe not created.");
} catch (MalformedURLException | URISyntaxException e) {
recipe.setImage(Recipe.class.getResource("/images/dish-fork-and-knife.png"));
log.error("Invalid image path, loaded default image.");
log.info("Recipe '{}' was created.", recipe.getName());
changeScene(View.RECIPE_VIEW, recipe);
}
}
......
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