private void reloadList() {
    myList.clear();
    final List<RDefaultRepository> repositories = myController.getDefaultRepositories();
    RPackageService service = RPackageService.getInstance();

    for (RDefaultRepository repository : repositories) {
      myList.addItem(
          repository,
          repository.getUrl(),
          service.enabledRepositories.contains(repository.getUrl()));
    }
    for (String repository : service.userRepositories) {
      myList.addItem(repository, repository, true);
    }
  }
  private void doDeleteDirectory() {
    if (myResourceDir == null) {
      return;
    }

    final int selectedIndex = myDirectoriesList.getSelectedIndex();
    if (selectedIndex < 0) {
      return;
    }

    final String selectedDirName = myDirNames[selectedIndex];
    final VirtualFile selectedDir = myResourceDir.findChild(selectedDirName);
    if (selectedDir == null) {
      return;
    }

    final VirtualFileDeleteProvider provider = new VirtualFileDeleteProvider();
    provider.deleteElement(
        new DataContext() {
          @Override
          public Object getData(@NonNls String dataId) {
            if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.getName().equals(dataId)) {
              return new VirtualFile[] {selectedDir};
            } else {
              return null;
            }
          }
        });
    updateDirectories(false);
  }
 @Override
 protected void doOKAction() {
   this.processDoNotAskOnOk(0);
   if (this.getOKAction().isEnabled()) {
     List<RRepository> enabled = Lists.newArrayList();
     for (int i = 0; i < myList.getItemsCount(); i++) {
       if (myList.isItemSelected(i)) {
         final Object item = myList.getItemAt(i);
         enabled.add((RRepository) item);
       }
     }
     myController.setCRANMirror(currentCRANMirror);
     myController.setRepositories(enabled);
     this.close(0);
   }
 }
  private void updateDirectories(boolean updateFileCombo) {
    final Module module = getModule();
    List<VirtualFile> valuesDirs = Collections.emptyList();

    if (module != null) {
      final AndroidFacet facet = AndroidFacet.getInstance(module);

      if (facet != null) {
        myResourceDir = AndroidRootUtil.getResourceDir(facet);

        if (myResourceDir != null) {
          valuesDirs =
              AndroidResourceUtil.getResourceSubdirs(
                  ResourceFolderType.VALUES.getName(), new VirtualFile[] {myResourceDir});
        }
      }
    }

    Collections.sort(
        valuesDirs,
        new Comparator<VirtualFile>() {
          @Override
          public int compare(VirtualFile f1, VirtualFile f2) {
            return f1.getName().compareTo(f2.getName());
          }
        });

    final Map<String, JCheckBox> oldCheckBoxes = myCheckBoxes;
    final int selectedIndex = myDirectoriesList.getSelectedIndex();
    final String selectedDirName = selectedIndex >= 0 ? myDirNames[selectedIndex] : null;

    final List<JCheckBox> checkBoxList = new ArrayList<JCheckBox>();
    myCheckBoxes = new HashMap<String, JCheckBox>();
    myDirNames = new String[valuesDirs.size()];

    int newSelectedIndex = -1;

    int i = 0;

    for (VirtualFile dir : valuesDirs) {
      final String dirName = dir.getName();
      final JCheckBox oldCheckBox = oldCheckBoxes.get(dirName);
      final boolean selected = oldCheckBox != null && oldCheckBox.isSelected();
      final JCheckBox checkBox = new JCheckBox(dirName, selected);
      checkBoxList.add(checkBox);
      myCheckBoxes.put(dirName, checkBox);
      myDirNames[i] = dirName;

      if (dirName.equals(selectedDirName)) {
        newSelectedIndex = i;
      }
      i++;
    }
    myDirectoriesList.setModel(new CollectionListModel<JCheckBox>(checkBoxList));

    if (newSelectedIndex >= 0) {
      myDirectoriesList.setSelectedIndex(newSelectedIndex);
    }

    if (checkBoxList.size() == 1) {
      checkBoxList.get(0).setSelected(true);
    }

    if (updateFileCombo) {
      final Object oldItem = myFileNameCombo.getEditor().getItem();
      final Set<String> fileNameSet = new HashSet<String>();

      for (VirtualFile valuesDir : valuesDirs) {
        for (VirtualFile file : valuesDir.getChildren()) {
          fileNameSet.add(file.getName());
        }
      }
      final List<String> fileNames = new ArrayList<String>(fileNameSet);
      Collections.sort(fileNames);
      myFileNameCombo.setModel(new DefaultComboBoxModel(fileNames.toArray()));
      myFileNameCombo.getEditor().setItem(oldItem);
    }
  }
 private void doUnselectAllDirs() {
   for (JCheckBox checkBox : myCheckBoxes.values()) {
     checkBox.setSelected(false);
   }
   myDirectoriesList.repaint();
 }