Package NTNU.IDATT1002.controllers
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 Summary
Fields Modifier and Type Field Description protected java.lang.Integer
pageSize
Fields inherited from class NTNU.IDATT1002.controllers.NavBarController
navBarAlbums, navBarExplore, navBarLogo, navBarLogOut, navBarMap, navBarSearch, navBarSearchBtn, navBarUpload, returnButton
-
Constructor Summary
Constructors Constructor Description PaginatedContent(java.lang.String dateField, java.lang.String titleField)
Initialize sort choice mapping to appropriate sort defined by given fields. -
Method Summary
Modifier and Type Method Description protected void
createAndShowResultsSelection()
Create and show aComboBox
selection holding the options for choosing the amount of results per page.protected abstract java.util.List<? extends javafx.scene.Node>
getContentsFrom(Page<T> page)
protected javafx.scene.Node
getPageFactory(java.lang.Integer pageIndex)
Define actions to take when user clicks on a new page.protected javafx.concurrent.Task<Page<T>>
getPageTaskFor(int pageNumber)
Return aTask
for fetching and updating the current page with given page number and specified page size.protected abstract PageableService<T>
getService()
void
initialize(java.net.URL url, java.util.ResourceBundle resourceBundle)
Generate content and bindings, including the first page of all images.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.protected void
pageSizeSelectionChanged(javafx.scene.control.ComboBox<java.lang.Integer> choices)
Action to take when user selected a new option in givenComboBox
.protected void
scrollToTop()
Scroll view point to top animation.void
updatePage()
Update view with the first page of results with index 0, in the background.Methods inherited from class NTNU.IDATT1002.controllers.NavBarController
doBeforePageExit, enterSearch, goToPrevious, logOut, search, switchToAlbums, switchToExplore, switchToMain, switchToMap, switchToSearch, switchToUpload
-
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 byPaginatedContent
titleField
- the title sort field defined byPaginatedContent
-
-
Method Details
-
getService
-
getContentsFrom
-
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 interfacejavafx.fxml.Initializable
-
createAndShowResultsSelection
protected void createAndShowResultsSelection()Create and show aComboBox
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 givenComboBox
.- Parameters:
choices
- theComboBox
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 aPagination
. -
getPageFactory
protected javafx.scene.Node getPageFactory(java.lang.Integer pageIndex)Define actions to take when user clicks on a new page. Fetches aPage
with given page index in the background and updates the view with formattedImageRow
s.- Parameters:
pageIndex
- the new page number- Returns:
- a page factory
-
getPageTaskFor
Return aTask
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
- theTask
holding the pagepageContentContainer
- the container for page content- Returns:
- the actions to take when the page changes
-
scrollToTop
protected void scrollToTop()Scroll view point to top animation.
-