private void removeSelectedConfiguration() {
   int oldSelection = myList.getSelectedIndex();
   myModel.removeElement(mySelection);
   int size = myList.getModel().getSize();
   int newSelection = oldSelection < size ? oldSelection : size - 1;
   if (newSelection >= 0 && newSelection < size) {
     myList.setSelectedIndex(newSelection);
   }
 }
  public CvsConfigurationsListEditor(List<CvsRootConfiguration> configs, Project project) {
    super(true);
    myCvs2SettingsEditPanel = new Cvs2SettingsEditPanel(project);
    setTitle(CvsBundle.message("operation.name.edit.configurations"));
    myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectNone();
    fillModel(configs);

    myCvs2SettingsEditPanel.addCvsRootChangeListener(
        new CvsRootChangeListener() {
          public void onCvsRootChanged() {
            if (mySelection == null) return;
            myCvs2SettingsEditPanel.saveTo(mySelection, false);
            myList.repaint();
          }
        });

    setTitle(CvsBundle.message("dialog.title.cvs.roots"));

    if (!configs.isEmpty()) {
      myList.setSelectedIndex(0);
    }
    init();
  }