void (@Nullable Module currentModule, final SearchScope scope) { final ItemListener stateListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { myModuleSelection.setEnabled(myModuleScope.isSelected()); myDirectory.setEnabled(myDirectoryScope.isSelected()); myRecursive.setEnabled(myDirectoryScope.isSelected()); myCustomScopeSelection.setEnabled(myCustomScope.isSelected()); if (e.getStateChange() == ItemEvent.SELECTED) { firePropertyChange("scope", null, getSelectedScope()); } } }; final ItemListener scopeListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { firePropertyChange("scope", null, getSelectedScope()); } } }; myWholeProjectScope.addItemListener(stateListener); myWholeProjectScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.PROJECT); myModuleScope.addItemListener(stateListener); myModuleScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.MODULE); myDirectoryScope.addItemListener(stateListener); myDirectoryScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.DIRECTORY); myCustomScope.addItemListener(stateListener); myCustomScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.CUSTOM); myModuleSelection.fillModules(myProject); Module m; if (scope.getModuleName() != null) { if ((m = ModuleManager.getInstance(myProject).findModuleByName(scope.getModuleName())) == null) { m = currentModule; } } else { m = currentModule; } if (m != null) { myModuleSelection.setSelectedModule(m); } myModuleSelection.addItemListener(scopeListener); ((ScopeChooserCombo)myCustomScopeSelection).init(myProject, true, true, scope.getScopeName(), null); myCustomScopeSelection.getComboBox().addItemListener(scopeListener); myDirectory.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { firePropertyChange("scope", null, getSelectedScope()); } }); final @NlsSafe String path = scope.getPath(); myDirectory.setText(path); myDirectory.addBrowseFolderListener(XPathBundle.message("dialog.title.select.path"), XPathBundle.message("label.select.path"), myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor()); myRecursive.setSelected(scope.isRecursive()); }