Class Controller
- java.lang.Object
-
- Controller
-
public class Controller extends java.lang.ObjectThe 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.Tabtab1
-
Constructor Summary
Constructors Constructor Description Controller()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToProductDB()First, it creates the connections to the database.voidaddToProductionRecordDB()First sets up connection to the Database.voidbtnAddProductPressed()Method called when the "Add Product Pressed" Button is pressedvoidbtnRecordProductionPressed()Method called when "Record Production" pressedvoidclearProductionLog()Simply clears the productionLog, used for readability.voiddatabaseNotFound()Error response for if the database is missing.voidenterEmployee()Creates a tempEmployee from text in the name and password text boxes on the employees tab of the program.voidgetPassword()Accesses res/properties to get the password String, then it calls reverseString to reverse the password String.voidgetSelectedProduct()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.voidinitialize()Upon the creation of the screen, the combobox is updated and it's becomes editable.voidloadProductionLog()Connects to database and creates productionRecord objects from PRODUCTIONRECORD In order to calculate the right type totals updateTypeTotals is called.voidloadProductList()Connects to database and creates products from PRODUCT table Then adds these created products to the productLinevoidpopulateListChooseProduct()Sets the listViewProducts to the productLinejava.lang.StringreverseString(java.lang.String pw)Recursive method to reverse the password String, could theoretically be used for other Strings toovoidsetComboBoxes()The purpose of this method is set up the combo boxes instead of flooding initialize with too much code.voidsetLabelErrorMessage(java.lang.String message)Changes the message in the error message below manufacturer text box.voidshowProduction()Loops over productRecord, and adds the string form of each object to the productionLogTxt box in production log tab.static voidtestMultimedia()Testing method to see if the child classes for Product work.
-
-
-
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.
-
-