Class SearchedItemPagination

All Implemented Interfaces:
Styleable, EventTarget, SearchedItemPanelSourceUI

public class SearchedItemPagination extends VBox implements SearchedItemPanelSourceUI
The SearchedItemPagination class represents a UI component that provides pagination for search results. It allows users to navigate through multiple pages of search results, with buttons to go back and forth.
  • Field Details

    • itemRepo

      private final ItemRepo itemRepo
      The item repository containing all items, used to populate the pagination content.
    • pageList

      private SearchedItemsLinkedList pageList
      The linked list representing the pages of search results.
    • mySearchedItemContainer

      private final SearchedItemContainer mySearchedItemContainer
      The SearchedItemContainer instance that displays the current page of search results.
    • prevButton

      private final Button prevButton
      The button to navigate to the previous page of search results.
    • nextButton

      private final Button nextButton
      The button to navigate to the next page of search results.
  • Constructor Details

    • SearchedItemPagination

      public SearchedItemPagination(ItemRepo itemRepo)
      Constructor for SearchedItemPagination. Initializes the item repository and sets up the pagination component.
      Parameters:
      itemRepo - The item repository containing all items, used to populate the pagination content based on the current search results.
      Preconditions:
      itemRepo should contain valid item data to populate the pagination content.
  • Method Details

    • getPageCount

      public int getPageCount()
      Returns the total number of pages in the pagination, calculated based on the total number of items and items per page.
      Returns:
      The total number of pages in the pagination, calculated based on the total number of items and items per page.
    • update

      public final void update(List<String> itemIdList)
      Updates the pagination content with a new list of item IDs corresponding to search results. Retrieves the corresponding items from the item hash map and updates the displayed content accordingly. Logs a message if the pagination component is not found or if there is a type error with the component.
      Parameters:
      itemIdList - A list of item IDs corresponding to search results to update the pagination component with.
      Preconditions:
      A SearchedItemPagination instance should be added to the manager with the expected key and type before this method is called. itemIdList should be a list of valid item IDs corresponding to search results.
    • getPreviousPage

      private List<Item> getPreviousPage()
      Returns the list of items in the previous page of search results.
      Returns:
      The list of items in the previous page of search results, or null if there is no previous page.
      Preconditions:
      The SearchedItemPagination instance should be properly initialized and the linked list should be set up to allow for navigating to the previous page.
      Postconditions:
      If there is a previous page, the current page is updated to the previous page and the corresponding items are returned. If there is no previous page, null is returned.
    • addSearchedItemPanelInteractor

      public void addSearchedItemPanelInteractor(SearchedItemPanelInteractor interactor)
      Adds a SearchedItemPanelInteractor to the SearchedItemContainer to allow for interaction with the item panels in the search results.
      Specified by:
      addSearchedItemPanelInteractor in interface SearchedItemPanelSourceUI
      Parameters:
      interactor - The SearchedItemPanelInteractor to add to the SearchedItemContainer for handling interactions with the item panels in the search results.
      Preconditions:
      interactor should be properly implemented to handle interactions with the item panels, and the SearchedItemContainer should be properly initialized to allow for adding interactors.
      Postconditions:
      The provided interactor is added to the SearchedItemContainer, allowing it to pass SearchedItemPanelInteractors to the SearchedItemPanels in the search results.
    • getNextPage

      private List<Item> getNextPage()
      Returns the list of items in the next page of search results.
      Returns:
      The list of items in the next page of search results, or null if there is no next page.
      Preconditions:
      The SearchedItemPagination instance should be properly initialized and the linked list should be set up to allow for navigating to the next page.
      Postconditions:
      If there is a next page, the current page is updated to the next page and the corresponding items are returned. If there is no next page, null is returned.