From 3171d15f1f796492b6d8bcaa9f81323b65165364 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 17 Apr 2014 12:20:50 +0400 Subject: [PATCH] create from sources: setup default (web) module if nothing special is detected (IDEA-91446, ZD-27093) --- .../DefaultProjectStructureDetector.java | 48 +++++++++++++++++++ resources/src/idea/RichPlatformPlugin.xml | 2 + 2 files changed, 50 insertions(+) create mode 100644 java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/DefaultProjectStructureDetector.java diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/DefaultProjectStructureDetector.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/DefaultProjectStructureDetector.java new file mode 100644 index 000000000000..dab952f51912 --- /dev/null +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/DefaultProjectStructureDetector.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.util.projectWizard.importSources; + +import com.intellij.ide.util.importProject.ProjectDescriptor; +import com.intellij.openapi.module.WebModuleType; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.util.Collection; +import java.util.List; + +/** + * @author nik + */ +public class DefaultProjectStructureDetector extends ProjectStructureDetector { + @NotNull + @Override + public DirectoryProcessingResult detectRoots(@NotNull File dir, + @NotNull File[] children, + @NotNull File base, + @NotNull List result) { + result.add(new DetectedContentRoot(dir, "Content", WebModuleType.getInstance())); + return DirectoryProcessingResult.SKIP_CHILDREN; + } + + @Override + public void setupProjectStructure(@NotNull Collection roots, + @NotNull ProjectDescriptor projectDescriptor, + @NotNull ProjectFromSourcesBuilder builder) { + if (!builder.hasRootsFromOtherDetectors(this)) { + builder.setupModulesByContentRoots(projectDescriptor, roots); + } + } +} diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index bef9a3ecd47a..d7dc396eac86 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -309,6 +309,8 @@ + +