Search in sources :

Example 1 with LibrariesContainer

use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.

the class AddFrameworkSupportInProjectStructureAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Module module = getSelectedModule();
    if (module == null)
        return;
    final LibrariesContainer librariesContainer = LibrariesContainerFactory.createContainer(myModuleStructureConfigurable.getContext());
    new AddSupportForSingleFrameworkDialog(module, myFrameworkType, myProvider, librariesContainer, new IdeaModifiableModelsProvider()).show();
}
Also used : IdeaModifiableModelsProvider(com.intellij.openapi.roots.IdeaModifiableModelsProvider) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) Module(com.intellij.openapi.module.Module)

Example 2 with LibrariesContainer

use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.

the class AddSupportForSingleFrameworkDialog method createDialog.

public static AddSupportForSingleFrameworkDialog createDialog(@NotNull Module module, @NotNull FrameworkSupportInModuleProvider provider) {
    List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(module, DefaultFacetsProvider.INSTANCE);
    if (providers.isEmpty())
        return null;
    IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider();
    LibrariesContainer container = LibrariesContainerFactory.createContainer(modifiableModelsProvider.getModuleModifiableModel(module));
    return new AddSupportForSingleFrameworkDialog(module, provider.getFrameworkType(), provider, container, modifiableModelsProvider);
}
Also used : LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)

Example 3 with LibrariesContainer

use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.

the class AddSupportForSingleFrameworkDialog method askAndRemoveDuplicatedLibraryEntry.

private boolean askAndRemoveDuplicatedLibraryEntry(@NotNull ModifiableRootModel rootModel, @NotNull CustomLibraryDescription description) {
    List<OrderEntry> existingEntries = new ArrayList<>();
    final LibrariesContainer container = myModel.getLibrariesContainer();
    for (OrderEntry entry : rootModel.getOrderEntries()) {
        if (!(entry instanceof LibraryOrderEntry))
            continue;
        final Library library = ((LibraryOrderEntry) entry).getLibrary();
        if (library == null)
            continue;
        if (LibraryPresentationManager.getInstance().isLibraryOfKind(library, container, description.getSuitableLibraryKinds())) {
            existingEntries.add(entry);
        }
    }
    if (!existingEntries.isEmpty()) {
        String message;
        if (existingEntries.size() > 1) {
            message = "There are already " + existingEntries.size() + " " + myFrameworkType.getPresentableName() + " libraries.\n Do you want to replace them?";
        } else {
            final String name = existingEntries.get(0).getPresentableName();
            message = "There is already a " + myFrameworkType.getPresentableName() + " library '" + name + "'.\n Do you want to replace it?";
        }
        final int result = Messages.showYesNoCancelDialog(rootModel.getProject(), message, "Library Already Exists", "&Replace", "&Add", "&Cancel", null);
        if (result == Messages.YES) {
            for (OrderEntry entry : existingEntries) {
                rootModel.removeOrderEntry(entry);
            }
        } else if (result != Messages.NO) {
            return false;
        }
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) Library(com.intellij.openapi.roots.libraries.Library)

Example 4 with LibrariesContainer

use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.

the class CloudModuleBuilder method getFrameworkSupportModel.

public FrameworkSupportModelBase getFrameworkSupportModel() {
    if (myFrameworkSupportModel == null) {
        final LibrariesContainer librariesContainer = LibrariesContainerFactory.createContainer(myProject);
        myFrameworkSupportModel = new FrameworkSupportModelBase(myProject, this, librariesContainer) {

            @NotNull
            @Override
            public String getBaseDirectoryForLibrariesPath() {
                return StringUtil.notNullize(getContentEntryPath());
            }
        };
    }
    return myFrameworkSupportModel;
}
Also used : FrameworkSupportModelBase(com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 5 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