Search in sources :

Example 46 with LibraryTable

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

the class LibraryTest method testJarDirectoriesSerialization.

public void testJarDirectoriesSerialization() {
    LibraryTable table = getLibraryTable();
    Library library = ApplicationManager.getApplication().runWriteAction((Computable<Library>) () -> table.createLibrary("jarDirs"));
    Library.ModifiableModel model = library.getModifiableModel();
    model.addJarDirectory("file://jar-dir", false, OrderRootType.CLASSES);
    model.addJarDirectory("file://jar-dir-src", false, OrderRootType.SOURCES);
    commit(model);
    Element element = serialize(library);
    PlatformTestUtil.assertElementEquals("<root>\n" + "  <library name=\"jarDirs\">\n" + "    <CLASSES>\n" + "      <root url=\"file://jar-dir\" />\n" + "    </CLASSES>\n" + "    <JAVADOC />\n" + "    <SOURCES>\n" + "      <root url=\"file://jar-dir-src\" />\n" + "    </SOURCES>\n" + "    <jarDirectory url=\"file://jar-dir\" recursive=\"false\" />\n" + "    <jarDirectory url=\"file://jar-dir-src\" recursive=\"false\" type=\"SOURCES\" />\n" + "  </library>\n" + "</root>", element);
}
Also used : ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) Element(org.jdom.Element) Library(com.intellij.openapi.roots.libraries.Library)

Example 47 with LibraryTable

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

the class RootsChangedTest method testGlobalLibraryEventsInUncommittedModel.

public void testGlobalLibraryEventsInUncommittedModel() throws Exception {
    final LibraryTable globalLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable();
    verifyLibraryTableEditingInUncommittedModel(globalLibraryTable);
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable)

Example 48 with LibraryTable

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

the class SimpleClasspathElementFactory method createElements.

public static List<SimpleClasspathElement> createElements(@NotNull Library library) {
    final LibraryTable table = library.getTable();
    if (table != null && LibraryTablesRegistrar.APPLICATION_LEVEL.equals(table.getTableLevel())) {
        return Collections.<SimpleClasspathElement>singletonList(new GlobalLibraryReferenceElement(library.getName()));
    }
    final List<SimpleClasspathElement> elements = new ArrayList<>();
    for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) {
        elements.add(new SingleRootClasspathElement(file.getUrl()));
    }
    return elements;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) ArrayList(java.util.ArrayList)

Example 49 with LibraryTable

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

the class LibraryOrderEntryImpl method addListeners.

private void addListeners() {
    final String libraryLevel = getLibraryLevel();
    final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(libraryLevel, getRootModel().getModule().getProject());
    if (libraryTable != null) {
        myProjectRootManagerImpl.addListenerForTable(myLibraryListener, libraryTable);
    }
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable)

Example 50 with LibraryTable

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

the class LibraryOrderEntryImpl method searchForLibrary.

private void searchForLibrary(@NotNull String name, @NotNull String level) {
    if (myLibrary != null)
        return;
    final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(level, getRootModel().getModule().getProject());
    final Library library = libraryTable != null ? libraryTable.getLibraryByName(name) : null;
    if (library == null) {
        myLibraryName = name;
        myLibraryLevel = level;
        myLibrary = null;
    } else {
        myLibraryName = null;
        myLibraryLevel = null;
        myLibrary = library;
    }
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) Library(com.intellij.openapi.roots.libraries.Library)

Aggregations

LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)64 Library (com.intellij.openapi.roots.libraries.Library)43 ProjectLibraryTable (com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable)18 VirtualFile (com.intellij.openapi.vfs.VirtualFile)16 Module (com.intellij.openapi.module.Module)10 NotNull (org.jetbrains.annotations.NotNull)7 Project (com.intellij.openapi.project.Project)5 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)5 LibraryTablesRegistrar (com.intellij.openapi.roots.libraries.LibraryTablesRegistrar)4 File (java.io.File)4 Element (org.jdom.Element)4 LibraryImpl (com.intellij.openapi.roots.impl.libraries.LibraryImpl)3 ArrayList (java.util.ArrayList)3 FlexLibraryProperties (com.intellij.lang.javascript.flex.library.FlexLibraryProperties)2 Application (com.intellij.openapi.application.Application)2 Result (com.intellij.openapi.application.Result)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 OrderEntry (com.intellij.openapi.roots.OrderEntry)2 ModuleLibraryTable (com.intellij.openapi.roots.impl.ModuleLibraryTable)2