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);
      }
    }
  }