@@ -75,23 +75,22 @@ public ProjectView(final EditorView view) {
7575 back .setBorder (new CompoundBorder (new MatteBorder (0 , 0 , 1 , 0 , GUIConstants .gray ),
7676 BaseXLayout .border (5 , 3 , 5 , 4 )));
7777
78- rootPath = new BaseXCombo (gui , true ).history (GUIOptions .PROJECTS , gui .gopts );
79- rootPath .setFocusable (false );
80-
81- // update project tree if another root is chosen
82- rootPath .textField ().getDocument ().addDocumentListener (
83- new DocumentListener () {
84- @ Override public void insertUpdate (final DocumentEvent e ) { changeRoot (); }
85- @ Override public void removeUpdate (final DocumentEvent e ) { }
86- @ Override public void changedUpdate (final DocumentEvent e ) { }
78+ rootPath = new BaseXCombo (gui , false ).history (GUIOptions .PROJECTS , gui .gopts );
79+ rootPath .addActionListener (e -> changeRoot ());
80+ rootPath .addPopupMenuListener (new PopupMenuListener () {
81+ @ Override public void popupMenuWillBecomeVisible (final PopupMenuEvent e ) { }
82+ @ Override public void popupMenuWillBecomeInvisible (final PopupMenuEvent e ) {
83+ rootPath .updateHistory ();
8784 }
88- );
85+ @ Override public void popupMenuCanceled (final PopupMenuEvent e ) { }
86+ });
8987
9088 final BaseXToolBar buttons = new BaseXToolBar ();
9189
9290 final AbstractButton browse = BaseXButton .get ("c_edit_open" , OPEN , false , gui );
9391 browse .setToolTipText (CHOOSE_DIR + DOTS );
9492 browse .addActionListener (e -> chooseRoot ());
93+ browse .setFocusable (true );
9594 buttons .add (browse );
9695
9796 back .add (rootPath , BorderLayout .CENTER );
@@ -127,7 +126,7 @@ public void componentResized(final ComponentEvent e) {
127126 }
128127 });
129128
130- rootPath .setText (dir .path ());
129+ rootPath .select (dir .path ());
131130 }
132131
133132 /**
@@ -335,13 +334,13 @@ private void chooseRoot() {
335334 final BaseXFileChooser fc = new BaseXFileChooser (gui , CHOOSE_DIR , root .file .path ());
336335 final IOFile io = fc .select (Mode .DOPEN );
337336 if (io != null ) {
338- rootPath .setText (io .normalize ().path ());
339- rootPath . updateHistory ();
337+ rootPath .select (io .normalize ().path ());
338+ changeRoot ();
340339 }
341340 }
342341
343342 /**
344- * Changes the root directory. Called by document listener of editable root path component .
343+ * Changes the root directory. Called when another directory is chosen in the root path combo box .
345344 */
346345 private void changeRoot () {
347346 final IOFile path = new IOFile (rootPath .getText ());
@@ -351,7 +350,8 @@ private void changeRoot() {
351350 gui .saveOptions ();
352351
353352 root .file = path ;
354- root .refresh ();
353+ root .expand ();
354+ tree .expandPath (root .path ());
355355 refresh ();
356356 }
357357}
0 commit comments