use of com.intellij.webcore.libraries.ScriptingLibraryMappings in project intellij-plugins by JetBrains.
the class ChooseScopeAndCreateLibraryDialog method createLibraryAndAssociate.
@Nullable
private ErrorMessage createLibraryAndAssociate() {
String libraryName = myLibraryNameTextField.getText();
ScriptingLibraryModel libraryModel = myLibraryHelper.getOrCreateJsLibraryModel(libraryName);
try {
ScriptingLibraryMappings libraryMappings = ServiceManager.getService(myProject, JSLibraryMappings.class);
if (myModuleSelector.isAssociateWithProjectView()) {
if (myModuleSelector.isAssociateWithProjectRequested()) {
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;
} catch (Exception ex) {
return new ErrorMessage("Unable to associate '" + libraryName + "' JavaScript library", ex);
}
}
Aggregations