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

"Added else statement for preventing edit popup if no item is selected. Moved...

"Added else statement for preventing edit popup if no item is selected. Moved refresh method. Moved brackets of else if which prevented screen switching"
parent 032a4524
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
......@@ -137,17 +137,19 @@ public class ExpensesController {
if (event.getSource().equals(addBtn)) {
dialogMode = DialogMode.ADD;
dialogTitle = "Add expense";
dialog.setTitle(dialogTitle);
dialog.showAndWait();
} else if (event.getSource().equals(editBtn)
&& expenseTableView.getSelectionModel().getSelectedItem() != null) {
dialogMode = DialogMode.EDIT;
dialogTitle = "Edit expense";
newExpense = expenseTableView.getSelectionModel().getSelectedItem();
dialogController.setExpense(newExpense);
dialog.setTitle(dialogTitle);
dialog.showAndWait();
} else {
return;
}
dialog.setTitle(dialogTitle);
dialog.showAndWait();
// Show the Dialog and wait for the user to close it
//Get the newly created expense from the dialog pane
......@@ -155,9 +157,8 @@ public class ExpensesController {
if (newExpense != null && dialogMode == DialogMode.ADD) {
expenseRegister.addItem(newExpense);
refreshObservableList();
}
refreshObservableList();
}
//Only add the expense to the tableview, if the expense is not null
......@@ -219,7 +220,7 @@ public class ExpensesController {
loader.setLocation(SceneController.class.getResource("/view/FirstMenu.fxml"));
} else if (event.getSource() == budgetBtn) {
loader.setLocation(SceneController.class.getResource("/view/underProgress.fxml"));
}
Parent root = loader.load();
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
......@@ -227,4 +228,3 @@ public class ExpensesController {
stage.show();
}
}
}
\ No newline at end of file
......@@ -135,6 +135,8 @@ public class IncomeController {
dialogTitle = "Edit income";
newIncome = incomeTableView.getSelectionModel().getSelectedItem();
dialogController.setIncome(newIncome);
} else {
return;
}
dialog.setTitle(dialogTitle);
......@@ -145,9 +147,8 @@ public class IncomeController {
if (newIncome != null && dialogMode == DialogMode.ADD) {
incomeRegister.addItem(newIncome);
refreshObservableList();
}
refreshObservableList();
}
//Only add the income to the tableview, if the income is not null
......@@ -209,7 +210,7 @@ public class IncomeController {
loader.setLocation(SceneController.class.getResource("/view/FirstMenu.fxml"));
} else if (event.getSource() == budgetBtn) {
loader.setLocation(SceneController.class.getResource("/view/underProgress.fxml"));
}
Parent root = loader.load();
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
......@@ -217,4 +218,3 @@ public class IncomeController {
stage.show();
}
}
}
\ No newline at end of file
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