Search in sources :

Example 1 with LibraryTable

use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.

the class MvcModuleStructureUtil method modifyDefaultLibrary.

public static Library.ModifiableModel modifyDefaultLibrary(ModifiableRootModel model, String libName) {
    LibraryTable libTable = model.getModuleLibraryTable();
    for (Library library : libTable.getLibraries()) {
        if (library.getName() != null && library.getName().startsWith(libName)) {
            return library.getModifiableModel();
        }
    }
    Library library = LibraryUtil.createLibrary(libTable, libName + " (" + model.getModule().getName() + ')');
    for (OrderEntry entry : model.getOrderEntries()) {
        if (!(entry instanceof LibraryOrderEntry))
            continue;
        LibraryOrderEntry libraryEntry = (LibraryOrderEntry) entry;
        if (libraryEntry.isModuleLevel() && libraryEntry.getLibrary() == library) {
            libraryEntry.setExported(true);
        }
    }
    return library.getModifiableModel();
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) Library(com.intellij.openapi.roots.libraries.Library)

Example 2 with LibraryTable

use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.

the class DependenciesImportingTest method testDoNotFailOnAbsentAppLibrary.

public void testDoNotFailOnAbsentAppLibrary() throws Exception {
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
    ApplicationManager.getApplication().runWriteAction(() -> {
        LibraryTable appTable = LibraryTablesRegistrar.getInstance().getLibraryTable();
        Library lib = appTable.createLibrary("foo");
        ModuleRootModificationUtil.addDependency(getModule("project"), lib);
        appTable.removeLibrary(lib);
    });
    // should not fail;
    importProject();
}
Also used : ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) Library(com.intellij.openapi.roots.libraries.Library)

Example 3 with LibraryTable

use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.

the class LibraryElementPresentation method getLibraryTableDisplayName.

public static String getLibraryTableDisplayName(final Library library) {
    LibraryTable table = library.getTable();
    LibraryTablePresentation presentation = table != null ? table.getPresentation() : ModuleLibraryTable.MODULE_LIBRARY_TABLE_PRESENTATION;
    return presentation.getDisplayName(false);
}
Also used : LibraryTablePresentation(com.intellij.openapi.roots.libraries.LibraryTablePresentation) ModuleLibraryTable(com.intellij.openapi.roots.impl.ModuleLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable)

Example 4 with LibraryTable

use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.

the class LibraryElementPresentation method getLibraryTableComment.

public static String getLibraryTableComment(final Library library) {
    LibraryTable libraryTable = library.getTable();
    String displayName;
    if (libraryTable != null) {
        displayName = libraryTable.getPresentation().getDisplayName(false);
    } else {
        Module module = ((LibraryImpl) library).getModule();
        String tableName = getLibraryTableDisplayName(library);
        displayName = module != null ? "'" + module.getName() + "' " + tableName : tableName;
    }
    return " (" + displayName + ")";
}
Also used : ModuleLibraryTable(com.intellij.openapi.roots.impl.ModuleLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) LibraryImpl(com.intellij.openapi.roots.impl.libraries.LibraryImpl) Module(com.intellij.openapi.module.Module)

Example 5 with LibraryTable

use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.

the class LibraryConfigurable method getBannerSlogan.

@Override
public String getBannerSlogan() {
    final LibraryTable libraryTable = myLibrary.getTable();
    String libraryType = libraryTable == null ? ProjectBundle.message("module.library.display.name", 1) : libraryTable.getPresentation().getDisplayName(false);
    return ProjectBundle.message("project.roots.library.banner.text", getDisplayName(), libraryType);
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable)

Aggregations

LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)76 Library (com.intellij.openapi.roots.libraries.Library)55 ProjectLibraryTable (com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 Module (com.intellij.openapi.module.Module)11 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)7 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)7 NotNull (org.jetbrains.annotations.NotNull)7 Project (com.intellij.openapi.project.Project)6 File (java.io.File)5 Element (org.jdom.Element)4 BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)3 Result (com.intellij.openapi.application.Result)3 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)3 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)3 LibraryTablesRegistrar (com.intellij.openapi.roots.libraries.LibraryTablesRegistrar)3 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)3 FlexLibraryProperties (com.intellij.lang.javascript.flex.library.FlexLibraryProperties)2 Application (com.intellij.openapi.application.Application)2 WriteAction (com.intellij.openapi.application.WriteAction)2