Class BudgetController
java.lang.Object
no.ntnu.idatt1002.demo.controller.FinanceController
no.ntnu.idatt1002.demo.controller.BudgetController
Controller for budget scene in the application. This controller manages all actions that relates
to the budget tableview (add, edit and delete), the switching of scenes from the budget scene to
another scene, and the saving of the table, whenever the user switches to another scene.
- Since:
- 24.3.2023
- Author:
- Anders Emil Bergan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavafx.collections.ObservableList<javafx.scene.chart.PieChart.Data>
Method for creating a list of data used for graphing budgets in a pie chart.void
Method for disabling the date picker, yet having its opacity at max.void
handleAddBtn
(javafx.event.ActionEvent event) Method for handling button presses on the add button.void
handleDeleteBtn
(javafx.event.ActionEvent event) Deletes an entry from the tableview, if an entry has been selected.void
handleEditBtn
(javafx.event.ActionEvent event) Adds or edits a budget item, depending on what mode the DialogMode enum is at.void
Initializes the budget register, the observable budget list and the tableview, along with the values of the dropbox used for filtering the tableview.void
Method for refreshing budget pie chart.void
Method for synching the register with the tableview.void
Saves the changes made to the tableview by writing the information to a file.void
switchScene
(javafx.event.ActionEvent event) Switches scene, by loading a new FXML file and setting the scene to this location.void
updateBudgetRegister
(String budgetFolderName) Updates the contents of the budget registers by adding a given budget name.Methods inherited from class no.ntnu.idatt1002.demo.controller.FinanceController
loadBudgetDataFromFile, loadExpenseDataFromFile, loadIncomeDataFromFile, showConfirmationDialog, showErrorDialogBox
-
Constructor Details
-
BudgetController
public BudgetController()
-
-
Method Details
-
initialize
public void initialize()Initializes the budget register, the observable budget list and the tableview, along with the values of the dropbox used for filtering the tableview. -
createPieChart
public javafx.collections.ObservableList<javafx.scene.chart.PieChart.Data> createPieChart() throws IllegalArgumentExceptionMethod for creating a list of data used for graphing budgets in a pie chart. Only data for categories that have been added are included in this list.- Returns:
- An observable list of the sum of expenditure on each category
- Throws:
IllegalArgumentException
- if generalbudget attempts to retrieve a category has not been added to the budget.
-
refreshPieChart
public void refreshPieChart()Method for refreshing budget pie chart. -
formatDatePicker
public void formatDatePicker()Method for disabling the date picker, yet having its opacity at max. -
handleAddBtn
public void handleAddBtn(javafx.event.ActionEvent event) Method for handling button presses on the add button.- Parameters:
event
- A button click on the add button.
-
handleEditBtn
public void handleEditBtn(javafx.event.ActionEvent event) Adds or edits a budget item, depending on what mode the DialogMode enum is at. The method brings up a dialog box popup in which the user can fill and choose values that the budget item will have. Open exiting the popup, the changes the saved to the tableview.- Parameters:
event
- A button click on either the add or delete button.
-
handleDeleteBtn
public void handleDeleteBtn(javafx.event.ActionEvent event) Deletes an entry from the tableview, if an entry has been selected. The method brings up a popup window, asking for confirmation for deleting the entry.- Parameters:
event
- A button click on the delete button
-
refreshTableView
public void refreshTableView()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. -
saveDataToFile
Saves the changes made to the tableview by writing the information to a file.- Throws:
IOException
- If an error occurs while writing to the file.
-
updateBudgetRegister
Updates the contents of the budget registers by adding a given budget name.- Parameters:
budgetFolderName
- The name of the budget project that has been newly created.
-
switchScene
public void switchScene(javafx.event.ActionEvent event) Switches scene, by loading a new FXML file and setting the scene to this location.- Parameters:
event
- A button click on the return to main menu button
-