void () { Module[] modules = ModuleManager.getInstance(myProject).getModules(); String[] names = new String[modules.length]; for (int i = 0; i < modules.length; i++) { names[i] = modules[i].getName(); } Arrays.sort(names, String.CASE_INSENSITIVE_ORDER); myModuleComboBox = new ComboBox<>(names); myModuleComboBox.setSwingPopup(false); myModuleComboBox.setMinimumAndPreferredWidth(JBUIScale.scale(300)); // as ScopeChooser myModuleComboBox.setRenderer(SimpleListCellRenderer.create("", Functions.id())); ActionListener restartSearchListener = e -> scheduleResultsUpdate(); myModuleComboBox.addActionListener(restartSearchListener); myDirectoryChooser = new FindPopupDirectoryChooser(myFindPopupPanel); myScopeCombo = new ScopeChooserCombo(); Object selection = ObjectUtils.coalesce(myHelper.getModel().getCustomScopeName(), FindSettings.getInstance().getDefaultScopeName()); myScopeCombo.init(myProject, true, true, selection, new Condition<>() { //final String projectFilesScopeName = PsiBundle.message("psi.search.scope.project"); final String moduleFilesScopeName; { String moduleScopeName = IndexingBundle.message("search.scope.module", ""); final int ind = moduleScopeName.indexOf(' '); moduleFilesScopeName = moduleScopeName.substring(0, ind + 1); } @Override public boolean value(ScopeDescriptor descriptor) { final String display = descriptor.getDisplayName(); return /*!projectFilesScopeName.equals(display) &&*/ !display.startsWith(moduleFilesScopeName); } }); myScopeCombo.setBrowseListener(new ScopeChooserCombo.BrowseListener() { private FindModel myModelSnapshot; @Override public void onBeforeBrowseStarted() { myModelSnapshot = myHelper.getModel(); myFindPopupPanel.getCanClose().set(false); } @Override public void onAfterBrowseFinished() { if (myModelSnapshot != null) { SearchScope scope = myScopeCombo.getSelectedScope(); if (scope != null) { myModelSnapshot.setCustomScope(scope); } myFindPopupPanel.getCanClose().set(true); } } }); myScopeCombo.getComboBox().addActionListener(restartSearchListener); Disposer.register(myFindPopupPanel.getDisposable(), myScopeCombo); }