public void init( final Project project, final boolean suggestSearchInLibs, final boolean prevSearchWholeFiles, final String preselect) { mySuggestSearchInLibs = suggestSearchInLibs; myPrevSearchFiles = prevSearchWholeFiles; myProject = project; myScopeListener = new NamedScopesHolder.ScopeListener() { @Override public void scopesChanged() { final SearchScope selectedScope = getSelectedScope(); rebuildModel(); if (selectedScope != null) { selectScope(selectedScope.getDisplayName()); } } }; myNamedScopeManager = NamedScopeManager.getInstance(project); myNamedScopeManager.addScopeListener(myScopeListener); myValidationManager = DependencyValidationManager.getInstance(project); myValidationManager.addScopeListener(myScopeListener); addActionListener(createScopeChooserListener()); final JComboBox combo = getComboBox(); combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer())); rebuildModel(); selectScope(preselect); }
void reloadScopes() { ApplicationManager.getApplication().assertIsDispatchThread(); List<Pair<NamedScope, NamedScopesHolder>> scopeList = new ArrayList<Pair<NamedScope, NamedScopesHolder>>(); final DependencyValidationManager dependencyValidationManager = DependencyValidationManager.getInstance(myProject); addScopesToList(scopeList, NamedScopeManager.getInstance(myProject)); addScopesToList(scopeList, dependencyValidationManager); myScopes.clear(); myScopes.addAll(scopeList); dependencyValidationManager.reloadRules(); }
@Override public void dispose() { super.dispose(); if (myValidationManager != null) { myValidationManager.removeScopeListener(myScopeListener); myValidationManager = null; } if (myNamedScopeManager != null) { myNamedScopeManager.removeScopeListener(myScopeListener); myNamedScopeManager = null; } myScopeListener = null; }