Class Controller


  • public class Controller
    extends java.lang.Object
    The main class for the GUI, it holds every component and all interactions the user can do.
    Author:
    Jairo Garciga
    • Field Summary

      Fields 
      Modifier and Type Field Description
      javafx.scene.control.Tab tab1  
    • Constructor Summary

      Constructors 
      Constructor Description
      Controller()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addToProductDB()
      First, it creates the connections to the database.
      void addToProductionRecordDB()
      First sets up connection to the Database.
      void btnAddProductPressed()
      Method called when the "Add Product Pressed" Button is pressed
      void btnRecordProductionPressed()
      Method called when "Record Production" pressed
      void clearProductionLog()
      Simply clears the productionLog, used for readability.
      void databaseNotFound()
      Error response for if the database is missing.
      void enterEmployee()
      Creates a tempEmployee from text in the name and password text boxes on the employees tab of the program.
      void getPassword()
      Accesses res/properties to get the password String, then it calls reverseString to reverse the password String.
      void getSelectedProduct()
      Grabs the selected product from listView, then grabs the number from the combobox for quantity, and creates x amount of that product to then put into productionRun which keeps track of every product that has been produced.
      void initialize()
      Upon the creation of the screen, the combobox is updated and it's becomes editable.
      void loadProductionLog()
      Connects to database and creates productionRecord objects from PRODUCTIONRECORD In order to calculate the right type totals updateTypeTotals is called.
      void loadProductList()
      Connects to database and creates products from PRODUCT table Then adds these created products to the productLine
      void populateListChooseProduct()
      Sets the listViewProducts to the productLine
      java.lang.String reverseString​(java.lang.String pw)
      Recursive method to reverse the password String, could theoretically be used for other Strings too
      void setComboBoxes()
      The purpose of this method is set up the combo boxes instead of flooding initialize with too much code.
      void setLabelErrorMessage​(java.lang.String message)
      Changes the message in the error message below manufacturer text box.
      void showProduction()
      Loops over productRecord, and adds the string form of each object to the productionLogTxt box in production log tab.
      static void testMultimedia()
      Testing method to see if the child classes for Product work.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • tab1

        public javafx.scene.control.Tab tab1
    • Constructor Detail

      • Controller

        public Controller()
    • Method Detail

      • initialize

        public void initialize()
        Upon the creation of the screen, the combobox is updated and it's becomes editable.
      • setComboBoxes

        public void setComboBoxes()
        The purpose of this method is set up the combo boxes instead of flooding initialize with too much code. First it does cmbbItemType then cmbbChooseQuantity.
      • populateListChooseProduct

        public void populateListChooseProduct()
        Sets the listViewProducts to the productLine
      • btnAddProductPressed

        public void btnAddProductPressed()
        Method called when the "Add Product Pressed" Button is pressed
      • btnRecordProductionPressed

        public void btnRecordProductionPressed()
        Method called when "Record Production" pressed
      • enterEmployee

        public void enterEmployee()
        Creates a tempEmployee from text in the name and password text boxes on the employees tab of the program.
      • getSelectedProduct

        public void getSelectedProduct()
        Grabs the selected product from listView, then grabs the number from the combobox for quantity, and creates x amount of that product to then put into productionRun which keeps track of every product that has been produced. TL;DR Adds to the record of products using listViewProducts and cmbbChooseQuantity
      • addToProductDB

        public void addToProductDB()
        First, it creates the connections to the database. Then it sets up variables for connections and statements A preparedStatement is called to insert values from the text fields, then a statement is used to output the PRODUCT Table to the console.
      • addToProductionRecordDB

        public void addToProductionRecordDB()
        First sets up connection to the Database. SQL statement grabs everything in productionRun and sends it to the database. It resets all the saved counts for the productionRun types since productionRecord objects are created very often, it would be bad to accidentally exponentially increase it.
      • loadProductList

        public void loadProductList()
        Connects to database and creates products from PRODUCT table Then adds these created products to the productLine
      • loadProductionLog

        public void loadProductionLog()
        Connects to database and creates productionRecord objects from PRODUCTIONRECORD In order to calculate the right type totals updateTypeTotals is called. Finally adds the new productionRecord objects into productionLog
      • showProduction

        public void showProduction()
        Loops over productRecord, and adds the string form of each object to the productionLogTxt box in production log tab.
      • clearProductionLog

        public void clearProductionLog()
        Simply clears the productionLog, used for readability.
      • reverseString

        public java.lang.String reverseString​(java.lang.String pw)
        Recursive method to reverse the password String, could theoretically be used for other Strings too
        Parameters:
        pw - The string representing the reversed password in properties
        Returns:
        The String now reversed
      • getPassword

        public void getPassword()
        Accesses res/properties to get the password String, then it calls reverseString to reverse the password String. Finally sets that String to the public object variable.
      • databaseNotFound

        public void databaseNotFound()
        Error response for if the database is missing. Product name text box will prompt user to restart the program.
      • setLabelErrorMessage

        public void setLabelErrorMessage​(java.lang.String message)
        Changes the message in the error message below manufacturer text box.
        Parameters:
        message - The error message
      • testMultimedia

        public static void testMultimedia()
        Testing method to see if the child classes for Product work.