private DefaultComboBoxModel createModel() {
    final DefaultComboBoxModel model = new DefaultComboBoxModel();

    createPredefinedScopeDescriptors(model);

    model.addElement(new ScopeSeparator("VCS Scopes"));
    final List<NamedScope> changeLists =
        ChangeListsScopesProvider.getInstance(myProject).getCustomScopes();
    for (NamedScope changeListScope : changeLists) {
      final GlobalSearchScope scope = GlobalSearchScopes.filterScope(myProject, changeListScope);
      model.addElement(new ScopeDescriptor(scope));
    }

    final List<ScopeDescriptor> customScopes = new ArrayList<ScopeDescriptor>();
    final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
    for (NamedScopesHolder holder : holders) {
      final NamedScope[] scopes = holder.getEditableScopes(); // predefined scopes already included
      for (NamedScope scope : scopes) {
        final GlobalSearchScope searchScope = GlobalSearchScopes.filterScope(myProject, scope);
        customScopes.add(new ScopeDescriptor(searchScope));
      }
    }
    if (!customScopes.isEmpty()) {
      model.addElement(new ScopeSeparator("Custom Scopes"));
      for (ScopeDescriptor scope : customScopes) {
        model.addElement(scope);
      }
    }

    return model;
  }
 private void selectScope(String preselect) {
   if (preselect != null) {
     final JComboBox combo = getComboBox();
     DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel();
     for (int i = 0; i < model.getSize(); i++) {
       ScopeDescriptor descriptor = (ScopeDescriptor) model.getElementAt(i);
       if (preselect.equals(descriptor.getDisplay())) {
         combo.setSelectedIndex(i);
         break;
       }
     }
   }
 }
 private void createPredefinedScopeDescriptors(DefaultComboBoxModel model) {
   @SuppressWarnings("deprecation")
   final DataContext context = DataManager.getInstance().getDataContext();
   for (SearchScope scope :
       getPredefinedScopes(
           myProject, context, mySuggestSearchInLibs, myPrevSearchFiles, true, true)) {
     model.addElement(new ScopeDescriptor(scope));
   }
   for (ScopeDescriptorProvider provider :
       Extensions.getExtensions(ScopeDescriptorProvider.EP_NAME)) {
     for (ScopeDescriptor scopeDescriptor : provider.getScopeDescriptors(myProject)) {
       model.addElement(scopeDescriptor);
     }
   }
 }