Class AddExpenseController
java.lang.Object
no.ntnu.idatt1002.demo.controller.AddExpenseController
Class that represents the popup dialog box that appears
whenever an expense is to be added or edited.
The dialog contains various fields that are used to
create a new expense or edit an existing expense.
- Since:
- 13.3.2023
- Author:
- Harry Linrui Xu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the value of the category box.Gets the newly created expense.void
Initializes the category and recurring drop boxes by filling them with all the values from the ExpenseCategory enum, and the boolean values respectively, and the datepicker calendar.boolean
Gets the value from the recurring box.void
pressCancelBtn
(javafx.event.ActionEvent event) Closes the dialog box and cancels any pending changes.void
pressOkBtn
(javafx.event.ActionEvent event) Adds a new to the tableview or edits an existing entry in table if the OK button is pressed.void
setExpense
(Expense expense) Binds the expense that is taken in as the argument with an expense declared in this class.
-
Constructor Details
-
AddExpenseController
public AddExpenseController()
-
-
Method Details
-
initialize
public void initialize()Initializes the category and recurring drop boxes by filling them with all the values from the ExpenseCategory enum, and the boolean values respectively, and the datepicker calendar. It then sets them to the default values of GIFT, false and today respectively. -
getCategory
Gets the value of the category box.- Returns:
- The chosen expense category.
-
isRecurring
public boolean isRecurring()Gets the value from the recurring box.- Returns:
- The chosen recurring boolean value.
-
getNewExpense
Gets the newly created expense.- Returns:
- The new expense.
-
setExpense
Binds the expense that is taken in as the argument with an expense declared in this class. The expense of this class is instantiated as a deep copy of the argument. Each attribute of their attributes are then bounded. The text fields and category boxes in the dialog window are then set to the values of the chosen expense, as to not display empty values.- Parameters:
expense
- The expense that is chosen to be edited.
-
pressOkBtn
public void pressOkBtn(javafx.event.ActionEvent event) Adds a new to the tableview or edits an existing entry in table if the OK button is pressed. An entry is edited as the selected entry of the table is bounded to another expense in this class. If this expense is altered, the expense in the tableview will automatically respond with the same changes.- Parameters:
event
- If the OK button is pressed.
-
pressCancelBtn
public void pressCancelBtn(javafx.event.ActionEvent event) Closes the dialog box and cancels any pending changes.- Parameters:
event
- A button click on the cancel button.
-