public static void showDialogAndAddLibraryToDependencies(
      final Library library, final Project project, boolean allowEmptySelection) {
    for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
      if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
        return;
      }
    }

    final ModuleStructureConfigurable moduleStructureConfigurable =
        ModuleStructureConfigurable.getInstance(project);
    final List<Module> modules =
        LibraryEditingUtil.getSuitableModules(
            moduleStructureConfigurable, ((LibraryEx) library).getKind(), library);
    if (modules.isEmpty()) return;
    final ChooseModulesDialog dlg =
        new ChooseModulesDialog(
            moduleStructureConfigurable.getProject(),
            modules,
            ProjectBundle.message("choose.modules.dialog.title"),
            ProjectBundle.message("choose.modules.dialog.description", library.getName()));
    if (dlg.showAndGet()) {
      final List<Module> chosenModules = dlg.getChosenElements();
      for (Module module : chosenModules) {
        moduleStructureConfigurable.addLibraryOrderEntry(module, library);
      }
    }
  }
 @Override
 public void addRow() {
   final Set<Module> projectModules =
       new HashSet<Module>(Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
   projectModules.removeAll(getAllModules());
   final ChooseModulesDialog chooser =
       new ChooseModulesDialog(
           ProcessedModulesTable.this, new ArrayList<Module>(projectModules), "ChooseModule");
   if (chooser.showAndGet()) {
     final List<Module> chosen = chooser.getChosenElements();
     for (Module module : chosen) {
       addElement(module, null);
     }
   }
 }