}
@Nullable
private ErrorMessage createLibraryAndAssociate() {
String libraryName = myLibraryNameTextField.getText();
ScriptingLibraryModel libraryModel = myLibraryHelper.getOrCreateJsLibraryModel(libraryName);
try {
ScriptingLibraryMappings libraryMappings = ServiceManager.getService(myProject, JSLibraryMappings.class);
if (myModuleSelector.isProjectAssociationDialog()) {
if (myModuleSelector.isProjectAssociationRequested()) {
libraryMappings.associateWithProject(libraryModel.getName());
LOG.info("Library '" + libraryModel.getName() + "' has been successfully associated with the project");
}
else {
libraryMappings.disassociateWithProject(libraryModel.getName());
}
}
else {
for (Module module : myModuleSelector.getSelectedModules()) {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
VirtualFile[] roots = moduleRootManager.getContentRoots();
for (VirtualFile root : roots) {
libraryMappings.associate(root, libraryModel.getName(), false);
LOG.info("Library '" + libraryModel.getName() + "' has been associated with " + root);
}
}
}
myLibraryHelper.commit();
return null;