use of com.intellij.framework.library.LibraryVersionProperties in project intellij-community by JetBrains.
the class CustomLibraryDescriptionBase method createNewLibrary.
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
descriptor.setTitle(IdeBundle.message("new.library.file.chooser.title"));
descriptor.setDescription(IdeBundle.message("new.library.file.chooser.description"));
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parentComponent, null, contextDirectory);
if (files.length == 0) {
return null;
}
return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
for (VirtualFile file : files) {
editor.addRoot(file, OrderRootType.CLASSES);
}
}
};
}
use of com.intellij.framework.library.LibraryVersionProperties 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