Class AddIngredientController

java.lang.Object
no.ntnu.idatt1002.demo.controller.AddIngredientController
All Implemented Interfaces:
javafx.fxml.Initializable

public class AddIngredientController extends Object implements javafx.fxml.Initializable
The AddIngredientController manages a dialog pane used to display a search-field along with a list of all the possible food types in the application according to the FoodItem enum class. The food types in the list may be selected and added to an up-to-date IngredientsAtHand object that is then written to file. The user may add several food types before pressing 'close' and exit the dialog. The food types that are not already contained in the IngredientsAtHand are listed underneath the list so that the user can keep track of the newly added food types. Upon opening the dialog, the search field is already selected and the user can start typing a search. When pressing 'Enter' on the keyboard, the search is performed and matches are displayed in the list. If the search field is left blank upon search, all food types are listed again.
  • Constructor Details

    • AddIngredientController

      public AddIngredientController()
  • Method Details

    • initialize

      public void initialize(URL url, ResourceBundle resourceBundle)
      The initialize method of the controller takes in a URL (location) and ResourceBundle(resources) to initialize the controller once its root element has been processed. The method then sets the list items of the list, sets the focus on the search-field and makes sure that the label underneath the list that states the added food types to the user can wrap if it fills the full width of the window.
      Specified by:
      initialize in interface javafx.fxml.Initializable
      Parameters:
      url - The location to resolve the relative paths to the root object.
      resourceBundle - Resources used to localize the root object.