mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
skip dirs containing only one subdir
This commit is contained in:
@@ -158,7 +158,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
|
||||
registerKeyboardAction(new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final Object o = myModel.getSelectedValue();
|
||||
navigateInsideBar(o);
|
||||
navigateInsideBar(optimizeTarget(o));
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), WHEN_FOCUSED);
|
||||
|
||||
@@ -204,6 +204,16 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
|
||||
updateList();
|
||||
}
|
||||
|
||||
private static Object optimizeTarget(Object target) {
|
||||
if (target instanceof PsiDirectory && ((PsiDirectory)target).getFiles().length == 0) {
|
||||
final PsiDirectory[] subDir = ((PsiDirectory)target).getSubdirectories();
|
||||
if (subDir.length == 1) {
|
||||
return optimizeTarget(subDir[0]);
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
private void processFocusLost(final FocusEvent e) {
|
||||
final boolean nodePopupInactive = myNodePopup == null || !myNodePopup.isVisible() || !myNodePopup.isFocused();
|
||||
final JBPopup child = JBPopupFactory.getInstance().getChildPopup(this);
|
||||
@@ -488,7 +498,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner {
|
||||
@NotNull public String getTextFor(final Object value) { return NavBarModel.getPresentableText(value, null);}
|
||||
public boolean isSelectable(Object value) { return true; }
|
||||
public PopupStep onChosen(final Object selectedValue, final boolean finalChoice) {
|
||||
navigateInsideBar(selectedValue);
|
||||
navigateInsideBar(optimizeTarget(selectedValue));
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user