Search in sources :

Example 1 with FrameworkSupportInModuleConfigurable

use of com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable in project intellij-community by JetBrains.

the class FrameworkSupportProviderTestCase method getOrCreateConfigurable.

private FrameworkSupportInModuleConfigurable getOrCreateConfigurable(FrameworkSupportInModuleProvider provider) {
    FrameworkSupportInModuleConfigurable configurable = myConfigurables.get(provider.getFrameworkType());
    if (configurable == null) {
        configurable = provider.createConfigurable(myFrameworkSupportModel);
        myConfigurables.put(provider.getFrameworkType(), configurable);
    }
    return configurable;
}
Also used : FrameworkSupportInModuleConfigurable(com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable)

Example 2 with FrameworkSupportInModuleConfigurable

use of com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable in project intellij-community by JetBrains.

the class FrameworkSupportProviderTestCase method addSupport.

protected void addSupport() {
    new WriteCommandAction.Simple(getProject()) {

        @Override
        protected void run() throws Throwable {
            final VirtualFile root = getVirtualFile(createTempDir("contentRoot"));
            PsiTestUtil.addContentRoot(myModule, root);
            final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
            try {
                List<FrameworkSupportConfigurable> selectedConfigurables = new ArrayList<>();
                final IdeaModifiableModelsProvider modelsProvider = new IdeaModifiableModelsProvider();
                for (FrameworkSupportNode node : myNodes.values()) {
                    if (node.isChecked()) {
                        final FrameworkSupportInModuleConfigurable configurable = getOrCreateConfigurable(node.getUserObject());
                        configurable.addSupport(myModule, model, modelsProvider);
                        if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
                            selectedConfigurables.add(((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable).getConfigurable());
                        }
                    }
                }
                for (FrameworkSupportCommunicator communicator : FrameworkSupportCommunicator.EP_NAME.getExtensions()) {
                    communicator.onFrameworkSupportAdded(myModule, model, selectedConfigurables, myFrameworkSupportModel);
                }
            } finally {
                model.commit();
            }
            for (FrameworkSupportInModuleConfigurable configurable : myConfigurables.values()) {
                Disposer.dispose(configurable);
            }
        }
    }.execute().throwException();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) IdeaModifiableModelsProvider(com.intellij.openapi.roots.IdeaModifiableModelsProvider) FrameworkSupportNode(com.intellij.ide.util.newProjectWizard.FrameworkSupportNode) OldFrameworkSupportProviderWrapper(com.intellij.ide.util.newProjectWizard.OldFrameworkSupportProviderWrapper) FrameworkSupportInModuleConfigurable(com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable) FrameworkSupportCommunicator(com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator)

Example 3 with FrameworkSupportInModuleConfigurable

use of com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable in project intellij-community by JetBrains.

the class AddSupportForFrameworksPanel method addSupport.

public void addSupport(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel) {
    List<Library> addedLibraries = new ArrayList<>();
    List<FrameworkSupportNode> selectedFrameworks = getSelectedNodes();
    sortFrameworks(selectedFrameworks);
    List<FrameworkSupportConfigurable> selectedConfigurables = new ArrayList<>();
    final IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider();
    for (FrameworkSupportNode node : selectedFrameworks) {
        FrameworkSupportInModuleConfigurable configurable = node.getConfigurable();
        if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
            selectedConfigurables.add(((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable).getConfigurable());
        }
        final LibraryCompositionSettings settings = getLibraryCompositionSettings(node);
        Library library = settings != null ? settings.addLibraries(rootModel, addedLibraries, myLibrariesContainer) : null;
        if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
            ((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable).getConfigurable().addSupport(module, rootModel, library);
        } else {
            configurable.addSupport(module, rootModel, modifiableModelsProvider);
        }
    }
    for (FrameworkSupportNode node : selectedFrameworks) {
        FrameworkSupportInModuleProvider provider = node.getUserObject();
        if (provider instanceof OldFrameworkSupportProviderWrapper) {
            final FrameworkSupportProvider oldProvider = ((OldFrameworkSupportProviderWrapper) provider).getProvider();
            if (oldProvider instanceof FacetBasedFrameworkSupportProvider && !addedLibraries.isEmpty()) {
                ((FacetBasedFrameworkSupportProvider) oldProvider).processAddedLibraries(module, addedLibraries);
            }
        }
    }
    for (FrameworkSupportCommunicator communicator : FrameworkSupportCommunicator.EP_NAME.getExtensions()) {
        communicator.onFrameworkSupportAdded(module, rootModel, selectedConfigurables, myModel);
    }
}
Also used : LibraryCompositionSettings(com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings) FrameworkSupportProvider(com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider) FacetBasedFrameworkSupportProvider(com.intellij.facet.ui.FacetBasedFrameworkSupportProvider) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider) FrameworkSupportConfigurable(com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable) IdeaModifiableModelsProvider(com.intellij.openapi.roots.IdeaModifiableModelsProvider) Library(com.intellij.openapi.roots.libraries.Library) FrameworkSupportInModuleConfigurable(com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable) FacetBasedFrameworkSupportProvider(com.intellij.facet.ui.FacetBasedFrameworkSupportProvider) FrameworkSupportCommunicator(com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator)

Example 4 with FrameworkSupportInModuleConfigurable

use of com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineStandardSupportProviderTest method setupAppEngine.

private void setupAppEngine(AppEngineStandardLibraryPanel libraryPanel, Library library) {
    CloudSdkService sdkService = mock(CloudSdkService.class);
    CloudSdkServiceManager sdkServiceManager = mock(CloudSdkServiceManager.class);
    when(sdkServiceManager.getCloudSdkService()).thenReturn(sdkService);
    CloudSdkInternals mockSdkInternals = mock(CloudSdkInternals.class);
    when(mockSdkInternals.getLibraries()).thenReturn(new File[] {});
    CloudSdkInternals.setInstance(mockSdkInternals);
    MavenRepositoryLibraryDownloader libraryDownloader = mock(MavenRepositoryLibraryDownloader.class);
    when(libraryDownloader.downloadLibrary(any(Module.class), any(AppEngineStandardMavenLibrary.class))).thenReturn(library);
    MutablePicoContainer applicationContainer = (MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer();
    applicationContainer.unregisterComponent(CloudSdkService.class.getName());
    applicationContainer.registerComponentInstance(CloudSdkService.class.getName(), sdkService);
    applicationContainer.unregisterComponent(MavenRepositoryLibraryDownloader.class.getName());
    applicationContainer.registerComponentInstance(MavenRepositoryLibraryDownloader.class.getName(), libraryDownloader);
    FrameworkSupportInModuleConfigurable configurable = selectFramework(AppEngineStandardFrameworkType.ID);
    if (libraryPanel != null && configurable instanceof AppEngineSupportConfigurable) {
        ((AppEngineSupportConfigurable) configurable).setAppEngineStandardLibraryPanel(libraryPanel);
    }
    CloudSdkServiceUserSettings.getInstance().setCustomSdkPath(AppEngineCodeInsightTestCase.getSdkPath());
}
Also used : MutablePicoContainer(org.picocontainer.MutablePicoContainer) AppEngineSupportConfigurable(com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardSupportProvider.AppEngineSupportConfigurable) AppEngineStandardMavenLibrary(com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardMavenLibrary) CloudSdkInternals(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkInternals) CloudSdkService(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService) MavenRepositoryLibraryDownloader(com.google.cloud.tools.intellij.appengine.facet.standard.MavenRepositoryLibraryDownloader) Module(com.intellij.openapi.module.Module) FrameworkSupportInModuleConfigurable(com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable) CloudSdkServiceManager(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkServiceManager)

Example 5 with FrameworkSupportInModuleConfigurable

use of com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable in project intellij-community by JetBrains.

the class FrameworkSupportProviderTestCase method selectFramework.

protected FrameworkSupportInModuleConfigurable selectFramework(@NotNull FrameworkSupportInModuleProvider provider) {
    final FrameworkSupportInModuleConfigurable configurable = getOrCreateConfigurable(provider);
    myNodes.get(provider.getFrameworkType()).setChecked(true);
    configurable.onFrameworkSelectionChanged(true);
    return configurable;
}
Also used : FrameworkSupportInModuleConfigurable(com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable)

Aggregations

FrameworkSupportInModuleConfigurable (com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable)5 FrameworkSupportCommunicator (com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator)2 IdeaModifiableModelsProvider (com.intellij.openapi.roots.IdeaModifiableModelsProvider)2 AppEngineStandardMavenLibrary (com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardMavenLibrary)1 AppEngineSupportConfigurable (com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardSupportProvider.AppEngineSupportConfigurable)1 MavenRepositoryLibraryDownloader (com.google.cloud.tools.intellij.appengine.facet.standard.MavenRepositoryLibraryDownloader)1 CloudSdkInternals (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkInternals)1 CloudSdkService (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService)1 CloudSdkServiceManager (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkServiceManager)1 LibraryCompositionSettings (com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings)1 FacetBasedFrameworkSupportProvider (com.intellij.facet.ui.FacetBasedFrameworkSupportProvider)1 FrameworkSupportInModuleProvider (com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)1 FrameworkSupportConfigurable (com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable)1 FrameworkSupportProvider (com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider)1 FrameworkSupportNode (com.intellij.ide.util.newProjectWizard.FrameworkSupportNode)1 OldFrameworkSupportProviderWrapper (com.intellij.ide.util.newProjectWizard.OldFrameworkSupportProviderWrapper)1 Module (com.intellij.openapi.module.Module)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 Library (com.intellij.openapi.roots.libraries.Library)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1