@@ -36,6 +36,7 @@ public interface Action {
3636 private final ListView <String > filesListView ;
3737 private String rootPath = ((String ) PropertiesLoader .getProperty ("sqlbrowserfx.root.path" , String .class , "~/" ))
3838 .replaceAll ("\" " , "" );
39+ private Label descLabel ;
3940
4041 public FileSearchPopOver (Action action ) {
4142 super ();
@@ -88,32 +89,41 @@ protected void updateItem(String item, boolean empty) {
8889 // TODO: add open button if has any value
8990 ImageView descIcon = JavaFXUtils .createIcon ("/icons/settings.png" );
9091
91- Label descLabel = new Label ("File Search in: " + rootPath , descIcon );
92+ descLabel = new Label ("File Search in: " + rootPath , descIcon );
9293 descLabel .setOnMouseClicked (event -> {
9394 this .hide ();
94- DirectoryChooser dirChooser = new DirectoryChooser ();
95- File selectedDir = dirChooser .showDialog (this .getOwnerWindow ());
96- this .rootPath = selectedDir .getAbsolutePath ();
97- descLabel .setText ("File Search in: " + rootPath );
95+ var dirChooser = new DirectoryChooser ();
96+ var initialDir = new File (this .rootPath );
97+ dirChooser .setInitialDirectory (initialDir );
98+ var selectedDir = dirChooser .showDialog (this .getOwnerWindow ());
99+ if (selectedDir != null ) {
100+ this .rootPath = selectedDir .getAbsolutePath ();
101+ descLabel .setText ("File Search in: " + rootPath );
102+ PropertiesLoader .storeProperty ("./sqlbrowserfx.properties" , "sqlbrowserfx.root.path" , this .rootPath );
103+ }
98104 });
99105 descLabel .setTooltip (new Tooltip ("Click to change root path" ));
100106
101107 this .setContentNode (new CustomVBox (descLabel , searchField , filesListView ));
108+
109+ this .setOnShowing (event -> {
110+ PropertiesLoader .loadProperties ();
111+ rootPath = ((String ) PropertiesLoader .getProperty ("sqlbrowserfx.root.path" , String .class , "~/" ))
112+ .replaceAll ("\" " , "" );
113+ this .descLabel .setText ("File Search in: " + rootPath );
114+ });
115+ this .setOnShown (event -> searchField .requestFocus ());
116+ this .setHideOnEscape (true );
102117 this .setOnHidden (event -> {
103118 if (executor != null ) {
104119 executor .shutdownNow ();
105120 }
106121 });
107-
108- this .setOnShown (event -> searchField .requestFocus ());
109- this .setHideOnEscape (true );
110122
111123 filesListView .setOnKeyPressed (keyEvent -> {
112124 if (keyEvent .getCode () == KeyCode .ENTER ) {
113125 String filePath = filesListView .getSelectionModel ().getSelectedItem ();
114126 action .run (new File (filePath ));
115- } else if (keyEvent .getCode () == KeyCode .ESCAPE ) {
116- this .hide ();
117127 }
118128 });
119129 filesListView .setOnMouseClicked (mouseEvent -> {
0 commit comments