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;
}
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));
}
}
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;
}
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);
}
}
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);
}
}
}
Aggregations