From 0df02b8c9d5f160d52089395d0a146a800baa696 Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Sat, 2 Jan 2021 16:58:07 +0100 Subject: [PATCH] Show progress indicator and a label if nothing was found --- CHANGELOG.md | 4 +++ .../java/ctbrec/ui/tabs/ThumbOverviewTab.java | 29 ++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad2c60d0..6c509f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +NEXT +======================== +* Added config option to show the total number of models in the title bar + 3.11.0 ======================== * Added config option for faster scroll speed diff --git a/client/src/main/java/ctbrec/ui/tabs/ThumbOverviewTab.java b/client/src/main/java/ctbrec/ui/tabs/ThumbOverviewTab.java index 065633b4..4149eceb 100644 --- a/client/src/main/java/ctbrec/ui/tabs/ThumbOverviewTab.java +++ b/client/src/main/java/ctbrec/ui/tabs/ThumbOverviewTab.java @@ -125,6 +125,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { double imageAspectRatio = 3.0 / 4.0; private final SimpleBooleanProperty preserveAspectRatio = new SimpleBooleanProperty(true); ProgressIndicator progressIndicator; + Label noResultsFound = new Label("Nothing found!"); private ComboBox thumbWidth; @@ -367,6 +368,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { try { ObservableList nodes = grid.getChildren(); nodes.remove(progressIndicator); + nodes.remove(noResultsFound); // first remove models, which are not in the updated list removeModelsMissingInUpdate(nodes, models); @@ -380,6 +382,11 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { // move models, which are tracked by the recorder to the front moveActiveRecordingsToFront(); + + // show "empty" label, if grid is still empty + if (grid.getChildren().isEmpty()) { + nodes.add(noResultsFound); + } } finally { gridLock.unlock(); } @@ -774,12 +781,14 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { // remove the ones from grid, which don't match for (Iterator iterator = grid.getChildren().iterator(); iterator.hasNext();) { Node node = iterator.next(); - ThumbCell cell = (ThumbCell) node; - Model m = cell.getModel(); - if(!matches(m, filter)) { - iterator.remove(); - filteredThumbCells.add(cell); - cell.setSelected(false); + if (node instanceof ThumbCell) { + ThumbCell cell = (ThumbCell) node; + Model m = cell.getModel(); + if (!matches(m, filter)) { + iterator.remove(); + filteredThumbCells.add(cell); + cell.setSelected(false); + } } } @@ -887,8 +896,12 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { @Override public void selected() { + grid.getChildren().remove(noResultsFound); + if (grid.getChildren().isEmpty()) { + grid.getChildren().add(progressIndicator); + } queue.clear(); - if(updateService != null) { + if (updateService != null) { State s = updateService.getState(); if (s != State.SCHEDULED && s != State.RUNNING) { updateService.reset(); @@ -907,7 +920,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { for (Iterator iterator = grid.getChildren().iterator(); iterator.hasNext();) { Node node = iterator.next(); - if(node instanceof ThumbCell) { + if (node instanceof ThumbCell) { ThumbCell thumbCell = (ThumbCell) node; thumbCell.releaseResources(); iterator.remove();