use of com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorBase in project intellij-community by JetBrains.
the class DownloadableLibraryPropertiesEditor method edit.
protected void edit() {
final ModalityState current = ModalityState.current();
myDescription.fetchVersions(new DownloadableFileSetVersions.FileSetVersionsCallback<FrameworkLibraryVersion>() {
@Override
public void onSuccess(@NotNull final List<? extends FrameworkLibraryVersion> versions) {
ApplicationManager.getApplication().invokeLater(() -> {
String pathForDownloaded = "";
final VirtualFile existingRootDirectory = myEditorComponent.getExistingRootDirectory();
if (existingRootDirectory != null) {
pathForDownloaded = existingRootDirectory.getPath();
} else {
final VirtualFile baseDir = myEditorComponent.getBaseDirectory();
if (baseDir != null) {
pathForDownloaded = baseDir.getPath() + "/lib";
}
}
final LibraryDownloadSettings initialSettings = new LibraryDownloadSettings(getCurrentVersion(versions), myLibraryType, LibrariesContainer.LibraryLevel.PROJECT, pathForDownloaded);
final LibraryDownloadSettings settings = DownloadingOptionsDialog.showDialog(getMainPanel(), initialSettings, versions, false);
if (settings != null) {
final NewLibraryEditor editor = settings.download(getMainPanel(), null);
if (editor != null) {
final LibraryEditorBase target = (LibraryEditorBase) myEditorComponent.getLibraryEditor();
target.removeAllRoots();
myEditorComponent.renameLibrary(editor.getName());
target.setType(myLibraryType);
editor.applyTo(target);
myEditorComponent.updateRootsTree();
myCurrentVersionString = settings.getVersion().getVersionString();
setModified();
}
}
}, current);
}
});
}
Aggregations