diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java index 454455335ee5c0e0b8eefb9cfd38dbaf15f48a74..f63eaecbb8196eb92b759242f61dc0fc926056d0 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java @@ -14,6 +14,7 @@ import javafx.scene.Scene; import javafx.scene.chart.PieChart; import javafx.scene.chart.PieChart.Data; import javafx.scene.control.*; +import javafx.scene.control.Alert.AlertType; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.text.Text; import javafx.stage.Modality; @@ -242,6 +243,10 @@ public class BudgetController extends FinanceController { item = budgetTableView.getSelectionModel().getSelectedItem(); //Binds the selected item to another item which is defined in the budgetcontroller budgetController.setBudget(item); + } else if (event.getSource().equals(editBtn) && budgetTableView.getSelectionModel().getSelectedItem() == null) { + showInformationDialog("No entry selected", "Please select the entry you wish" + + " to edit", "Click on the entry you wish to edit, then press the edit button"); + return; } else { return; } @@ -276,6 +281,8 @@ public class BudgetController extends FinanceController { BudgetItem item = budgetTableView.getSelectionModel().getSelectedItem(); //Exits the method if nothing is selected if (item == null) { + showInformationDialog("No entry selected", "Please select the entry you wish" + + " to edit", "Click on the entry you wish to edit, then press the edit button"); return; } //Brings up a confirmation popup @@ -291,6 +298,22 @@ public class BudgetController extends FinanceController { } } + /** + * Displays an information dialog. + + * @param title The dialog box title. + * @param header The dialog box header. + * @param content The dialog box content. + */ + private void showInformationDialog(String title, String header, String content) { + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle(title); + alert.setHeaderText(header); + alert.setContentText(content); + + alert.show(); + } + /** * Method for synching the register with the tableview. The observable list to which the tableview is set, is being refilled with all the entries * in the register, keeping it updated with new changes. @@ -349,12 +372,16 @@ public class BudgetController extends FinanceController { //Always saving the data when switching to main menu saveDataToFile(); } else if (event.getSource() == continueBtn) { + Optional<ButtonType> isConfirmed = showConfirmationDialog("Finish setup" + , "By pressing OK you will complete the budget setup?","" + + "Have you done all the changes you wished to make?"); + if (isConfirmed.isPresent() && isConfirmed.get() == ButtonType.OK) { + loader.setLocation(getClass().getResource("/view/dualList.fxml")); + } else return; //Adds unused categories to the table general.addUnusedCategories(); - updateBudgetRegister(FileHandlingSelectedBudget .readSelectedBudget("budgets/SelectedBudget")); - loader.setLocation(getClass().getResource("/view/MainMenuNew.fxml")); //Always saving the data when switching to main menu saveDataToFile(); diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java index 812eebff257e7b205b911c57ea5332c56af7d93b..fb5a8ead1f6f0798ea75d1762615719ce1ee8bb7 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/SuggestRecipesController.java @@ -6,12 +6,14 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.geometry.Rectangle2D; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; +import javafx.stage.Screen; import javafx.stage.Stage; import no.ntnu.idatt1002.demo.data.recipes.*; @@ -88,7 +90,7 @@ public class SuggestRecipesController implements Initializable { * @throws IOException If the method is unable to set the location based on the provided path of the dialog pane. */ @FXML - private void addIngredient() throws IOException { + private void addIngredient(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("/view/AddIngredient.fxml")); DialogPane addIngredientPane = loader.load(); @@ -97,6 +99,11 @@ public class SuggestRecipesController implements Initializable { dialog.setDialogPane(addIngredientPane); dialog.setTitle("Add ingredient to fridge"); + //Position popup left, allowing for quick comparison between fridge and add list + Rectangle2D bounds = Screen.getPrimary().getVisualBounds(); + dialog.setX((bounds.getWidth() - dialog.getWidth()) /3); + dialog.setY((bounds.getWidth() - dialog.getWidth()) /2); + Optional<ButtonType> clickedButton = dialog.showAndWait(); if (clickedButton.isPresent() && clickedButton.get() == ButtonType.CLOSE) { diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java index 55f80eee1804b49b7427c21ffb560b7dbc38d967..1181ec1cc663e4166b2b5ebd69b54fb3ba03c357 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java @@ -8,26 +8,13 @@ import java.io.FileWriter; import java.io.IOException; //Set titler på hvert vindu - kan gjøres i switch scene -//capsing av titler og font sizing -//HS vindu litt lit venster slik at kjøleskap og søk funker -//Popup for edit og delete button - //Close program properly //close button i first menu //remove printstackstraces //En delete funksjon i select old budget //Endre pakkenavn //Public vs private metoder må sjekkes -//confirmation for når returnBtn som returner til start. "Are you sure you want to go back. Changes will not be saved" // FIKSE TRY CATCHES I ALLE METODENE!!!!!!!!!! -//Bytte oversikt på dualList til Monthly .... - -//System.out.println(System.getProperty("user.dir") + path); = -//C:\Users\xulr0\IdeaProjects\skoleProsjekter\idatt1002\idatt1002_2023_9src/main/resources/ - -//(System.getProperty("user.dir") + "/" + path) = -//(path) = -//(src/main/resources) /** * Class that handles the reading and writing to the budget archive file, diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/MMBI.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/MMBI.java deleted file mode 100644 index fe15c58322935001fb04b138acc63af1adc08dd4..0000000000000000000000000000000000000000 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/MMBI.java +++ /dev/null @@ -1,64 +0,0 @@ -package no.ntnu.idatt1002.demo.data.Budget; - -import javafx.scene.control.ProgressBar; - -/** - * Class that represents the main menu category progress bars. Each bar - * is associated with a corresponding expense category. - * - * @author Anders Emil Bergan. - * @since 17.04.2023. - */ -public class MMBI { - private ProgressBar progressBar; - private BudgetItem budgetItem; - - /** - * Constructor for creating a MMBI. - - * @param item The budget item. - * @param bar The progress bar. - */ - public MMBI(BudgetItem item, ProgressBar bar){ - this.budgetItem = item; - this.progressBar = bar; - - } - - /** - * Gets the budget item. - - * @return the budget item. - */ - public BudgetItem getBudgetItem(){ - return budgetItem; - } - - /** - * Sets the budget item to the argument value. - - * @param item The value to which the budget item will be set. - */ - public void setBudgetItem(BudgetItem item){ - this.budgetItem = item; - } - - /** - * Gets the progress bar. - - * @return the progress bar. - */ - public ProgressBar getBar(){ - return progressBar; - } - - /** - * Sets the progress bar to the argument value. - - * @param bar The value to which the progress bar will be set. - */ - public void setProgressBar(ProgressBar bar){ - this.progressBar = bar; - } - -} diff --git a/src/main/resources/view/AddIngredient.fxml b/src/main/resources/view/AddIngredient.fxml index 3384b11dd2e656b33c21031ce603264f17525783..ed05d4e47d1977359da9b2c59a46862c39c9c16c 100644 --- a/src/main/resources/view/AddIngredient.fxml +++ b/src/main/resources/view/AddIngredient.fxml @@ -1,11 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> -<?import javafx.geometry.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.layout.*?> -<?import javafx.scene.text.*?> +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.ButtonType?> +<?import javafx.scene.control.DialogPane?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.ListView?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Font?> -<DialogPane id="dialog-pane" expanded="true" prefHeight="555.0" prefWidth="614.0" stylesheets="@../style.css" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.AddIngredientController"> +<DialogPane id="dialog-pane" expanded="true" prefHeight="555.0" prefWidth="614.0" stylesheets="@../style.css" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.AddIngredientController"> <content> <AnchorPane prefHeight="400.0" prefWidth="600.0"> <padding> @@ -74,7 +82,7 @@ <children> <Pane prefHeight="100.0" prefWidth="543.0"> <children> - <Label layoutX="19.0" layoutY="30.0" prefWidth="516.0" styleClass="head-line" stylesheets="@../style.css" text="Add ingredients to Fridge"> + <Label layoutX="121.0" layoutY="28.0" prefWidth="516.0" styleClass="head-line" stylesheets="@../style.css" text="Add ingredients"> <font> <Font size="30.0" /> </font> diff --git a/src/main/resources/view/BudgetNewest.fxml b/src/main/resources/view/BudgetNewest.fxml index 4c3169f7728e2f2c1d10495f96eebd303e89406d..fa443449c97c7b2be8b16c150ba4895617669db5 100644 --- a/src/main/resources/view/BudgetNewest.fxml +++ b/src/main/resources/view/BudgetNewest.fxml @@ -128,7 +128,7 @@ <center> <Pane BorderPane.alignment="CENTER"> <children> - <ComboBox fx:id="filter" layoutX="134.0" layoutY="2.0" prefWidth="150.0" promptText="Show"> + <ComboBox fx:id="filter" disable="true" layoutX="134.0" layoutY="2.0" opacity="0.0" prefWidth="150.0" promptText="Show"> <opaqueInsets> <Insets /> </opaqueInsets> diff --git a/src/main/resources/view/IncomeAndExpenses.fxml b/src/main/resources/view/IncomeAndExpenses.fxml index fbaa0cc788b4bb71128ffe2a873d5037e0327969..8493e9de7623e0b42a360317961a0e14240d7f51 100644 --- a/src/main/resources/view/IncomeAndExpenses.fxml +++ b/src/main/resources/view/IncomeAndExpenses.fxml @@ -117,7 +117,7 @@ <center> <Pane BorderPane.alignment="CENTER"> <children> - <ComboBox fx:id="filter" layoutX="74.0" layoutY="19.0" prefWidth="150.0" promptText="Show"> + <ComboBox fx:id="filter" disable="true" layoutX="74.0" layoutY="19.0" opacity="0.0" prefWidth="150.0" promptText="Show"> <opaqueInsets> <Insets /> </opaqueInsets> diff --git a/src/main/resources/view/newBudgetBudgert.fxml b/src/main/resources/view/newBudgetBudgert.fxml index ddd9bd02ba18d7b07138b1adef730a011ad1682f..e11fde863a527a5e821c85e605a7a4874bef240d 100644 --- a/src/main/resources/view/newBudgetBudgert.fxml +++ b/src/main/resources/view/newBudgetBudgert.fxml @@ -181,7 +181,7 @@ </HBox> <HBox alignment="CENTER_RIGHT" prefHeight="42.0" prefWidth="106.0" GridPane.columnIndex="1"> <children> - <ComboBox fx:id="filter" prefHeight="25.0" prefWidth="80.0" promptText="Show"> + <ComboBox fx:id="filter" disable="true" opacity="0.0" prefHeight="25.0" prefWidth="80.0" promptText="Show"> <opaqueInsets> <Insets /> </opaqueInsets>