Search in sources :

Example 6 with DetectedFrameworkDescription

use of com.intellij.framework.detection.DetectedFrameworkDescription in project intellij-community by JetBrains.

the class FrameworkDetectionUtil method doGetDisabledDescriptions.

private static List<DetectedFrameworkDescription> doGetDisabledDescriptions(@NotNull List<? extends DetectedFrameworkDescription> currentDescriptions, @NotNull List<? extends DetectedFrameworkDescription> allDescriptions) {
    List<DetectedFrameworkDescription> disabled = new ArrayList<>();
    for (DetectedFrameworkDescription description : currentDescriptions) {
        if (!description.canSetupFramework(allDescriptions)) {
            disabled.add(description);
        }
    }
    if (!disabled.isEmpty()) {
        List<DetectedFrameworkDescription> remaining = new ArrayList<>(currentDescriptions);
        remaining.removeAll(disabled);
        disabled.addAll(doGetDisabledDescriptions(remaining, allDescriptions));
    }
    return disabled;
}
Also used : DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription) ArrayList(java.util.ArrayList)

Example 7 with DetectedFrameworkDescription

use of com.intellij.framework.detection.DetectedFrameworkDescription in project intellij-community by JetBrains.

the class DetectedFrameworksTree method createNodesGroupedByType.

private void createNodesGroupedByType(CheckedTreeNode root, final List<? extends DetectedFrameworkDescription> frameworks) {
    Map<FrameworkType, FrameworkTypeNode> groupNodes = new HashMap<>();
    for (DetectedFrameworkDescription framework : frameworks) {
        final FrameworkType type = framework.getDetector().getFrameworkType();
        FrameworkTypeNode group = groupNodes.get(type);
        if (group == null) {
            group = new FrameworkTypeNode(type);
            groupNodes.put(type, group);
            root.add(group);
        }
        group.add(new DetectedFrameworkNode(framework, myContext));
    }
}
Also used : FrameworkType(com.intellij.framework.FrameworkType) DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription)

Example 8 with DetectedFrameworkDescription

use of com.intellij.framework.detection.DetectedFrameworkDescription in project intellij-community by JetBrains.

the class FrameworkDetectionInWizardContext method createDetectedFacetDescriptions.

@NotNull
@Override
public <F extends Facet, C extends FacetConfiguration> List<? extends DetectedFrameworkDescription> createDetectedFacetDescriptions(@NotNull FacetBasedFrameworkDetector<F, C> detector, @NotNull Collection<VirtualFile> files) {
    final List<ModuleDescriptor> descriptors = getModuleDescriptors();
    MultiMap<ModuleDescriptor, VirtualFile> filesByModule = new MultiMap<>();
    for (VirtualFile file : files) {
        final File ioFile = VfsUtil.virtualToIoFile(file);
        ModuleDescriptor descriptor = findDescriptorByFile(descriptors, ioFile);
        if (descriptor != null) {
            filesByModule.putValue(descriptor, file);
        }
    }
    final List<DetectedFrameworkDescription> result = new ArrayList<>();
    final FacetType<F, C> facetType = detector.getFacetType();
    for (ModuleDescriptor module : filesByModule.keySet()) {
        if (!facetType.isSuitableModuleType(module.getModuleType())) {
            continue;
        }
        final List<Pair<C, Collection<VirtualFile>>> pairs = detector.createConfigurations(filesByModule.get(module), Collections.<C>emptyList());
        for (Pair<C, Collection<VirtualFile>> pair : pairs) {
            result.add(new FacetBasedDetectedFrameworkDescriptionInWizard<>(module, detector, pair.getFirst(), new HashSet<>(pair.getSecond())));
        }
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription) MultiMap(com.intellij.util.containers.MultiMap) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with DetectedFrameworkDescription

use of com.intellij.framework.detection.DetectedFrameworkDescription in project intellij-community by JetBrains.

the class DetectedFrameworksTree method createNodesGroupedByDirectory.

private void createNodesGroupedByDirectory(CheckedTreeNode root, final List<? extends DetectedFrameworkDescription> frameworks) {
    Map<VirtualFile, FrameworkDirectoryNode> nodes = new HashMap<>();
    List<DetectedFrameworkNode> externalNodes = new ArrayList<>();
    for (DetectedFrameworkDescription framework : frameworks) {
        VirtualFile parent = VfsUtil.getCommonAncestor(framework.getRelatedFiles());
        if (parent != null && !parent.isDirectory()) {
            parent = parent.getParent();
        }
        final DetectedFrameworkNode frameworkNode = new DetectedFrameworkNode(framework, myContext);
        if (parent != null) {
            createDirectoryNodes(parent, nodes).add(frameworkNode);
        } else {
            externalNodes.add(frameworkNode);
        }
    }
    List<FrameworkDirectoryNode> rootDirs = new ArrayList<>();
    for (FrameworkDirectoryNode directoryNode : nodes.values()) {
        if (directoryNode.getParent() == null) {
            rootDirs.add(directoryNode);
        }
    }
    for (FrameworkDirectoryNode dir : rootDirs) {
        root.add(collapseDirectoryNode(dir));
    }
    for (DetectedFrameworkNode node : externalNodes) {
        root.add(node);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription)

Example 10 with DetectedFrameworkDescription

use of com.intellij.framework.detection.DetectedFrameworkDescription in project intellij-community by JetBrains.

the class DetectedFrameworksTree method onNodeStateChanged.

@Override
protected void onNodeStateChanged(CheckedTreeNode node) {
    final List<DetectedFrameworkDescription> checked = Arrays.asList(getCheckedNodes(DetectedFrameworkDescription.class, null));
    final List<DetectedFrameworkDescription> disabled = FrameworkDetectionUtil.getDisabledDescriptions(checked, Collections.<DetectedFrameworkDescription>emptyList());
    for (DetectedFrameworkDescription description : disabled) {
        final DefaultMutableTreeNode treeNode = TreeUtil.findNodeWithObject(getRoot(), description);
        if (treeNode instanceof CheckedTreeNode) {
            ((CheckedTreeNode) treeNode).setChecked(false);
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription) CheckedTreeNode(com.intellij.ui.CheckedTreeNode)

Aggregations

DetectedFrameworkDescription (com.intellij.framework.detection.DetectedFrameworkDescription)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)3 NotNull (org.jetbrains.annotations.NotNull)3 DetectionExcludesConfiguration (com.intellij.framework.detection.DetectionExcludesConfiguration)2 Pair (com.intellij.openapi.util.Pair)2 FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)2 File (java.io.File)2 DefaultFacetsProvider (com.intellij.facet.impl.DefaultFacetsProvider)1 FrameworkType (com.intellij.framework.FrameworkType)1 ConfigureDetectedFrameworksDialog (com.intellij.framework.detection.impl.ui.ConfigureDetectedFrameworksDialog)1 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 Module (com.intellij.openapi.module.Module)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 PlatformModifiableModelsProvider (com.intellij.openapi.roots.PlatformModifiableModelsProvider)1 DefaultModulesProvider (com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider)1 FacetsProvider (com.intellij.openapi.roots.ui.configuration.FacetsProvider)1 CheckedTreeNode (com.intellij.ui.CheckedTreeNode)1 MultiMap (com.intellij.util.containers.MultiMap)1