Search in sources :

Example 1 with LibraryEditorBase

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);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FrameworkLibraryVersion(com.intellij.framework.library.FrameworkLibraryVersion) LibraryDownloadSettings(com.intellij.facet.impl.ui.libraries.LibraryDownloadSettings) ModalityState(com.intellij.openapi.application.ModalityState) DownloadableFileSetVersions(com.intellij.util.download.DownloadableFileSetVersions) LibraryEditorBase(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorBase) NewLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor)

Aggregations

LibraryDownloadSettings (com.intellij.facet.impl.ui.libraries.LibraryDownloadSettings)1 FrameworkLibraryVersion (com.intellij.framework.library.FrameworkLibraryVersion)1 ModalityState (com.intellij.openapi.application.ModalityState)1 LibraryEditorBase (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorBase)1 NewLibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 DownloadableFileSetVersions (com.intellij.util.download.DownloadableFileSetVersions)1