use of com.intellij.framework.library.DownloadableLibraryFileDescription in project intellij-community by JetBrains.
the class DownloadingOptionsDialog method onVersionChanged.
private void onVersionChanged(@Nullable final List<? extends DownloadableLibraryFileDescription> selectedFiles) {
final FrameworkLibraryVersion version = getSelectedVersion();
if (Comparing.equal(myLastSelectedVersion, version))
return;
if (version != null) {
final List<? extends DownloadableLibraryFileDescription> downloads = version.getFiles();
myFilesList.setModel(new CollectionListModel<>(ContainerUtil.map2Array(downloads, JCheckBox.class, new Function<DownloadableLibraryFileDescription, JCheckBox>() {
@Override
public JCheckBox fun(DownloadableLibraryFileDescription description) {
final boolean selected = selectedFiles != null ? selectedFiles.contains(description) : !description.isOptional();
return new JCheckBox(description.getPresentableFileName(), selected);
}
})));
if (myNameAndLevelPanel != null) {
myNameAndLevelPanel.setDefaultName(version.getDefaultLibraryName());
}
}
updateSourcesAndJavadocCheckboxes();
myLastSelectedVersion = version;
}
use of com.intellij.framework.library.DownloadableLibraryFileDescription in project intellij-community by JetBrains.
the class DownloadingOptionsDialog method createSettings.
private LibraryDownloadSettings createSettings() {
final FrameworkLibraryVersion version = getSelectedVersion();
LOG.assertTrue(version != null);
String libraryName;
LibrariesContainer.LibraryLevel libraryLevel;
if (myNameAndLevelPanel != null) {
libraryName = myNameAndLevelPanel.getLibraryName();
libraryLevel = myNameAndLevelPanel.getLibraryLevel();
} else {
libraryName = version.getDefaultLibraryName();
libraryLevel = LibrariesContainer.LibraryLevel.PROJECT;
}
final String path = FileUtil.toSystemIndependentName(myDirectoryField.getText());
List<DownloadableLibraryFileDescription> selected = getSelectedDownloads(version);
return new LibraryDownloadSettings(version, myLibraryType, path, libraryName, libraryLevel, selected, myDownloadSourcesCheckBox.isSelected(), myDownloadJavadocsCheckBox.isSelected());
}
use of com.intellij.framework.library.DownloadableLibraryFileDescription in project intellij-community by JetBrains.
the class DownloadingOptionsDialog method updateSourcesAndJavadocCheckboxes.
private void updateSourcesAndJavadocCheckboxes() {
final FrameworkLibraryVersion version = getSelectedVersion();
boolean sourcesCheckboxEnabled;
boolean javadocCheckboxEnabled;
if (version == null) {
sourcesCheckboxEnabled = javadocCheckboxEnabled = false;
} else {
final List<DownloadableLibraryFileDescription> descriptions = getSelectedDownloads(version);
sourcesCheckboxEnabled = haveAdditionalDownloads(descriptions, AdditionalDownloadType.SOURCES);
javadocCheckboxEnabled = haveAdditionalDownloads(descriptions, AdditionalDownloadType.DOCUMENTATION);
}
setEnabled(myDownloadSourcesCheckBox, sourcesCheckboxEnabled);
setEnabled(myDownloadJavadocsCheckBox, javadocCheckboxEnabled);
}
use of com.intellij.framework.library.DownloadableLibraryFileDescription 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