Package Controller

Class EditMenuController

java.lang.Object
Controller.EditMenuController

public class EditMenuController extends Object
Controller for the Edit Menu Screen
Since:
2023-03-07
  • Field Details

    • session

      private SessionData session
      Current session data
      See Also:
    • database

      private DatabaseConnect database
      Connection to the database
      See Also:
    • sceneSwitch

      private SceneSwitch sceneSwitch
      Switches between scenes or tabs
      See Also:
    • orderButton

      private javafx.scene.control.Button orderButton
      Button Button to navigate order scene
    • orderHistoryButton

      private javafx.scene.control.Button orderHistoryButton
      Button Button to navigate order history scene
    • inventoryButton

      private javafx.scene.control.Button inventoryButton
      Button Button to navigate inventory scene
    • employeesButton

      private javafx.scene.control.Button employeesButton
      Button Button to navigate employees scene
    • editMenuButton

      private javafx.scene.control.Button editMenuButton
      Button Button to navigate edit menu scene
    • dataTrendsButton

      private javafx.scene.control.Button dataTrendsButton
      Button Button to navigate to the data trends scene
    • logoutButton

      private javafx.scene.control.Button logoutButton
      Button Button to logout
    • numberSold

      private javafx.scene.control.TableColumn<MenuItem,Long> numberSold
      TableColumn displaying the quantity of MenuItem sold
    • updateIDText

      private javafx.scene.control.TextField updateIDText
      TextField to allow for user input to update a MenuItem
    • updateNameText

      private javafx.scene.control.TextField updateNameText
      TextField to allow for user input to update a MenuItem
    • updateCostText

      private javafx.scene.control.TextField updateCostText
      TextField to allow for user input to update a MenuItem
    • updateRecipeText

      private javafx.scene.control.TextField updateRecipeText
      TextField to allow for user input to update a MenuItem
    • addNameText

      private javafx.scene.control.TextField addNameText
      TextField to allow for user input to add a MenuItem
    • addCostText

      private javafx.scene.control.TextField addCostText
      TextField to allow for user input to add a MenuItem
    • addRecipeText

      private javafx.scene.control.TextField addRecipeText
      TextField to allow for user input to add a MenuItem
    • deleteItemID

      private javafx.scene.control.TextField deleteItemID
      TextField to allow for user input to remove a MenuItem
    • updateItemButton

      private javafx.scene.control.Button updateItemButton
      Button that will trigger updateItemClicked(ActionEvent)
    • addItemButton

      private javafx.scene.control.Button addItemButton
      Button that will trigger addItemClicked(ActionEvent)
    • deleteItemButton

      private javafx.scene.control.Button deleteItemButton
      Button that will trigger deleteItemClicked(ActionEvent)
  • Constructor Details

    • EditMenuController

      public EditMenuController()
      Default constructor to prevent errors
    • EditMenuController

      public EditMenuController(SessionData session)
      Allows for passing session data from scene to scene
      Parameters:
      session - SessionData passed in from SceneSwitch
  • 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 - ActionEvent of updateItemButton
    • 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 - ActionEvent of addItemButton
    • deleteItemClicked

      public void deleteItemClicked(javafx.event.ActionEvent e)
      Remove item from menu table and recipe item table if it exists
      Parameters:
      e - ActionEvent of deleteItemClicked(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 for menuTable
    • getMenuItems

      private javafx.collections.ObservableList<MenuItem> getMenuItems()
      Gets all menu items from the database
      Returns:
      ObservableList of MenuItem
    • updateTable

      private void updateTable()
      Updates menuTable in the Graphical User Interface
    • parseRecipe

      private Map<Long,Long> parseRecipe(String[] recipe)
      Parses the recipe list into a Map maping from Long to Long. The Key is the ID number of the recipe item, the Value is the amount of that item in the recipe.
      Parameters:
      recipe - array of String holding the recipe
      Returns:
      Map of Long to Long
    • addItemsToRecipe

      private void addItemsToRecipe(Map<Long,Long> recipeMap, long menuID)
      Adds items to the recipe table
      Parameters:
      recipeMap - Map parsed by parseRecipe(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.