Skip to content
Snippets Groups Projects
Commit 8dc645d6 authored by Andreas Kluge Svendsrud's avatar Andreas Kluge Svendsrud
Browse files

Merge branch 'frontend-testing' into 'master'

Added input validation to add dialog boxes.

See merge request !32
parents 48ed9bb5 2297af96
No related branches found
No related tags found
2 merge requests!35Budget,!32Added input validation to add dialog boxes.
Pipeline #214633 passed
Showing
with 583 additions and 218 deletions
......@@ -7,8 +7,10 @@ import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Budget.BudgetItem;
import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory;
......@@ -37,7 +39,14 @@ public class AddBudgetController {
private Button okBtn;
@FXML
private Button cancelButton;
private Button cancelBtn;
/**
* Initializes the category drop box by filling it with all the values from the ExpenseCategory enum.
* It then sets a prompt text on the box.
*/
@FXML
private Text errorMsg;
/**
* Initializes the category drop box by filling it with all the values from the ExpenseCategory enum.
......@@ -51,7 +60,10 @@ public class AddBudgetController {
//Set the values inside the dropbox
categoryVariable.setItems(expenseCategories);
//Set default value
categoryVariable.setPromptText("Category");
categoryVariable.setValue(ExpenseCategory.FOOD);
addEventFilters();
}
public ExpenseCategory getCategory(){
......@@ -89,7 +101,7 @@ public class AddBudgetController {
* @param event If the OK button is pressed.
*/
@FXML
public void pressOkBtn(ActionEvent event) {
private void pressOkBtn(ActionEvent event) {
//Instantiates a new budget item
if(newBudgetItem == null){
ExpenseCategory category = getCategory();
......@@ -108,11 +120,37 @@ public class AddBudgetController {
stage.close();
}
private void addEventFilters() {
okBtn.addEventFilter(
ActionEvent.ACTION, event -> {
try {
validateInputs();
} catch(IllegalArgumentException e) {
event.consume();
errorMsg.setOpacity(1);
}
}
);
}
private boolean validateInputs() {
try {
BudgetItem item = new BudgetItem(
Double.parseDouble(amountVariable.getText()),
descriptionVariable.getText(),
categoryVariable.getValue());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid inputs. Cannot instantiate item", e);
}
return true;
}
/**
* Closes the dialog box.
* @param actionEvent A button click on the close button.
*/
public void closeButton(ActionEvent actionEvent) {
@FXML
private void pressCancelBtn(ActionEvent actionEvent) {
final Node source = (Node) actionEvent.getSource();
final Stage stage = (Stage) source.getScene().getWindow();
stage.close();
......
......@@ -14,7 +14,9 @@ import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Budget.BudgetItem;
import no.ntnu.idatt1002.demo.data.Economics.Expense;
import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory;
import no.ntnu.idatt1002.demo.data.Economics.Expense;
......@@ -39,6 +41,9 @@ public class AddExpenseController {
@FXML
private TextField dateField;
@FXML
private Text errorMsg;
@FXML
private DatePicker datePicker;
......@@ -75,6 +80,9 @@ public class AddExpenseController {
//Set date to today
datePicker.setValue(LocalDate.now());
//Adding event filter to okBtn
addEventFilters();
}
public ExpenseCategory getCategory() {
......@@ -138,6 +146,8 @@ public class AddExpenseController {
chosenExpense.setDate(datePicker.getValue());
}
errorMsg.setOpacity(0);
final Node source = (Node) event.getSource();
((Stage) source.getScene().getWindow()).close();
}
......@@ -153,4 +163,28 @@ public class AddExpenseController {
stage.close();
}
private void addEventFilters() {
okBtn.addEventFilter(
ActionEvent.ACTION, event -> {
try {
validateInputs();
} catch(IllegalArgumentException e) {
event.consume();
errorMsg.setOpacity(1);
}
});
}
private boolean validateInputs() {
try {
Expense expense = new Expense(
Double.parseDouble(amountField.getText()), recurringBox.getValue(),
categoryBox.getValue(), datePicker.getValue());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid input. Cannot instantiate expense", e);
}
return true;
}
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Economics.Expense;
import no.ntnu.idatt1002.demo.data.Economics.Income;
......@@ -36,6 +37,8 @@ public class AddIncomeController {
@FXML
private Button okBtn;
@FXML
private Text errorMsg;
@FXML
private DatePicker datePicker;
......@@ -72,6 +75,8 @@ public class AddIncomeController {
//Set date to today
datePicker.setValue(LocalDate.now());
addEventFilters();
}
public IncomeCategory getCategory() {
......@@ -100,9 +105,7 @@ public class AddIncomeController {
chosenIncome.recurringProperty().bindBidirectional(income.recurringProperty());
chosenIncome.incomeCategoryObjectProperty().bindBidirectional(income.incomeCategoryObjectProperty());
chosenIncome.dateProperty().bindBidirectional(income.dateProperty());
descriptionField.textProperty().set(income.getDescription());
amountField.textProperty().setValue(String.valueOf(income.getAmount()));
recurringBox.setValue(income.isRecurring());
//Set the values of the input fields of the dialog box
descriptionField.textProperty().set(income.getDescription());
......@@ -121,7 +124,7 @@ public class AddIncomeController {
@FXML
public void pressOkBtn(ActionEvent event) {
//Instantiates a new income
if (chosenIncome == null) {
if (newIncome == null) {
LocalDate date = datePicker.getValue();
double amount = Double.parseDouble(amountField.getText());
String description = descriptionField.getText();
......@@ -142,6 +145,27 @@ public class AddIncomeController {
((Stage) source.getScene().getWindow()).close();
}
private void addEventFilters() {
okBtn.addEventFilter(
ActionEvent.ACTION, event -> {
try {
validateInputs();
} catch(IllegalArgumentException e) {
event.consume();
errorMsg.setOpacity(1);
}
});
}
private boolean validateInputs() {
try {
Income income = new Income(
Double.parseDouble(amountField.getText()), recurringBox.getValue(),
categoryBox.getValue(), datePicker.getValue());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid inputs. Cannot instantiate income", e);
}
return true;
}
/**
* Closes the dialog box and cancels any pending changes.
......
package no.ntnu.idatt1002.demo.controller;
import java.time.LocalDate;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
......@@ -60,6 +61,9 @@ public class BudgetController implements FinanceController {
@FXML
private Text sum;
@FXML
private DatePicker date;
@FXML
private TableColumn<BudgetItem, Double> percentageColumn;
......@@ -74,7 +78,11 @@ public class BudgetController implements FinanceController {
@FXML
public void initialize() throws IOException {
//TODO if budget is not empty - disable
//TODO if budget is not empty (HAS VALUES) -> make uneditable -> EVENT FILTER TO CONTEXT MENU
//TODO disable return to main menu when creating budget because this is the same view as when you create budeget
//TODO make budget item throw exception with negative amount
//TODO specify error messgage for when amount is exceeded / duplicate exists
//todo properly close screen so things are saved
//Initialize table columns
categoryCol.setCellValueFactory(new PropertyValueFactory<BudgetItem, ExpenseCategory>("budgetCategory"));
amountCol.setCellValueFactory(new PropertyValueFactory<BudgetItem, Double>("budgetAmount"));
......@@ -85,18 +93,34 @@ public class BudgetController implements FinanceController {
budgetList = FXCollections.observableArrayList(general.getBudgetItems());
budgetTableView.setItems(budgetList);
formatDatePicker();
//createBudgetPieChart();
//Initialize sum field under the tableview
//sum.setText(String.valueOf(general.totalSum()));
}
private ObservableList<PieChart.Data> createBudgetPieChart() { //TODO DOESNT WORK IF BUDGETITEM HAS NO BUDGET
return FXCollections.observableArrayList(
new Data("Food", general.getBudgetItem(ExpenseCategory.FOOD).getBudgetAmount()),
new Data("Books", general.getBudgetItem(ExpenseCategory.BOOKS).getBudgetAmount()),
new Data("Clothes", general.getBudgetItem(ExpenseCategory.CLOTHES).getBudgetAmount()),
new Data("Other", general.getBudgetItem(ExpenseCategory.OTHER).getBudgetAmount())
);
private ObservableList<PieChart.Data> createBudgetPieChart() throws IllegalArgumentException { //TODO DOESNT WORK IF BUDGETITEM HAS NO BUDGET
try {
return FXCollections.observableArrayList(
new Data("Food", general.getBudgetItem(ExpenseCategory.FOOD).getBudgetAmount()),
new Data("Books", general.getBudgetItem(ExpenseCategory.BOOKS).getBudgetAmount()),
new Data("Clothes",
general.getBudgetItem(ExpenseCategory.CLOTHES).getBudgetAmount()),
new Data("Other", general.getBudgetItem(ExpenseCategory.OTHER).getBudgetAmount())
);
} catch(IllegalArgumentException iae) {
return FXCollections.observableArrayList();
}
}
/**
* Method for disabling the date picker, yet having its opacity at max.
*/
private void formatDatePicker() {
date.setValue(LocalDate.now());
date.setDisable(true);
date.setStyle("-fx-opacity: 1");
date.getEditor().setStyle("-fx-opacity: 1");
}
@Override
......@@ -114,7 +138,7 @@ public class BudgetController implements FinanceController {
String dialogTitle = "";
DialogMode dialogMode;
FXMLLoader loader = new FXMLLoader(SceneController.class.getResource("/view/AddBudget.fxml"));
FXMLLoader loader = new FXMLLoader(SceneController.class.getResource("/view/AddBudgetNew.fxml"));
Dialog<BudgetItem> dialog = new Dialog<>();
dialog.initModality(Modality.APPLICATION_MODAL);
......@@ -189,7 +213,7 @@ public class BudgetController implements FinanceController {
public void refreshTableView(){
this.budgetList.setAll(general.getBudgetItems());
//Refreshing the sum of the amounts of the budget
this.sum.setText(String.valueOf(general.totalSum()));
//this.sum.setText(String.valueOf(general.totalSum()));
}
/**
......@@ -240,6 +264,7 @@ public class BudgetController implements FinanceController {
//Instantiate new budget
if (fileHandlingBudget.isEmpty(fileName)) {
general = new GeneralBudget(31, 1000);
//throws new IOException("Not valid budget")
} else { //Load previous budget
try {
general = fileHandlingBudget.readGeneralBudgetFromFile(fileName);
......@@ -251,9 +276,8 @@ public class BudgetController implements FinanceController {
}
/**
* Switches scenes from the budget scene to another, by loading a new FXML file and setting the scene to this location.
* The destination depends entirely on which button is pressed.
* @param event A button click on the buttons on the buttonbar or the next button
* Switches scenes back to main menu, by loading a new FXML file and setting the scene to this location.
* @param event A button click on the return to main menu button
* @throws IOException If an error occurs with loading any of the FXML files.
*/
@FXML
......
......@@ -49,4 +49,11 @@ public interface FinanceController {
* @throws IOException If an error occurs while writing to the file.
*/
void saveDataToFile() throws IOException;
/**
* Switches scenes back to main menu, by loading a new FXML file and setting the scene to this location.
* @param event A button click on the return to main menu button
* @throws IOException If an error occurs with loading any of the FXML files.
*/
void returnToMainMenu(javafx.event.ActionEvent event) throws IOException;
}
......@@ -2,6 +2,7 @@ package no.ntnu.idatt1002.demo.controller;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Optional;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
......@@ -89,12 +90,6 @@ public class IncomeExpenseController implements FinanceController {
@FXML
private MenuItem addIncome;
@FXML
private Button deleteBtn;
@FXML
private Button editBtn;
@FXML
private ProgressBar budgetProgress;
......@@ -112,6 +107,19 @@ public class IncomeExpenseController implements FinanceController {
@FXML
private Label title;
@FXML
private MenuItem editIncomeMenu;
@FXML
private MenuItem deleteIncomeMenu;
@FXML
private MenuItem editExpenseMenu;
@FXML
private MenuItem deleteExpenseMenu;
private IncomeRegister incomeRegister;
private ExpenseRegister expenseRegister;
......@@ -147,15 +155,15 @@ public class IncomeExpenseController implements FinanceController {
expenseTableView.setItems(expenses);
//Setting pie chart values to correspond with the registers
refreshPieCharts();
incomePieChart.setLegendSide(Side.RIGHT);
refreshPieCharts();
expensePieChart.setLegendSide(Side.RIGHT);
expensePieChart.setLabelLineLength(10);
refreshPieCharts();
refreshProgress();
formatDatePicker();
//Initialize sum field under the tableview
// inSum.setText(String.valueOf(incomeRegister.getTotalSum()));
//expSum.setText(String.valueOf(expenseRegister.getTotalSum()));
......@@ -192,20 +200,35 @@ public class IncomeExpenseController implements FinanceController {
);
}
/**
* Method for disabling the date picker, yet having its opacity at max.
*/
private void formatDatePicker() {
date.setValue(LocalDate.now());
date.setDisable(true);
date.setStyle("-fx-opacity: 1");
date.getEditor().setStyle("-fx-opacity: 1");
}
/**
* Method for handling the adding of new entries in the tableview.
* @param event A button click on the add button.
*/
@Override
public void handleAddBtn(javafx.event.ActionEvent event) {
int sizeBf = (expenseRegister.getItems().size() + incomeRegister.getItems().size());
if (event.getSource() == addIncome) {
handleAddIncome();
} else if (event.getSource() == addExpense){
handleAddExpense();
}
refreshTableView();
refreshPieCharts();
refreshProgress();
int sizeAf = (expenseRegister.getItems().size() + incomeRegister.getItems().size());
if (sizeAf != sizeBf) {
refreshTableView();
refreshProgress();
}
}
/**
......@@ -214,26 +237,34 @@ public class IncomeExpenseController implements FinanceController {
* @param event A button click on the edit button.
*/
@Override
public void handleEditBtn(javafx.event.ActionEvent event) {
public void handleEditBtn(javafx.event.ActionEvent event) {
System.out.println(event.getSource());
Income chosenIncome = incomeTableView.getSelectionModel().getSelectedItem();
Expense chosenExpense = expenseTableView.getSelectionModel().getSelectedItem();
if (event.getSource() == editBtn) {
if (chosenIncome!= null) {
handleEditIncome(chosenIncome);
} else if (chosenExpense != null) {
handleEditExpense(chosenExpense);
}
} else if (event.getSource() == deleteBtn) {
if (chosenIncome != null) {
handleDeleteIncome(chosenIncome);
} else if (chosenExpense != null) {
handleDeleteExpense(chosenExpense);
}
boolean isEditIncome = event.getSource() == editIncomeMenu;
boolean isDeleteIncome = event.getSource() == deleteIncomeMenu;
boolean isEditExpense = event.getSource() == editExpenseMenu;
boolean isDeleteExpense = event.getSource() == deleteExpenseMenu;
System.out.println(chosenIncome);
System.out.println(chosenExpense);
if (isEditIncome) {
handleEditIncome(chosenIncome);
} else if (isDeleteIncome) {
handleDeleteIncome(chosenIncome);
} else if (isEditExpense) {
handleEditExpense(chosenExpense);
} else if (isDeleteExpense) {
handleDeleteExpense(chosenExpense);
} else return;
//Updates the tableview and pie chart using the register
refreshTableView();
refreshPieCharts();
refreshProgress();
}
......@@ -261,7 +292,7 @@ public class IncomeExpenseController implements FinanceController {
this.expenses.setAll(expenseRegister.getItems());
//this.sum.setText(String.valueOf(incomeRegister.getTotalSum()));
}
private void refreshPieCharts() {
this.incomePieChart.setData(createIncomePieChart());
this.expensePieChart.setData(createExpensePieChart());
......@@ -302,6 +333,7 @@ public class IncomeExpenseController implements FinanceController {
//Adds the new item to the register
if (newIncome != null) {
incomeRegister.addItem(newIncome);
incomePieChart.setData(createIncomePieChart());
}
}
......@@ -337,11 +369,14 @@ public class IncomeExpenseController implements FinanceController {
//Adds the new item to the register
if (newExpense != null) {
expenseRegister.addItem(newExpense);
expensePieChart.setData(createExpensePieChart());
}
}
@FXML
private void handleEditIncome(Income chosenIncome) {
//Create copy of chosenIncome before changes
//Instantiate FXML loader and loads the popup for adding income
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/view/AddIncome.fxml"));
......@@ -366,6 +401,9 @@ public class IncomeExpenseController implements FinanceController {
dialog.setTitle(dialogTitle);
// Show the Dialog and wait for the user to close it
dialog.showAndWait();
this.incomePieChart.setData(createIncomePieChart());
}
@FXML
......@@ -393,6 +431,8 @@ public class IncomeExpenseController implements FinanceController {
dialog.setTitle(dialogTitle);
// Show the Dialog and wait for the user to close it
dialog.showAndWait();
this.expensePieChart.setData(createExpensePieChart());
}
@FXML
......@@ -401,6 +441,7 @@ public class IncomeExpenseController implements FinanceController {
if (isConfirmed.isPresent() && isConfirmed.get() == ButtonType.OK) {
incomeRegister.removeItem(chosenIncome);
}
this.incomePieChart.setData(createIncomePieChart());
}
@FXML
......@@ -409,7 +450,7 @@ public class IncomeExpenseController implements FinanceController {
if (isConfirmed.isPresent() && isConfirmed.get() == ButtonType.OK) {
expenseRegister.removeItem(chosenExpense);
}
this.expensePieChart.setData(createExpensePieChart());
}
/**
* Returns an optional, which is a popup alert box, asking for confirmation for deleting an
......@@ -499,10 +540,12 @@ public class IncomeExpenseController implements FinanceController {
}
/**
* Switches the scene to the Main Menu scene.
* Switches scenes back to main menu, by loading a new FXML file and setting the scene to this location.
* @param event A button click on the return to main menu button
* @throws IOException If an error occurs with loading any of the FXML files.
*/
@FXML
private void returnToMainMenu(javafx.event.ActionEvent event) throws IOException {
public void returnToMainMenu(javafx.event.ActionEvent event) throws IOException {
saveDataToFile();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/view/MainMenuNew.fxml"));
......
......@@ -93,6 +93,8 @@ public class MainMenu {
//Initialize all controllers
initializeControllers();
mainBar.setStyle("-fx-accent: green;");
double incomeSum = incomeRegister.getTotalSum();
double expenseSum = expenseRegister.getTotalSum();
......@@ -163,6 +165,7 @@ public class MainMenu {
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setResizable(false);
stage.show();
}
}
......
......@@ -33,7 +33,7 @@ public class SceneController {
}
public void switchIncome(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader(SceneController.class.getResource("/view/Income.fxml"));
FXMLLoader loader = new FXMLLoader(SceneController.class.getResource("/view/IncomeAndExpenses.fxml"));
Parent root = loader.load();
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
......
......@@ -5,3 +5,7 @@ budgetAmount=500.0
budgetCategory=FOOD
budgetDescription=dd
budgetAmount=100.0
budgetCategory=CLOTHES
budgetDescription=
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<DialogPane prefHeight="295.0" prefWidth="360.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.AddBudgetController">
<content>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Category">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<Label text="Amount:" GridPane.rowIndex="1">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<Label text="Description:" GridPane.rowIndex="2">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<TextField fx:id="amountVariable" promptText="100" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="descriptionVariable" promptText="(optional)" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<HBox alignment="BOTTOM_RIGHT" prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="4">
<children>
<Button fx:id="cancelBtn" mnemonicParsing="false" onAction="#pressCancelBtn" prefHeight="25.0" prefWidth="60.0" text="Cancel">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Button>
<Button fx:id="okBtn" mnemonicParsing="false" onAction="#pressOkBtn" prefHeight="25.0" prefWidth="60.0" text="OK">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Button>
</children>
<GridPane.margin>
<Insets top="20.0" />
</GridPane.margin>
</HBox>
<Text fx:id="errorMsg" fill="#d90808" opacity="0.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Invalid input. Make sure that amount is an integer above 1" wrappingWidth="300.0" GridPane.columnSpan="3" GridPane.rowIndex="3" GridPane.rowSpan="2">
<font>
<Font name="Lucida Console" size="11.0" />
</font>
</Text>
<ComboBox fx:id="categoryVariable" prefWidth="150.0" GridPane.columnIndex="1" />
</children>
</GridPane>
</content>
</DialogPane>
......@@ -11,6 +11,8 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<DialogPane expanded="true" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.AddExpenseController">
<content>
......@@ -27,27 +29,55 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Date:" />
<Label text="Amount:" GridPane.rowIndex="1" />
<Label text="Description:" GridPane.rowIndex="2" />
<Label text="Category" GridPane.rowIndex="3" />
<Label text="Recurring" GridPane.rowIndex="4" />
<Label text="Date:">
<font>
<Font name="Lucida Console" size="12.0" />
</font></Label>
<Label text="Amount:" GridPane.rowIndex="1">
<font>
<Font name="Lucida Console" size="12.0" />
</font></Label>
<Label text="Description:" GridPane.rowIndex="2">
<font>
<Font name="Lucida Console" size="12.0" />
</font></Label>
<Label text="Category: " GridPane.rowIndex="3">
<font>
<Font name="Lucida Console" size="12.0" />
</font></Label>
<Label text="Recurring: " GridPane.rowIndex="4">
<font>
<Font name="Lucida Console" size="12.0" />
</font></Label>
<TextField fx:id="amountField" promptText="100" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<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="recurringBox" prefWidth="150.0" promptText="No" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<HBox alignment="BOTTOM_RIGHT" prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="5">
<HBox alignment="BOTTOM_RIGHT" prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="7">
<children>
<Button fx:id="cancelBtn" mnemonicParsing="false" onAction="#pressCancelBtn" prefHeight="25.0" prefWidth="60.0" text="Cancel" />
<Button fx:id="okBtn" mnemonicParsing="false" onAction="#pressOkBtn" prefHeight="25.0" prefWidth="60.0" text="OK" />
<Button fx:id="cancelBtn" mnemonicParsing="false" onAction="#pressCancelBtn" prefHeight="25.0" prefWidth="60.0" text="Cancel">
<font>
<Font name="Lucida Console" size="12.0" />
</font></Button>
<Button fx:id="okBtn" mnemonicParsing="false" onAction="#pressOkBtn" prefHeight="25.0" prefWidth="60.0" text="OK">
<font>
<Font name="Lucida Console" size="12.0" />
</font></Button>
</children>
<GridPane.margin>
<Insets top="20.0" />
</GridPane.margin>
</HBox>
<DatePicker fx:id="datePicker" GridPane.columnIndex="1" />
<Text fx:id="errorMsg" fill="#d90808" opacity="0.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Invalid input. Please make sure that amount is an integer above 1." wrappingWidth="300.0" GridPane.columnSpan="3" GridPane.rowIndex="5" GridPane.rowSpan="2">
<font>
<Font name="Lucida Console" size="11.0" />
</font>
</Text>
</children>
</GridPane>
</content>
......
......@@ -11,6 +11,8 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<DialogPane expanded="true" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.AddIncomeController">
<content>
......@@ -27,27 +29,62 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Date:" />
<Label text="Amount:" GridPane.rowIndex="1" />
<Label text="Description:" GridPane.rowIndex="2" />
<Label text="Category" GridPane.rowIndex="3" />
<Label text="Recurring" GridPane.rowIndex="4" />
<Label text="Date:">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<Label text="Amount:" GridPane.rowIndex="1">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<Label text="Description:" GridPane.rowIndex="2">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<Label text="Category: " GridPane.rowIndex="3">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<Label text="Recurring: " GridPane.rowIndex="4">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Label>
<TextField fx:id="amountField" promptText="100" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="descriptionField" promptText="(optional)" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<ComboBox fx:id="categoryBox" prefWidth="150.0" promptText="Choose" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<ComboBox fx:id="categoryBox" prefWidth="150.0" promptText="Food" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<ComboBox fx:id="recurringBox" prefWidth="150.0" promptText="No" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<HBox alignment="BOTTOM_RIGHT" prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="5">
<HBox alignment="BOTTOM_RIGHT" prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="7">
<children>
<Button fx:id="cancelBtn" mnemonicParsing="false" onAction="#pressCancelBtn" prefHeight="25.0" prefWidth="60.0" text="Cancel" />
<Button fx:id="okBtn" mnemonicParsing="false" onAction="#pressOkBtn" prefHeight="25.0" prefWidth="60.0" text="OK" />
<Button fx:id="cancelBtn" mnemonicParsing="false" onAction="#pressCancelBtn" prefHeight="25.0" prefWidth="60.0" text="Cancel">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Button>
<Button fx:id="okBtn" mnemonicParsing="false" onAction="#pressOkBtn" prefHeight="25.0" prefWidth="60.0" text="OK">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
</Button>
</children>
<GridPane.margin>
<Insets top="20.0" />
</GridPane.margin>
</HBox>
<DatePicker fx:id="datePicker" GridPane.columnIndex="1" />
<Text fx:id="errorMsg" fill="#d90808" opacity="0.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Invalid input. Please make sure that amount is an integer above 1." wrappingWidth="300.0" GridPane.columnSpan="3" GridPane.rowIndex="5" GridPane.rowSpan="2">
<font>
<Font name="Lucida Console" size="11.0" />
</font>
</Text>
</children>
</GridPane>
</content>
......
This diff is collapsed.
......@@ -75,7 +75,7 @@
</BorderPane>
<BorderPane prefHeight="64.0" prefWidth="1100.0">
<left>
<HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0" BorderPane.alignment="CENTER">
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" spacing="10.0" BorderPane.alignment="CENTER">
<children>
<MenuButton mnemonicParsing="false" prefHeight="25.0" prefWidth="50.0">
<items>
......@@ -90,30 +90,6 @@
</ImageView>
</graphic>
</MenuButton>
<Button fx:id="editBtn" mnemonicParsing="false" onAction="#handleEditBtn" prefHeight="25.0" prefWidth="60.0">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
<graphic>
<ImageView fitHeight="30.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../Images/edit.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button fx:id="deleteBtn" mnemonicParsing="false" onAction="#handleDeleteBtn" prefHeight="25.0" prefWidth="60.0">
<font>
<Font name="Lucida Console" size="12.0" />
</font>
<graphic>
<ImageView fitHeight="30.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../Images/delete.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
<BorderPane.margin>
<Insets left="30.0" />
......@@ -136,7 +112,7 @@
<center>
<Pane BorderPane.alignment="CENTER">
<children>
<ComboBox fx:id="filter" layoutX="134.0" layoutY="2.0" prefWidth="150.0" promptText="Show">
<ComboBox fx:id="filter" layoutX="135.0" layoutY="25.0" prefWidth="150.0" promptText="Show">
<opaqueInsets>
<Insets />
</opaqueInsets>
......@@ -173,7 +149,8 @@
<contextMenu>
<ContextMenu>
<items>
<MenuItem mnemonicParsing="false" text="Unspecified Action" />
<MenuItem fx:id="editIncomeMenu" mnemonicParsing="false" onAction="#handleEditBtn" text="Edit" />
<MenuItem fx:id="deleteIncomeMenu" mnemonicParsing="false" onAction="#handleDeleteBtn" text="Delete " />
</items>
</ContextMenu>
</contextMenu>
......@@ -220,7 +197,8 @@
<contextMenu>
<ContextMenu>
<items>
<MenuItem mnemonicParsing="false" text="Unspecified Action" />
<MenuItem fx:id="editExpenseMenu" mnemonicParsing="false" onAction="#handleEditBtn" text="Edit" />
<MenuItem fx:id="deleteExpenseMenu" mnemonicParsing="false" onAction="#handleDeleteBtn" text="Delete" />
</items>
</ContextMenu>
</contextMenu>
......
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