Class UIElementManager
java.lang.Object
org.troy.capstone.managers.UIElementManager
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 Summary
FieldsModifier and TypeFieldDescriptionprivate ButtonThe search button in the UIprivate final Map<UIElementName, Node> A map of UI element names to their corresponding nodes -
Constructor Summary
ConstructorsConstructorDescriptionConstructor forUIElementManager, initializes the map for storing UI elements -
Method Summary
Modifier and TypeMethodDescriptionvoidaddElement(UIElementName key, Node element) Adds a UI element to the manager with the specified key.Gets the search button from the manager.getElement(UIElementName key) Retrieves a UI element based on the provided key.Gathers current values of UI elements and returns them in a map for use in search queries.voidSets the search button in the manager and assigns an action to it that filters the search results and updates the UI when clicked.voidupdateSearchedItemPagination(List<String> itemIDs) Updates the searched item pagination component with new search results.
-
Field Details
-
uiElements
A map of UI element names to their corresponding nodes -
searchButton
The search button in the UI
-
-
Constructor Details
-
UIElementManager
public UIElementManager()Constructor forUIElementManager, initializes the map for storing UI elements
-
-
Method Details
-
getElement
Retrieves a UI element based on the provided key. Logs a message if the element is not found in the manager.- Parameters:
key- TheUIElementNamerepresenting the UI element to retrieve- Returns:
- An
Optionalcontaining the UI element if found, or an emptyOptionalif not found - Preconditions:
- key is not null.
-
addElement
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 elementelement- The UI element to be added- Preconditions:
- key and element are not null.
-
getButton
Gets the search button from the manager.- Returns:
- The
Buttonthat was set in the manager - Preconditions:
searchButtonis not null.
-
setButton
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- TheButtonto be set in the manager
-
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
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 theSearchedItemPaginationcomponent with.- Preconditions:
- A
SearchedItemPaginationcomponent 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.
-