Search in sources :

Example 1 with NewLibraryEditor

use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project kotlin by JetBrains.

the class KotlinDebuggerTestCase method configureLibrary.

private static void configureLibrary(@NotNull ModifiableRootModel model, @NotNull String libraryName, @NotNull File classes, @NotNull File sources) {
    NewLibraryEditor customLibEditor = new NewLibraryEditor();
    customLibEditor.setName(libraryName);
    customLibEditor.addRoot(VfsUtil.getUrlForLibraryRoot(classes), OrderRootType.CLASSES);
    customLibEditor.addRoot(VfsUtil.getUrlForLibraryRoot(sources), OrderRootType.SOURCES);
    ConfigLibraryUtil.addLibrary(customLibEditor, model);
}
Also used : NewLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor)

Example 2 with NewLibraryEditor

use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project kotlin by JetBrains.

the class KotlinJdkAndLibraryProjectDescriptor method configureModule.

@Override
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model) {
    NewLibraryEditor editor = new NewLibraryEditor();
    editor.setName(LIBRARY_NAME);
    editor.addRoot(VfsUtil.getUrlForLibraryRoot(libraryFile), OrderRootType.CLASSES);
    ConfigLibraryUtil.addLibrary(editor, model);
}
Also used : NewLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor)

Example 3 with NewLibraryEditor

use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project intellij-community by JetBrains.

the class NewLibraryChooser method createLibrary.

@Nullable
public Library createLibrary() {
    final NewLibraryConfiguration configuration = CreateNewLibraryAction.createNewLibraryConfiguration(myLibraryType, myParentComponent, myProject);
    if (configuration == null)
        return null;
    final NewLibraryEditor libraryEditor = new NewLibraryEditor(configuration.getLibraryType(), configuration.getProperties());
    libraryEditor.setName(configuration.getDefaultLibraryName());
    configuration.addRoots(libraryEditor);
    final LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
    List<LibraryTable> tables = Arrays.asList(myRootModel.getModuleLibraryTable(), registrar.getLibraryTable(myProject), registrar.getLibraryTable());
    CreateNewLibraryDialog dialog = new CreateNewLibraryDialog(myParentComponent, myContext, libraryEditor, tables, 1);
    final Module contextModule = LangDataKeys.MODULE_CONTEXT.getData(DataManager.getInstance().getDataContext(myParentComponent));
    dialog.setContextModule(contextModule);
    if (dialog.showAndGet()) {
        return dialog.createLibrary();
    }
    return null;
}
Also used : CreateNewLibraryDialog(com.intellij.openapi.roots.ui.configuration.libraryEditor.CreateNewLibraryDialog) Module(com.intellij.openapi.module.Module) NewLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with NewLibraryEditor

use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor 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)

Example 5 with NewLibraryEditor

use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project intellij-community by JetBrains.

the class LibraryOptionsPanel method doCreate.

private void doCreate(boolean useDefaultSettings) {
    final NewLibraryConfiguration libraryConfiguration = useDefaultSettings ? myLibraryDescription.createNewLibraryWithDefaultSettings(getBaseDirectory()) : myLibraryDescription.createNewLibrary(myCreateButton, getBaseDirectory());
    if (libraryConfiguration != null) {
        final NewLibraryEditor libraryEditor = new NewLibraryEditor(libraryConfiguration.getLibraryType(), libraryConfiguration.getProperties());
        libraryEditor.setName(myLibrariesContainer.suggestUniqueLibraryName(libraryConfiguration.getDefaultLibraryName()));
        libraryConfiguration.addRoots(libraryEditor);
        if (myLibraryComboBoxModel.get(0) == null) {
            myLibraryComboBoxModel.remove(0);
        }
        myLibraryComboBoxModel.add(libraryEditor);
        myLibraryComboBoxModel.setSelectedItem(libraryEditor);
        myButtonEnumModel.setSelected(Choice.USE_LIBRARY);
    }
}
Also used : NewLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor) NewLibraryConfiguration(com.intellij.openapi.roots.libraries.NewLibraryConfiguration)

Aggregations

NewLibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor)11 NewLibraryConfiguration (com.intellij.openapi.roots.libraries.NewLibraryConfiguration)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Nullable (org.jetbrains.annotations.Nullable)3 FrameworkLibraryVersion (com.intellij.framework.library.FrameworkLibraryVersion)2 OrderRootType (com.intellij.openapi.roots.OrderRootType)2 DownloadableFileSetVersions (com.intellij.util.download.DownloadableFileSetVersions)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 LibraryDownloadSettings (com.intellij.facet.impl.ui.libraries.LibraryDownloadSettings)1 DownloadableLibraryDescription (com.intellij.framework.library.DownloadableLibraryDescription)1 DownloadableLibraryFileDescription (com.intellij.framework.library.DownloadableLibraryFileDescription)1 DownloadableLibraryType (com.intellij.framework.library.DownloadableLibraryType)1 FrameworkLibraryVersionFilter (com.intellij.framework.library.FrameworkLibraryVersionFilter)1 LibraryVersionProperties (com.intellij.framework.library.LibraryVersionProperties)1 AllIcons (com.intellij.icons.AllIcons)1 IdeBundle (com.intellij.ide.IdeBundle)1 OldCustomLibraryDescription (com.intellij.ide.util.frameworkSupport.OldCustomLibraryDescription)1 Disposable (com.intellij.openapi.Disposable)1 ModalityState (com.intellij.openapi.application.ModalityState)1