Search in sources :

Example 26 with LibraryOrderEntry

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

the class ProjectSettingsService method getLibrarySettingsConfigurable.

@Nullable
private static Configurable getLibrarySettingsConfigurable(OrderEntry orderEntry) {
    if (!(orderEntry instanceof LibraryOrderEntry))
        return null;
    LibraryOrderEntry libOrderEntry = (LibraryOrderEntry) orderEntry;
    Library lib = libOrderEntry.getLibrary();
    if (lib instanceof LibraryEx) {
        Project project = libOrderEntry.getOwnerModule().getProject();
        PersistentLibraryKind<?> libKind = ((LibraryEx) lib).getKind();
        if (libKind != null) {
            return LibrarySettingsProvider.getAdditionalSettingsConfigurable(project, libKind);
        }
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Library(com.intellij.openapi.roots.libraries.Library) Nullable(org.jetbrains.annotations.Nullable)

Example 27 with LibraryOrderEntry

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

the class LibraryPackagingElement method findLibrary.

@Nullable
public Library findLibrary(@NotNull PackagingElementResolvingContext context) {
    if (myModuleName == null) {
        return context.findLibrary(myLevel, myLibraryName);
    }
    final ModulesProvider modulesProvider = context.getModulesProvider();
    final Module module = modulesProvider.getModule(myModuleName);
    if (module != null) {
        for (OrderEntry entry : modulesProvider.getRootModel(module).getOrderEntries()) {
            if (entry instanceof LibraryOrderEntry) {
                final LibraryOrderEntry libraryEntry = (LibraryOrderEntry) entry;
                if (libraryEntry.isModuleLevel()) {
                    final String libraryName = libraryEntry.getLibraryName();
                    if (libraryName != null && libraryName.equals(myLibraryName)) {
                        return libraryEntry.getLibrary();
                    }
                }
            }
        }
    }
    return null;
}
Also used : ModulesProvider(com.intellij.openapi.roots.ui.configuration.ModulesProvider) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 28 with LibraryOrderEntry

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

the class ChooseLibrariesDialogBase method collectChildren.

protected void collectChildren(Object element, final List<Object> result) {
    if (element instanceof Application) {
        Collections.addAll(result, ProjectManager.getInstance().getOpenProjects());
        final LibraryTablesRegistrar instance = LibraryTablesRegistrar.getInstance();
        //1
        result.add(instance.getLibraryTable());
        //2
        result.addAll(instance.getCustomLibraryTables());
    } else if (element instanceof Project) {
        Collections.addAll(result, ModuleManager.getInstance((Project) element).getModules());
        result.add(LibraryTablesRegistrar.getInstance().getLibraryTable((Project) element));
    } else if (element instanceof LibraryTable) {
        Collections.addAll(result, ((LibraryTable) element).getLibraries());
    } else if (element instanceof Module) {
        for (OrderEntry entry : ModuleRootManager.getInstance((Module) element).getOrderEntries()) {
            if (entry instanceof LibraryOrderEntry) {
                final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) entry;
                if (LibraryTableImplUtil.MODULE_LEVEL.equals(libraryOrderEntry.getLibraryLevel())) {
                    final Library library = libraryOrderEntry.getLibrary();
                    result.add(library);
                }
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) LibraryTablesRegistrar(com.intellij.openapi.roots.libraries.LibraryTablesRegistrar) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) Application(com.intellij.openapi.application.Application)

Example 29 with LibraryOrderEntry

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

the class MavenProjectImporter method removeUnusedProjectLibraries.

private boolean removeUnusedProjectLibraries() {
    Set<Library> unusedLibraries = new HashSet<>();
    Collections.addAll(unusedLibraries, myModelsProvider.getAllLibraries());
    for (ModuleRootModel eachModel : collectModuleModels()) {
        for (OrderEntry eachEntry : eachModel.getOrderEntries()) {
            if (eachEntry instanceof LibraryOrderEntry) {
                unusedLibraries.remove(((LibraryOrderEntry) eachEntry).getLibrary());
            }
        }
    }
    boolean removed = false;
    for (Library each : unusedLibraries) {
        if (!isDisposed(each) && MavenRootModelAdapter.isMavenLibrary(each) && !MavenRootModelAdapter.isChangedByUser(each)) {
            myModelsProvider.removeLibrary(each);
            removed = true;
        }
    }
    return removed;
}
Also used : OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) ModuleRootModel(com.intellij.openapi.roots.ModuleRootModel) Library(com.intellij.openapi.roots.libraries.Library) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) THashSet(gnu.trove.THashSet)

Example 30 with LibraryOrderEntry

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

the class MvcUpgradeAction method removeOldMvcSdk.

public static void removeOldMvcSdk(MvcFramework framework, ModifiableRootModel model) {
    final LibraryPresentationManager presentationManager = LibraryPresentationManager.getInstance();
    for (OrderEntry entry : model.getOrderEntries()) {
        if (entry instanceof LibraryOrderEntry) {
            final Library library = ((LibraryOrderEntry) entry).getLibrary();
            final LibrariesContainer container = LibrariesContainerFactory.createContainer(model);
            if (library != null) {
                final VirtualFile[] files = container.getLibraryFiles(library, OrderRootType.CLASSES);
                if (presentationManager.isLibraryOfKind(Arrays.asList(files), framework.getLibraryKind())) {
                    model.removeOrderEntry(entry);
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Library(com.intellij.openapi.roots.libraries.Library) LibraryPresentationManager(com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager)

Aggregations

LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)40 Library (com.intellij.openapi.roots.libraries.Library)27 OrderEntry (com.intellij.openapi.roots.OrderEntry)17 Module (com.intellij.openapi.module.Module)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)7 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)6 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)5 Nullable (org.jetbrains.annotations.Nullable)5 Project (com.intellij.openapi.project.Project)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)3 ActionCallback (com.intellij.openapi.util.ActionCallback)3 THashSet (gnu.trove.THashSet)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Notification (com.intellij.notification.Notification)2 IdeModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)2 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)2