Class PaginatedContent<T>

java.lang.Object
NTNU.IDATT1002.controllers.NavBarController
NTNU.IDATT1002.controllers.PaginatedContent<T>
Type Parameters:
T - the type of entity content served
All Implemented Interfaces:
javafx.fxml.Initializable
Direct Known Subclasses:
Explore, ExploreAlbums

public abstract class PaginatedContent<T>
extends NavBarController
implements javafx.fxml.Initializable
Controller class for serving paginated content. Comes with predefined selections of Sort and the amount of results per page. To properly integrate this class, these FXML components are required, but can be placed and styled where appropriate.

 // Display for the total amount of results
 <Text fx:id="total" >
    <font>
       <Font name="System Bold Italic" size="36.0" />
    </font>
 </Text>

 // Sort selection
 <ChoiceBox fx:id="sortChoiceBox" prefHeight="52.0" prefWidth="228.0" value="Newest first">
    <items>
       <FXCollections fx:factory="observableArrayList">
          <String fx:value="Newest first" />
          <String fx:value="Oldest first" />
          <String fx:value="Alphabetically (A-Z)" />
          <String fx:value="Alphabetically (Z-A)" />
       </FXCollections>
    </items>
 </ChoiceBox>

 // Container for the page's content and progress indicator
 <VBox fx:id="pageContainer">
     <VBox fx:id="showResultsPerPageContainer" >
         <VBox>
             <ProgressIndicator fx:id="pageProgressIndicator"/>
         </VBox>
     </VBox>
 </VBox>
 
  • Field Details

    • pageSize

      protected java.lang.Integer pageSize
  • Constructor Details

    • PaginatedContent

      public PaginatedContent​(java.lang.String dateField, java.lang.String titleField)
      Initialize sort choice mapping to appropriate sort defined by given fields.
      Parameters:
      dateField - the date sort field defined by PaginatedContent
      titleField - the title sort field defined by PaginatedContent
  • Method Details

    • getService

      protected abstract PageableService<T> getService()
    • getContentsFrom

      protected abstract java.util.List<? extends javafx.scene.Node> getContentsFrom​(Page<T> page)
    • initialize

      public void initialize​(java.net.URL url, java.util.ResourceBundle resourceBundle)
      Generate content and bindings, including the first page of all images.
      Specified by:
      initialize in interface javafx.fxml.Initializable
    • createAndShowResultsSelection

      protected void createAndShowResultsSelection()
      Create and show a ComboBox selection holding the options for choosing the amount of results per page.
    • pageSizeSelectionChanged

      protected void pageSizeSelectionChanged​(javafx.scene.control.ComboBox<java.lang.Integer> choices)
      Action to take when user selected a new option in given ComboBox.
      Parameters:
      choices - the ComboBox holding the list of choice integers
    • updatePage

      public void updatePage()
      Update view with the first page of results with index 0, in the background. Includes the results in a Pagination.
    • getPageFactory

      protected javafx.scene.Node getPageFactory​(java.lang.Integer pageIndex)
      Define actions to take when user clicks on a new page. Fetches a Page with given page index in the background and updates the view with formatted ImageRows.
      Parameters:
      pageIndex - the new page number
      Returns:
      a page factory
    • getPageTaskFor

      protected javafx.concurrent.Task<Page<T>> getPageTaskFor​(int pageNumber)
      Return a Task for fetching and updating the current page with given page number and specified page size.
      Parameters:
      pageNumber - the page number
    • pageChanged

      protected javafx.event.EventHandler<javafx.concurrent.WorkerStateEvent> pageChanged​(javafx.concurrent.Task<Page<T>> newPageTask, javafx.scene.layout.VBox pageContentContainer)
      Define actions to take when the page changes.
      Parameters:
      newPageTask - the Task holding the page
      pageContentContainer - the container for page content
      Returns:
      the actions to take when the page changes
    • scrollToTop

      protected void scrollToTop()
      Scroll view point to top animation.