Search in sources :

Example 6 with LibrariesContainer

use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer 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

LibrariesContainer (com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer)6 Library (com.intellij.openapi.roots.libraries.Library)3 NotNull (org.jetbrains.annotations.NotNull)2 FrameworkSupportInModuleProvider (com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)1 FrameworkSupportModelBase (com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase)1 Module (com.intellij.openapi.module.Module)1 IdeaModifiableModelsProvider (com.intellij.openapi.roots.IdeaModifiableModelsProvider)1 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1 LibraryPresentationManager (com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrayList (java.util.ArrayList)1