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

Added a DatePicker to the dialog box for testing

parent 08742725
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
package no.ntnu.idatt1002.demo.controller; package no.ntnu.idatt1002.demo.controller;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.time.LocalDate;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
...@@ -8,6 +9,7 @@ import javafx.fxml.FXML; ...@@ -8,6 +9,7 @@ import javafx.fxml.FXML;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.stage.Stage; import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Economics.Expense; import no.ntnu.idatt1002.demo.data.Economics.Expense;
...@@ -15,7 +17,7 @@ import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory; ...@@ -15,7 +17,7 @@ import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory;
public class AddExpenseController { public class AddExpenseController {
Expense newExpense = null; //the expense that is chosen when editing or the expense that is created when adding Expense newExpense = null; //the expense that is chosen when editing or the expense that is created when adding
Expense oldExpense = null; //an expense that is meant to track the old state of an expense before editing, in case cancel bugtton is clicked Expense chosenExpense = null; //an expense that is meant to track the old state of an expense before editing, in case cancel bugtton is clicked
@FXML @FXML
private Button cancelBtn; private Button cancelBtn;
...@@ -25,6 +27,9 @@ public class AddExpenseController { ...@@ -25,6 +27,9 @@ public class AddExpenseController {
@FXML @FXML
private TextField dateField; private TextField dateField;
@FXML
private DatePicker datePicker;
@FXML @FXML
private TextField descriptionField; private TextField descriptionField;
...@@ -70,13 +75,16 @@ public class AddExpenseController { ...@@ -70,13 +75,16 @@ public class AddExpenseController {
@FXML @FXML
public void pressOkBtn(ActionEvent event) { public void pressOkBtn(ActionEvent event) {
String date = dateField.getText(); if (newExpense == null) {
double amount = Double.parseDouble(amountField.getText()); String date = dateField.getText();
String description = descriptionField.getText(); double amount = Double.parseDouble(amountField.getText());
ExpenseCategory category = getCategory(); String description = descriptionField.getText();
boolean recurring = isRecurring(); ExpenseCategory category = getCategory();
newExpense = new Expense(description, amount, recurring, category, date); boolean recurring = isRecurring();
System.out.println(date + " " + amount + " " + description + " " + category + " " + recurring); newExpense = new Expense(description, amount, recurring, category, date);
System.out.println(date + " " + amount + " " + description + " " + category + " " + recurring);
}
final Node source = (Node) event.getSource(); final Node source = (Node) event.getSource();
((Stage) source.getScene().getWindow()).close(); ((Stage) source.getScene().getWindow()).close();
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?> <?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.DialogPane?> <?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?> <?import javafx.scene.control.TextField?>
...@@ -33,7 +34,6 @@ ...@@ -33,7 +34,6 @@
<Label text="Description:" GridPane.rowIndex="2" /> <Label text="Description:" GridPane.rowIndex="2" />
<Label text="Category" GridPane.rowIndex="3" /> <Label text="Category" GridPane.rowIndex="3" />
<Label text="Recurring" GridPane.rowIndex="4" /> <Label text="Recurring" GridPane.rowIndex="4" />
<TextField fx:id="dateField" promptText="1/1/23" GridPane.columnIndex="1" />
<TextField fx:id="amountField" promptText="100" GridPane.columnIndex="1" GridPane.rowIndex="1" /> <TextField fx:id="amountField" promptText="100" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="descriptionField" promptText="(optional)" GridPane.columnIndex="1" GridPane.rowIndex="2" /> <TextField fx:id="descriptionField" promptText="(optional)" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<ComboBox fx:id="categoryBox" prefWidth="150.0" promptText="Food" GridPane.columnIndex="1" GridPane.rowIndex="3" /> <ComboBox fx:id="categoryBox" prefWidth="150.0" promptText="Food" GridPane.columnIndex="1" GridPane.rowIndex="3" />
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
<Insets top="20.0" /> <Insets top="20.0" />
</GridPane.margin> </GridPane.margin>
</HBox> </HBox>
<DatePicker fx:id="datePicker" GridPane.columnIndex="2" />
<TextField fx:id="dateField" GridPane.columnIndex="1" />
</children> </children>
</GridPane> </GridPane>
</content> </content>
......
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