public boolean downloadLibraries() {
   applyLibraryOptionsForSelected();
   List<LibraryCompositionSettings> list = getLibrariesCompositionSettingsList();
   for (LibraryCompositionSettings compositionSettings : list) {
     if (!compositionSettings.downloadFiles(myMainPanel)) return false;
   }
   return true;
 }
  @Override
  protected void doOKAction() {
    final LibraryCompositionSettings librarySettings = myComponent.getLibraryCompositionSettings();
    if (librarySettings != null) {
      final ModifiableRootModel modifiableModel =
          myModifiableModelsProvider.getModuleModifiableModel(myModule);
      if (!askAndRemoveDuplicatedLibraryEntry(
          modifiableModel, librarySettings.getLibraryDescription())) {
        if (myConfigurable.isOnlyLibraryAdded()) {
          myModifiableModelsProvider.disposeModuleModifiableModel(modifiableModel);
          return;
        }
        return;
      }

      // Fix
      new WriteAction() {
        @Override
        protected void run(final Result result) {
          myModifiableModelsProvider.commitModuleModifiableModel(modifiableModel);
        }
      }.execute();

      final boolean downloaded = librarySettings.downloadFiles(getRootPane());
      if (!downloaded) {
        int answer =
            Messages.showYesNoDialog(
                getRootPane(),
                ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
                CommonBundle.getWarningTitle(),
                Messages.getWarningIcon());
        if (answer != 0) {
          return;
        }
      }
    }

    new WriteAction() {
      @Override
      protected void run(final Result result) {
        final ModifiableRootModel rootModel =
            myModifiableModelsProvider.getModuleModifiableModel(myModule);
        if (librarySettings != null) {
          librarySettings.addLibraries(
              rootModel, new ArrayList<Library>(), myModel.getLibrariesContainer());
        }
        myConfigurable.addSupport(myModule, rootModel, myModifiableModelsProvider);
        myModifiableModelsProvider.commitModuleModifiableModel(rootModel);
      }
    }.execute();
    super.doOKAction();
  }
 public void addSupport(
     final @NotNull Module module, final @NotNull ModifiableRootModel rootModel) {
   List<Library> addedLibraries = new ArrayList<Library>();
   List<FrameworkSupportNode> selectedFrameworks = getSelectedNodes();
   sortFrameworks(selectedFrameworks);
   List<FrameworkSupportConfigurable> selectedConfigurables =
       new ArrayList<FrameworkSupportConfigurable>();
   final IdeaModifiableModelsProvider modifiableModelsProvider =
       new IdeaModifiableModelsProvider();
   for (FrameworkSupportNode node : selectedFrameworks) {
     FrameworkSupportInModuleConfigurable configurable = node.getConfigurable();
     if (configurable
         instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
       selectedConfigurables.add(
           ((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable)
               .getConfigurable());
     }
     final LibraryCompositionSettings settings = getLibraryCompositionSettings(node);
     Library library =
         settings != null
             ? settings.addLibraries(rootModel, addedLibraries, myLibrariesContainer)
             : null;
     if (configurable
         instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
       ((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable)
           .getConfigurable()
           .addSupport(module, rootModel, library);
     } else {
       configurable.addSupport(module, rootModel, modifiableModelsProvider);
     }
   }
   for (FrameworkSupportNode node : selectedFrameworks) {
     FrameworkSupportInModuleProvider provider = node.getUserObject();
     if (provider instanceof OldFrameworkSupportProviderWrapper) {
       final FrameworkSupportProvider oldProvider =
           ((OldFrameworkSupportProviderWrapper) provider).getProvider();
       if (oldProvider instanceof FacetBasedFrameworkSupportProvider
           && !addedLibraries.isEmpty()) {
         ((FacetBasedFrameworkSupportProvider) oldProvider)
             .processAddedLibraries(module, addedLibraries);
       }
     }
   }
   for (FrameworkSupportCommunicator communicator :
       FrameworkSupportCommunicator.EP_NAME.getExtensions()) {
     communicator.onFrameworkSupportAdded(module, rootModel, selectedConfigurables, myModel);
   }
 }