Class UIElementManager

java.lang.Object
org.troy.capstone.managers.UIElementManager

public class UIElementManager extends Object
The UIElementManager class is responsible for managing the UI elements in the application. It provides methods to add and retrieve UI elements, gather search data from the UI, and update the UI with search results.
  • Field Details

    • uiElements

      private final Map<UIElementName, Node> uiElements
      A map of UI element names to their corresponding nodes
    • searchButton

      private Button searchButton
      The search button in the UI
  • Constructor Details

    • UIElementManager

      public UIElementManager()
      Constructor for UIElementManager, initializes the map for storing UI elements
  • Method Details

    • getElement

      public Optional<Node> getElement(UIElementName key)
      Retrieves a UI element based on the provided key. Logs a message if the element is not found in the manager.
      Parameters:
      key - The UIElementName representing the UI element to retrieve
      Returns:
      An Optional containing the UI element if found, or an empty Optional if not found
      Preconditions:
      key is not null.
    • addElement

      public void addElement(UIElementName key, Node element)
      Adds a UI element to the manager with the specified key. Logs a message if the key or element is null.
      Parameters:
      key - The key representing the UI element
      element - The UI element to be added
      Preconditions:
      key and element are not null.
    • getButton

      public Button getButton()
      Gets the search button from the manager.
      Returns:
      The Button that was set in the manager
      Preconditions:
      searchButton is not null.
    • setButton

      public void setButton(Button button)
      Sets the search button in the manager and assigns an action to it that filters the search results and updates the UI when clicked. Logs a message if the button is null.
      Parameters:
      button - The Button to be set in the manager
    • getSearchData

      public Map<UIDataName, Object> getSearchData()
      Gathers current values of UI elements and returns them in a map for use in search queries. Logs any missing elements or type errors but continues gathering other data.
      Returns:
      A map containing the current values of UI elements for use in search queries
      Preconditions:
      UI elements should be added to the manager with the expected keys and types before this method is called.
    • updateSearchedItemPagination

      public void updateSearchedItemPagination(List<String> itemIDs)
      Updates the searched item pagination component with new search results. Logs missing pagination component or type error with the component.
      Parameters:
      itemIDs - A list of item IDs corresponding to search results to update the SearchedItemPagination component with.
      Preconditions:
      A SearchedItemPagination component should be added to the manager with the expected key and type before this method is called. itemIDs should be a list of valid item IDs corresponding to search results.