use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.
the class LibraryDownloadSettings method download.
@Nullable
public NewLibraryEditor download(JComponent parent, @Nullable String rootPath) {
final List<DownloadableFileDescription> toDownload = new ArrayList<>(mySelectedDownloads);
Map<DownloadableFileDescription, OrderRootType> rootTypes = new HashMap<>();
for (DownloadableLibraryFileDescription description : mySelectedDownloads) {
final DownloadableFileDescription sources = description.getSourcesDescription();
if (myDownloadSources && sources != null) {
toDownload.add(sources);
rootTypes.put(sources, OrderRootType.SOURCES);
}
final DownloadableFileDescription docs = description.getDocumentationDescription();
if (myDownloadJavaDocs && docs != null) {
toDownload.add(docs);
rootTypes.put(docs, JavadocOrderRootType.getInstance());
}
}
String path = rootPath != null && !FileUtil.isAbsolute(myLibrariesPath) ? new File(rootPath, myLibrariesPath).getPath() : myLibrariesPath;
List<Pair<VirtualFile, DownloadableFileDescription>> downloaded = DownloadableFileService.getInstance().createDownloader(toDownload, myLibraryName + " Library").downloadWithProgress(path, null, parent);
if (downloaded == null) {
return null;
}
final NewLibraryEditor libraryEditor;
if (myLibraryType != null) {
libraryEditor = new NewLibraryEditor(myLibraryType, new LibraryVersionProperties(myVersion.getVersionString()));
} else {
libraryEditor = new NewLibraryEditor();
}
libraryEditor.setName(myLibraryName);
for (Pair<VirtualFile, DownloadableFileDescription> pair : downloaded) {
final OrderRootType rootType = rootTypes.containsKey(pair.getSecond()) ? rootTypes.get(pair.getSecond()) : OrderRootType.CLASSES;
libraryEditor.addRoot(pair.getFirst(), rootType);
}
return libraryEditor;
}
Aggregations