Skip to content
Snippets Groups Projects
Commit fd6bc368 authored by Harry Linrui XU's avatar Harry Linrui XU
Browse files

"Made sum field refresh with tableview changes"

parent a1a76652
No related branches found
No related tags found
10 merge requests!43Merging frontend-testing into master,!38"Made progressbar dynamic in accordance to spending. Added balance field....,!37Made the sub progress bars respond to changes in expense,!32Added input validation to add dialog boxes.,!30Redesigned scenes,!29Redesigned scenes,!28Redesigned scenes,!26Redesigned Main menu and expense/income windows,!24Merging frontend-testing with master,!23Merging frontend-testing and master
Pipeline #212785 passed
......@@ -17,16 +17,11 @@ import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Budget.BudgetItem;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingBudget;
import no.ntnu.idatt1002.demo.data.Budget.GeneralBudget;
import no.ntnu.idatt1002.demo.data.Economics.Expense;
import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import no.ntnu.idatt1002.demo.data.Economics.FileHandling;
import no.ntnu.idatt1002.demo.data.Economics.IncomeRegister;
public class BudgetController {
......@@ -126,7 +121,7 @@ public class BudgetController {
showIllegalBudgetItemDialog();
}
}
refreshObservableList();
refreshTableView();
}
@FXML
......@@ -145,7 +140,7 @@ public class BudgetController {
Optional<ButtonType> isConfirmed = showConfirmationDialog();
if (isConfirmed.isPresent() && isConfirmed.get() == ButtonType.OK) {
general.deleteItemFromBudget(item.getBudgetCategory());
refreshObservableList();
refreshTableView();
}
}
......@@ -188,8 +183,9 @@ public class BudgetController {
}
protected void refreshObservableList(){
protected void refreshTableView(){
this.budgetList.setAll(general.getBudgetItems());
this.sum.setText(String.valueOf(general.totalSum()));
}
@FXML
......
......@@ -159,7 +159,7 @@ public class ExpensesController {
if (newExpense != null && dialogMode == DialogMode.ADD) {
expenseRegister.addItem(newExpense);
}
refreshObservableList();
refreshTableView();
}
//Only add the expense to the tableview, if the expense is not null
......@@ -172,12 +172,14 @@ public class ExpensesController {
Optional<ButtonType> isConfirmed = showConfirmationDialog();
if (isConfirmed.isPresent() && isConfirmed.get() == ButtonType.OK) {
expenseRegister.removeItem(chosenExpense);
refreshObservableList();
refreshTableView();
}
}
protected void refreshObservableList() {
protected void refreshTableView() {
this.expenses.setAll(expenseRegister.getItems());
this.sum.setText(String.valueOf(expenseRegister.getTotalSum()));
}
private Optional<ButtonType> showConfirmationDialog() {
......
......@@ -27,10 +27,6 @@ import no.ntnu.idatt1002.demo.data.Economics.Income;
import no.ntnu.idatt1002.demo.data.Economics.IncomeCategory;
import no.ntnu.idatt1002.demo.data.Economics.IncomeRegister;
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.Economics.Item;
import no.ntnu.idatt1002.demo.data.Economics.ItemRegister;
public class IncomeController {
......@@ -152,7 +148,7 @@ public class IncomeController {
if (newIncome != null && dialogMode == DialogMode.ADD) {
incomeRegister.addItem(newIncome);
}
refreshObservableList();
refreshTableView();
}
//Only add the income to the tableview, if the income is not null
......@@ -165,12 +161,13 @@ public class IncomeController {
Optional<ButtonType> isConfirmed = showConfirmationDialog();
if (isConfirmed.isPresent() && isConfirmed.get() == ButtonType.OK) {
incomeRegister.removeItem(chosenIncome);
refreshObservableList();
refreshTableView();
}
}
protected void refreshObservableList() {
protected void refreshTableView() {
this.income.setAll(incomeRegister.getItems());
this.sum.setText(String.valueOf(incomeRegister.getTotalSum()));
}
private Optional<ButtonType> showConfirmationDialog() {
......
......@@ -11,7 +11,7 @@ isRecurring=Not recurring
category=OTHER
date=2023-03-26
amount=4000.0
amount=10.0
isRecurring=Not recurring
category=FOOD
......@@ -11,7 +11,7 @@ category=GIFT
date=2023-03-25
description=airbnb
amount=3000.0
amount=1000.0
isRecurring=Not recurring
category=GIFT
......@@ -69,9 +69,9 @@
</ImageView>
<ProgressBar fx:id="progressbar" prefHeight="40.0" prefWidth="554.0" progress="0.72" translateY="-10.0" />
<Label fx:id="today" text="Today" textAlignment="CENTER" translateX="-150.0" translateY="-2.0">
<font>
<Font name="System Bold" size="12.0" />
</font>
<StackPane.margin>
<Insets left="300.0" />
</StackPane.margin>
</Label>
</children>
</StackPane>
......
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