From 9b1e366e452674d5a97d9de9263047a4773476b6 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Sat, 30 Aug 2014 06:28:01 -0500 Subject: [PATCH] Fixed annoying bug where if there were less images than the limit, the pagination would never render the content. --- .../main/resources/fxml/mainapp/MainApp.fxml | 2 +- .../ui/controller/AppController.scala | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gui/src/main/resources/fxml/mainapp/MainApp.fxml b/gui/src/main/resources/fxml/mainapp/MainApp.fxml index e6a7a63..2d48599 100644 --- a/gui/src/main/resources/fxml/mainapp/MainApp.fxml +++ b/gui/src/main/resources/fxml/mainapp/MainApp.fxml @@ -128,7 +128,7 @@ - + diff --git a/gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala b/gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala index f5400fe..67b2a77 100644 --- a/gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala +++ b/gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala @@ -91,6 +91,7 @@ class AppController extends Logging { }) //override the imageTilePane + debug("Replacing the default TilePane with a custom ImageTilePane") val newImageTilePane = new ImageTilePane() newImageTilePane.setHgap(this.imageTilePane.getHgap) newImageTilePane.setVgap(this.imageTilePane.getVgap) @@ -103,6 +104,7 @@ class AppController extends Logging { //newImageTilePane.setPrefTileHeight(this.imageTilePane.getPrefTileHeight) //newImageTilePane.setPrefTileWidth(this.imageTilePane.getPrefTileWidth) newImageTilePane.setTileAlignment(this.imageTilePane.getTileAlignment) + debug("Assigning the the new ImageTilePane to the ScrollPane") this.scrollPane.setContent(newImageTilePane) this.imageTilePane = newImageTilePane @@ -110,9 +112,12 @@ class AppController extends Logging { //val testImage = new Image() //testImage.setThumbnailPath("test.jpg") //testImage.setImagePath("test.jpg") + //val testImageList = new mutable.MutableList[Image] //for (i <- 1 to 100) { - // imageTilePane.getChildren.add(ImageTileFactory.get(testImage)) + // testImageList += testImage //} + //setPagesContent(testImageList.toList) + //showPage(0) //val list = FXCollections.observableArrayList[String]() //for (i <- 1 to 100) { // list.add(s"test-item ${i}") @@ -181,7 +186,7 @@ class AppController extends Logging { @FXML def showAllImages(event: ActionEvent) = { resetPaginator() - imageTilePane.getChildren.setAll(new java.util.ArrayList[Node]()) + getImageTilePane.getChildren.setAll(new java.util.ArrayList[Node]()) val f: Future[List[Image]] = Future { engine.getImagesForDirectory(currentDirectory, recursive = doRecursiveProcessing.isSelected) } @@ -194,6 +199,7 @@ class AppController extends Logging { Platform.runLater(new Runnable() { override def run() { setPagesContent(images) + showPage(0) } }) case Failure(t) => @@ -219,10 +225,10 @@ class AppController extends Logging { for (similarImage <- similarImages) { debug(s"Adding similar images ${similarImage.rootImage.toString} to app") tempImages += similarImage.rootImage - imageTilePane.getChildren.add(ImageTileFactory.get(similarImage.rootImage, imageTilePane)) similarImage.similarImages.foreach(image => tempImages += image) } setPagesContent(tempImages.toList) + showPage(0) } }) case Failure(t) => @@ -253,13 +259,13 @@ class AppController extends Logging { val startIndex = pageIndex * itemsPerPage val endIndex = if ((startIndex + itemsPerPage) > this.currentImages.size) this.currentImages.length else startIndex + itemsPerPage //clear and populate the scrollpane - imageTilePane.getChildren.setAll(new java.util.ArrayList[Node]()) + getImageTilePane.getChildren.setAll(new java.util.ArrayList[Node]()) val images = this.currentImages.slice(startIndex, endIndex) Platform.runLater(new Runnable() { override def run() { for (image <- images) { debug(s"Adding image ${image.toString} to app") - imageTilePane.getChildren.add(ImageTileFactory.get(image, imageTilePane)) + getImageTilePane.getChildren.add(ImageTileFactory.get(image, getImageTilePane)) } } }) @@ -267,6 +273,10 @@ class AppController extends Logging { //endregion + def getImageTilePane :TilePane = { + this.imageTilePane + } + //todo: include a templating engine for rendering information //todo: show a dialog that is rendered from markdown content