Search in sources :

Example 1 with FrameworkSupportInModuleProvider

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

the class AddFrameworkSupportInProjectStructureAction method isVisible.

private boolean isVisible() {
    final Module module = getSelectedModule();
    if (module == null || !myProvider.isEnabledForModuleType(ModuleType.get(module))) {
        return false;
    }
    final ProjectFacetsConfigurator facetsProvider = myModuleStructureConfigurable.getFacetConfigurator();
    if (!myProvider.canAddSupport(module, facetsProvider)) {
        return false;
    }
    final String underlyingFrameworkTypeId = myFrameworkType.getUnderlyingFrameworkTypeId();
    if (underlyingFrameworkTypeId == null)
        return true;
    final FrameworkSupportInModuleProvider underlyingProvider = FrameworkSupportUtil.findProvider(underlyingFrameworkTypeId, FrameworkSupportUtil.getAllProviders());
    if (underlyingProvider == null) {
        LOG.error("framework not found by id " + underlyingFrameworkTypeId);
    }
    return underlyingProvider.isSupportAlreadyAdded(module, facetsProvider);
}
Also used : Module(com.intellij.openapi.module.Module) ProjectFacetsConfigurator(com.intellij.facet.impl.ProjectFacetsConfigurator) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)

Example 2 with FrameworkSupportInModuleProvider

use of com.intellij.framework.addSupport.FrameworkSupportInModuleProvider 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 FrameworkSupportInModuleProvider

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

the class FrameworkSupportModelBase method onFrameworkSelectionChanged.

public void onFrameworkSelectionChanged(FrameworkSupportNode node) {
    final FrameworkSupportInModuleProvider provider = node.getUserObject();
    //todo[nik]
    boolean checked = node.isChecked();
    if (provider instanceof OldFrameworkSupportProviderWrapper) {
        final FrameworkSupportProvider oldProvider = ((OldFrameworkSupportProviderWrapper) provider).getProvider();
        selectFramework(oldProvider, checked);
    }
    for (FrameworkSupportInModuleProvider.FrameworkDependency dependency : provider.getDependenciesFrameworkIds()) {
        if (!dependency.isOptional()) {
            String id = dependency.getFrameworkId();
            setFrameworkComponentEnabled(id, true);
        }
    }
}
Also used : FrameworkSupportProvider(com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider) OldFrameworkSupportProviderWrapper(com.intellij.ide.util.newProjectWizard.OldFrameworkSupportProviderWrapper) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)

Example 4 with FrameworkSupportInModuleProvider

use of com.intellij.framework.addSupport.FrameworkSupportInModuleProvider 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 5 with FrameworkSupportInModuleProvider

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

the class AddSupportForFrameworksPanel method createNode.

@Nullable
private FrameworkSupportNode createNode(final FrameworkSupportInModuleProvider provider, final Map<String, FrameworkSupportNode> nodes, final Map<FrameworkGroup<?>, FrameworkGroupNode> groupNodes, List<FrameworkSupportNodeBase> roots, List<FrameworkSupportInModuleProvider> providers, Set<String> associated, Map<String, FrameworkSupportNodeBase> associatedNodes) {
    String id = provider.getFrameworkType().getId();
    FrameworkSupportNode node = nodes.get(id);
    if (node != null || associatedNodes.containsKey(id)) {
        return node;
    }
    String underlyingTypeId = provider.getFrameworkType().getUnderlyingFrameworkTypeId();
    FrameworkSupportNodeBase parentNode = null;
    final FrameworkGroup<?> group = provider.getFrameworkType().getParentGroup();
    if (underlyingTypeId != null) {
        FrameworkSupportInModuleProvider parentProvider = FrameworkSupportUtil.findProvider(underlyingTypeId, providers);
        if (parentProvider == null) {
            LOG.info("Cannot find id = " + underlyingTypeId);
            return null;
        }
        parentNode = createNode(parentProvider, nodes, groupNodes, roots, providers, associated, associatedNodes);
    } else if (group != null) {
        parentNode = groupNodes.get(group);
        if (parentNode == null) {
            FrameworkGroupNode groupNode = new FrameworkGroupNode(group, null);
            if (associated.contains(groupNode.getId())) {
                associatedNodes.put(groupNode.getId(), groupNode);
            } else {
                groupNodes.put(group, groupNode);
                parentNode = groupNode;
                roots.add(groupNode);
            }
        }
    }
    node = new FrameworkSupportNode(provider, parentNode, myModel, this);
    if (associated.contains(id)) {
        associatedNodes.put(id, node);
    } else {
        nodes.put(id, node);
        if (parentNode == null) {
            roots.add(node);
        }
    }
    return node;
}
Also used : FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FrameworkSupportInModuleProvider (com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)9 FrameworkSupportProvider (com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider)2 ProjectFacetsConfigurator (com.intellij.facet.impl.ProjectFacetsConfigurator)1 LibraryCompositionSettings (com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings)1 FacetBasedFrameworkSupportProvider (com.intellij.facet.ui.FacetBasedFrameworkSupportProvider)1 FrameworkGroup (com.intellij.framework.FrameworkGroup)1 FrameworkSupportInModuleConfigurable (com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable)1 FrameworkSupportConfigurable (com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable)1 FrameworkSupportNode (com.intellij.ide.util.newProjectWizard.FrameworkSupportNode)1 OldFrameworkSupportProviderWrapper (com.intellij.ide.util.newProjectWizard.OldFrameworkSupportProviderWrapper)1 FrameworkSupportCommunicator (com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 IdeaModifiableModelsProvider (com.intellij.openapi.roots.IdeaModifiableModelsProvider)1 Library (com.intellij.openapi.roots.libraries.Library)1 LibrariesContainer (com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer)1 Nullable (org.jetbrains.annotations.Nullable)1