Search in sources :

Example 26 with LibraryTable

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

the class RootsChangedTest method testProjectLibraryChangeEvent.

public void testProjectLibraryChangeEvent() throws Exception {
    final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
    verifyLibraryTableEditing(projectLibraryTable);
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable)

Example 27 with LibraryTable

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

the class RootsChangedTest method testProjectLibraryEventsInUncommittedModel.

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

Example 28 with LibraryTable

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

the class ModuleRootsExternalizationTest method testModuleLibraries.

public void testModuleLibraries() throws Exception {
    File moduleFile = new File(getTestRoot(), "test.iml");
    Module module = createModule(moduleFile);
    final ModuleRootManagerImpl moduleRootManager = (ModuleRootManagerImpl) ModuleRootManager.getInstance(module);
    final ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
    final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
    final Library unnamedLibrary = moduleLibraryTable.createLibrary();
    final File unnamedLibClasses = new File(getTestRoot(), "unnamedLibClasses");
    final VirtualFile unnamedLibClassesRoot = LocalFileSystem.getInstance().findFileByIoFile(unnamedLibClasses);
    final Library.ModifiableModel libraryModifyableModel = unnamedLibrary.getModifiableModel();
    libraryModifyableModel.addRoot(unnamedLibClassesRoot.getUrl(), OrderRootType.CLASSES);
    final Library namedLibrary = moduleLibraryTable.createLibrary("namedLibrary");
    final File namedLibClasses = new File(getTestRoot(), "namedLibClasses");
    final VirtualFile namedLibClassesRoot = LocalFileSystem.getInstance().findFileByIoFile(namedLibClasses);
    final Library.ModifiableModel namedLibraryModel = namedLibrary.getModifiableModel();
    namedLibraryModel.addRoot(namedLibClassesRoot.getUrl(), OrderRootType.CLASSES);
    ApplicationManager.getApplication().runWriteAction(() -> {
        libraryModifyableModel.commit();
        namedLibraryModel.commit();
    });
    final Iterator libraryIterator = moduleLibraryTable.getLibraryIterator();
    assertEquals(libraryIterator.next(), unnamedLibrary);
    assertEquals(libraryIterator.next(), namedLibrary);
    ApplicationManager.getApplication().runWriteAction(rootModel::commit);
    final Element element = new Element("root");
    moduleRootManager.getState().writeExternal(element);
    assertElementEquals(element, "<root inherit-compiler-output=\"true\">" + "<exclude-output />" + "<orderEntry type=\"sourceFolder\" forTests=\"false\" />" + "<orderEntry type=\"module-library\">" + "<library>" + "<CLASSES><root url=\"file://$MODULE_DIR$/unnamedLibClasses\" /></CLASSES>" + "<JAVADOC />" + "<SOURCES />" + "</library>" + "</orderEntry>" + "<orderEntry type=\"module-library\">" + "<library name=\"namedLibrary\">" + "<CLASSES><root url=\"file://$MODULE_DIR$/namedLibClasses\" /></CLASSES>" + "<JAVADOC />" + "<SOURCES />" + "</library>" + "</orderEntry>" + "</root>", module);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) ModuleRootManagerImpl(com.intellij.openapi.roots.impl.ModuleRootManagerImpl) Element(org.jdom.Element) Iterator(java.util.Iterator) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 29 with LibraryTable

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

the class ClasspathPanelImpl method doEdit.

private void doEdit() {
    final OrderEntry entry = getSelectedEntry();
    if (!(entry instanceof LibraryOrderEntry))
        return;
    final Library library = ((LibraryOrderEntry) entry).getLibrary();
    if (library == null) {
        return;
    }
    final LibraryTable table = library.getTable();
    final String tableLevel = table != null ? table.getTableLevel() : LibraryTableImplUtil.MODULE_LEVEL;
    final LibraryTablePresentation presentation = LibraryEditingUtil.getLibraryTablePresentation(getProject(), tableLevel);
    final LibraryTableModifiableModelProvider provider = getModifiableModelProvider(tableLevel);
    EditExistingLibraryDialog dialog = EditExistingLibraryDialog.createDialog(this, provider, library, myState.getProject(), presentation, getStructureConfigurableContext());
    dialog.setContextModule(getRootModel().getModule());
    dialog.show();
    myEntryTable.repaint();
    ModuleStructureConfigurable.getInstance(myState.getProject()).getTree().repaint();
}
Also used : LibraryTablePresentation(com.intellij.openapi.roots.libraries.LibraryTablePresentation) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) EditExistingLibraryDialog(com.intellij.openapi.roots.ui.configuration.libraryEditor.EditExistingLibraryDialog) Library(com.intellij.openapi.roots.libraries.Library) LibraryTableModifiableModelProvider(com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider)

Example 30 with LibraryTable

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

the class LibrariesContainerFactory method createLibraryInTable.

@NotNull
private static Library createLibraryInTable(@NotNull final NewLibraryEditor editor, final LibraryTable table) {
    LibraryTable.ModifiableModel modifiableModel = table.getModifiableModel();
    final String name = StringUtil.isEmpty(editor.getName()) ? null : getUniqueLibraryName(editor.getName(), modifiableModel);
    final LibraryType<?> type = editor.getType();
    Library library = modifiableModel.createLibrary(name, type == null ? null : type.getKind());
    final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx) library.getModifiableModel();
    editor.applyTo(model);
    model.commit();
    modifiableModel.commit();
    return library;
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) Library(com.intellij.openapi.roots.libraries.Library) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)65 Library (com.intellij.openapi.roots.libraries.Library)44 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