Skip to content
Snippets Groups Projects
Forked from Surya Bahadur Kathayat / idatt1002
This fork has diverged from the upstream repository.
FinanceController.java 1.68 KiB
package no.ntnu.idatt1002.demo.controller;

import java.awt.event.ActionEvent;
import java.io.IOException;
import java.util.Optional;
import javafx.scene.control.ButtonType;

/**
 * Interface for controllers for scenes with finance tableviews.
 *
 * @author Harry Linrui Xu
 * @since 29.3.2023
 */
public interface FinanceController {


  /**
   * Method for handling the adding of new entries in the tableview.
   * @param event A button click on the add button.
   */
  void handleAddBtn(javafx.event.ActionEvent event);

  /**
   * Method for handling the editing of a chosen entry in the tableview.
   * @param event A button click on the edit button.
   */
  void handleEditBtn(javafx.event.ActionEvent event);

  /**
   * Deletes an entry from the tableview, if an entry has been selected. The method brings up a popup window, asking for confirmation for deleting the entry.
   * @param event A button click on the delete button
   */
  void handleDeleteBtn(javafx.event.ActionEvent event);

  /**
   * Method for synching the register with the tableview. The observable list to which the tableview is set, is being refilled with all the entries
   * in the register, keeping it updated with new changes.
   */
  void refreshTableView();

  /**
   * Returns an optional, which is a popup alert box, asking for confirmation for deleting an entry.
   * @return An alert box, asking for confirmation for deleting the selected entry of the tableview.
   */
  Optional<ButtonType> showConfirmationDialog();

  /**
   * Saves the changes made to the tableview by writing the information to a file.
   * @throws IOException If an error occurs while writing to the file.
   */
  void saveDataToFile() throws IOException;
}