2222import com .jfoenix .controls .JFXListView ;
2323import com .jfoenix .controls .JFXTextField ;
2424import javafx .animation .PauseTransition ;
25+ import javafx .beans .binding .Bindings ;
26+ import javafx .beans .property .BooleanProperty ;
2527import javafx .beans .property .ObjectProperty ;
2628import javafx .beans .property .ReadOnlyObjectProperty ;
29+ import javafx .beans .property .SimpleBooleanProperty ;
2730import javafx .beans .property .SimpleObjectProperty ;
2831import javafx .collections .FXCollections ;
2932import javafx .collections .ObservableList ;
3235import javafx .geometry .Pos ;
3336import javafx .scene .Cursor ;
3437import javafx .scene .Node ;
38+ import javafx .scene .control .Label ;
3539import javafx .scene .control .ListCell ;
3640import javafx .scene .control .ScrollPane ;
3741import javafx .scene .control .Skin ;
@@ -506,6 +510,9 @@ private static final class ThemePackManagementPageSkin extends SkinBase<ThemePac
506510 /// Toolbar shown during normal browsing.
507511 private final HBox toolbarNormal = new HBox ();
508512
513+ /// Whether the search mechanism is currently active.
514+ private final BooleanProperty isSearching = new SimpleBooleanProperty (false );
515+
509516 /// Search input.
510517 private final JFXTextField searchField = new JFXTextField ();
511518
@@ -543,13 +550,17 @@ private void initializeToolbar(ThemePackManagementPage skinnable, ComponentList
543550 pause .setOnFinished (event ->
544551 skinnable .filteredList .setPredicate (skinnable .createPredicate (searchField .getText ())));
545552 searchField .textProperty ().addListener ((observable , oldValue , newValue ) -> {
546- pause .setRate (1 );
547- pause .playFromStart ();
553+ if (isSearching .get () || !StringUtils .isBlank (newValue )) {
554+ pause .setRate (1 );
555+ pause .playFromStart ();
556+ }
548557 });
549558
550559 JFXButton closeSearchBar = createToolbarButton2 (null , SVG .CLOSE , () -> {
551560 changeToolbar (toolbarNormal );
552561 searchField .clear ();
562+
563+ isSearching .set (false );
553564 });
554565 onEscPressed (searchField , closeSearchBar ::fire );
555566
@@ -584,6 +595,22 @@ private void initializeList(ThemePackManagementPage skinnable, ComponentList roo
584595 listView .getStyleClass ().add ("no-horizontal-scrollbar" );
585596 ignoreEvent (listView , KeyEvent .KEY_PRESSED , event -> event .getCode () == KeyCode .ESCAPE );
586597
598+ StackPane placeholderContainer = new StackPane ();
599+ placeholderContainer .getStyleClass ().add ("notice-pane" );
600+ Label placeholderLabel = new Label (i18n ("search.no_results_found" ));
601+ placeholderLabel .textProperty ().bind (
602+ Bindings .createStringBinding (() -> {
603+ if (isSearching .get ()) {
604+ return i18n ("search.no_results_found" );
605+ } else {
606+ return i18n ("" );
607+ }
608+ },
609+ isSearching )
610+ );
611+ placeholderContainer .getChildren ().add (placeholderLabel );
612+ listView .setPlaceholder (placeholderContainer );
613+
587614 center .setContent (listView );
588615 root .getContent ().add (center );
589616 }
@@ -595,6 +622,8 @@ private void changeToolbar(HBox newToolbar) {
595622 toolbarPane .setContent (newToolbar , ContainerAnimations .FADE );
596623 if (newToolbar == searchBar ) {
597624 runInFX (searchField ::requestFocus );
625+
626+ isSearching .set (true );
598627 }
599628 }
600629 }
0 commit comments