void () { if (myRememberScope) { int type = myOptions.SCOPE_TYPE; List<ModelScopeItemView> preselectedScopes = ContainerUtil.filter(myViewItems, x -> x.scopeId == type); if (preselectedScopes.size() >= 1) { LOG.assertTrue(preselectedScopes.size() == 1, "preselectedScopes.size() == 1"); preselectedScopes.get(0).button.setSelected(true); return; } } List<ModelScopeItemView> candidates = new ArrayList<>(); for (ModelScopeItemView view : myViewItems) { candidates.add(view); if (view.scopeId == AnalysisScope.FILE) { break; } } Collections.reverse(candidates); for (ModelScopeItemView x : candidates) { int scopeType = x.scopeId; // skip predefined scopes if (scopeType == AnalysisScope.CUSTOM || scopeType == AnalysisScope.UNCOMMITTED_FILES) { continue; } x.button.setSelected(true); break; } }