Skip to content
Snippets Groups Projects
Commit a24adfdf authored by HSoreide's avatar HSoreide
Browse files

Initialize ingredients at hand and recipe register from file in SuggestRecipesController

parent d21b72ab
No related branches found
No related tags found
2 merge requests!42Hs frontend recipes,!41Hs frontend recipes
Pipeline #215611 passed
package no.ntnu.idatt1002.demo.controller;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
......@@ -13,7 +14,11 @@ import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.DialogPane;
import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Economics.Expense;
import no.ntnu.idatt1002.demo.data.Economics.FileHandling;
import no.ntnu.idatt1002.demo.data.Economics.Income;
import no.ntnu.idatt1002.demo.data.Economics.IncomeRegister;
import no.ntnu.idatt1002.demo.data.recipes.*;
import java.io.IOException;
import java.net.URL;
......@@ -22,7 +27,9 @@ import java.util.ResourceBundle;
public class SuggestRecipesController implements Initializable {
FileHandling fileHandling;
IngredientsAtHand ingredientsAtHand;
RecipeRegister recipeRegister;
@FXML
private Button addToFridgeBtn;
......@@ -30,6 +37,10 @@ public class SuggestRecipesController implements Initializable {
@FXML
private Button goBackBtn;
private ObservableList<FoodItem> fridge;
private ObservableList<Recipe> recipes;
@FXML
private void addIngredient(ActionEvent event) throws IOException {
......@@ -42,13 +53,13 @@ public class SuggestRecipesController implements Initializable {
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setDialogPane(addIngredientPane);
dialog.setTitle("Hallays!");
dialog.setTitle("Add ingredient to fridge");
Optional<ButtonType> clickedButton = dialog.showAndWait();
if (clickedButton.get() == ButtonType.OK) {
System.out.printf("Clickecked OK!");
System.out.println("Clickecked OK!");
}else if(clickedButton.get() == ButtonType.CANCEL) {
System.out.printf("Close the dialog");
System.out.println("Close the dialog");
}
......@@ -69,22 +80,15 @@ public class SuggestRecipesController implements Initializable {
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
fileHandling = new FileHandling();
/*
//Initialize columns
setColumns();
ingredientsAtHand = FileHandler.readIngredientsAtHand("Fridge");
fridge = FXCollections.observableArrayList(ingredientsAtHand.getIngredientsAtHand());
//Initialize registers and tableview
incomeRegister = loadIncomeDataFromFile("Income");
income = FXCollections.observableArrayList(incomeRegister.getItems());
incomeTableView.setItems(income);
recipeRegister = FileHandler.readRecipeRegister("Recipes");
recipes = FXCollections.observableArrayList(recipeRegister.getRecipes());
expenseRegister = loadExpenseDataFromFile("Expense");
expenses = FXCollections.observableArrayList(expenseRegister.getItems());
expenseTableView.setItems(expenses);*/
}
}
......@@ -73,7 +73,7 @@ public class FileHandler {
}
public static RecipeRegister readRecipeRegister(String title) throws FileNotFoundException {
public static RecipeRegister readRecipeRegister(String title) {
File file = new File(filePath + title + fileType);
RecipeRegister register = new RecipeRegister();
......
POTATO
MILK
LEMON
MINCED_MEAT
\ No newline at end of file
# Meat, cheese and potatoes
- MINCED_MEAT | 500.0 | GR
- POTATO | 750.0 | GR
- YELLOW_CHEESE | 2.0 | DL
Instructions must be written continuously in one line. No line shifts.
Testing another line of instructions!
# Meat, cheese and lemons
- MINCED_MEAT | 500.0 | GR
- LEMON | 750.0 | GR
- YELLOW_CHEESE | 2.0 | DL
Instructions
# Another recipe added for testing
- ONION | 5.0 | PC
- LEMON | 750.0 | GR
- POTATO | 10.0 | PC
Instructions for another dish.
\ No newline at end of file
......@@ -13,8 +13,6 @@ Testing another line of instructions!
Instructions
# Another recipe added for testing
- ONION | 5.0 | PC
- LEMON | 750.0 | GR
......
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