Package Controller
Class EditMenuController
java.lang.Object
Controller.EditMenuController
Controller for the Edit Menu Screen
- Since:
- 2023-03-07
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.control.TextFieldTextFieldto allow for user input to add aMenuItemprivate javafx.scene.control.ButtonButtonthat will triggeraddItemClicked(ActionEvent)private javafx.scene.control.TextFieldTextFieldto allow for user input to add aMenuItemprivate javafx.scene.control.TextFieldTextFieldto allow for user input to add aMenuItemprivate DatabaseConnectConnection to the databaseprivate javafx.scene.control.ButtonButtonButton to navigate to the data trends sceneprivate javafx.scene.control.ButtonButtonthat will triggerdeleteItemClicked(ActionEvent)private javafx.scene.control.TextFieldTextFieldto allow for user input to remove aMenuItemprivate javafx.scene.control.ButtonButtonButton to navigate edit menu sceneprivate javafx.scene.control.ButtonButtonButton to navigate employees sceneprivate javafx.scene.control.ButtonButtonButton to navigate inventory sceneprivate javafx.scene.control.ButtonButtonButton to logoutTableColumndisplaying the ID number ofMenuItemTableColumndisplaying the name of theMenuItemTableColumndisplaying the price of theMenuItemprivate javafx.scene.control.TableView<MenuItem>TableViewofMenuItemto displayTableColumndisplaying the quantity ofMenuItemsoldprivate javafx.scene.control.ButtonButtonButton to navigate order sceneprivate javafx.scene.control.ButtonButtonButton to navigate order history sceneprivate SceneSwitchSwitches between scenes or tabsprivate SessionDataCurrent session dataprivate javafx.scene.control.TextFieldTextFieldto allow for user input to update aMenuItemprivate javafx.scene.control.TextFieldTextFieldto allow for user input to update aMenuItemprivate javafx.scene.control.ButtonButtonthat will triggerupdateItemClicked(ActionEvent)private javafx.scene.control.TextFieldTextFieldto allow for user input to update aMenuItemprivate javafx.scene.control.TextFieldTextFieldto allow for user input to update aMenuItem -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor to prevent errorsEditMenuController(SessionData session) Allows for passing session data from scene to scene -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItemClicked(javafx.event.ActionEvent e) If item doesn't exist, it adds it to menu table and adds its recipe to the recipeitem tableprivate voidaddItemsToRecipe(Map<Long, Long> recipeMap, long menuID) Adds items to the recipe tableprivate voidReset all text fields that get user input for editing a menu item to nullvoiddeleteItemClicked(javafx.event.ActionEvent e) Remove item from menu table and recipe item table if it existsprivate javafx.collections.ObservableList<MenuItem>Gets all menu items from the databasevoidLoads menu items onto screen from database.voidnavButtonClicked(javafx.event.ActionEvent event) Handle switching scenes through the navigation barparseRecipe(String[] recipe) private voidremoveItemsFromRecipe(long menuID) Remove all recipe items from the recipe table that have a specified menu ID numberprivate voidInitialized the columns formenuTablevoidupdateItemClicked(javafx.event.ActionEvent e) Update existing item in the menuitem table.private voidUpdatesmenuTablein the Graphical User Interface
-
Field Details
-
session
Current session data- See Also:
-
database
Connection to the database- See Also:
-
sceneSwitch
Switches between scenes or tabs- See Also:
-
orderButton
private javafx.scene.control.Button orderButtonButtonButton to navigate order scene -
orderHistoryButton
private javafx.scene.control.Button orderHistoryButtonButtonButton to navigate order history scene -
inventoryButton
private javafx.scene.control.Button inventoryButtonButtonButton to navigate inventory scene -
employeesButton
private javafx.scene.control.Button employeesButtonButtonButton to navigate employees scene -
editMenuButton
private javafx.scene.control.Button editMenuButtonButtonButton to navigate edit menu scene -
dataTrendsButton
private javafx.scene.control.Button dataTrendsButtonButtonButton to navigate to the data trends scene -
logoutButton
private javafx.scene.control.Button logoutButtonButtonButton to logout -
numberSold
TableColumndisplaying the quantity ofMenuItemsold -
updateIDText
private javafx.scene.control.TextField updateIDTextTextFieldto allow for user input to update aMenuItem -
updateNameText
private javafx.scene.control.TextField updateNameTextTextFieldto allow for user input to update aMenuItem -
updateCostText
private javafx.scene.control.TextField updateCostTextTextFieldto allow for user input to update aMenuItem -
updateRecipeText
private javafx.scene.control.TextField updateRecipeTextTextFieldto allow for user input to update aMenuItem -
addNameText
private javafx.scene.control.TextField addNameTextTextFieldto allow for user input to add aMenuItem -
addCostText
private javafx.scene.control.TextField addCostTextTextFieldto allow for user input to add aMenuItem -
addRecipeText
private javafx.scene.control.TextField addRecipeTextTextFieldto allow for user input to add aMenuItem -
deleteItemID
private javafx.scene.control.TextField deleteItemIDTextFieldto allow for user input to remove aMenuItem -
updateItemButton
private javafx.scene.control.Button updateItemButtonButtonthat will triggerupdateItemClicked(ActionEvent) -
addItemButton
private javafx.scene.control.Button addItemButtonButtonthat will triggeraddItemClicked(ActionEvent) -
deleteItemButton
private javafx.scene.control.Button deleteItemButtonButtonthat will triggerdeleteItemClicked(ActionEvent)
-
-
Constructor Details
-
EditMenuController
public EditMenuController()Default constructor to prevent errors -
EditMenuController
Allows for passing session data from scene to scene- Parameters:
session-SessionDatapassed in fromSceneSwitch
-
-
Method Details
-
initialize
public void initialize()Loads menu items onto screen from database. Sets other fields to null -
updateItemClicked
public void updateItemClicked(javafx.event.ActionEvent e) Update existing item in the menuitem table. First checks if the item exists, then updates its values that the user entered that aren't null, then updates the recipeitem table- Parameters:
e-ActionEventofupdateItemButton
-
addItemClicked
public void addItemClicked(javafx.event.ActionEvent e) If item doesn't exist, it adds it to menu table and adds its recipe to the recipeitem table- Parameters:
e-ActionEventofaddItemButton
-
deleteItemClicked
public void deleteItemClicked(javafx.event.ActionEvent e) Remove item from menu table and recipe item table if it exists- Parameters:
e-ActionEventofdeleteItemClicked(ActionEvent)
-
clearTextFields
private void clearTextFields()Reset all text fields that get user input for editing a menu item to null -
setUpTable
private void setUpTable()Initialized the columns formenuTable -
getMenuItems
Gets all menu items from the database- Returns:
ObservableListofMenuItem
-
updateTable
private void updateTable()UpdatesmenuTablein the Graphical User Interface -
parseRecipe
-
addItemsToRecipe
Adds items to the recipe table- Parameters:
recipeMap-Mapparsed byparseRecipe(String[])menuID- ID number of the menu item
-
removeItemsFromRecipe
private void removeItemsFromRecipe(long menuID) Remove all recipe items from the recipe table that have a specified menu ID number- Parameters:
menuID- ID number of the menu to remove from the recipe table.
-