Search in sources :

Example 1 with ModuleDescriptor

use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-community by JetBrains.

the class GroovySdkForProjectFromSourcesStep method updateDataModel.

@Override
public void updateDataModel() {
    super.updateDataModel();
    List<ModuleDescriptor> modules = new ArrayList<>();
    for (DetectedProjectRoot root : myBuilder.getProjectRoots(myDetector)) {
        final ModuleDescriptor descriptor = new ModuleDescriptor(root.getDirectory(), StdModuleTypes.JAVA, Collections.<DetectedSourceRoot>emptyList());
        descriptor.addConfigurationUpdater(createModuleConfigurationUpdater());
        modules.add(descriptor);
    }
    myProjectDescriptor.setModules(modules);
}
Also used : ModuleDescriptor(com.intellij.ide.util.importProject.ModuleDescriptor) DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot) ArrayList(java.util.ArrayList)

Example 2 with ModuleDescriptor

use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-community by JetBrains.

the class CreateFromSourcesMode method addSteps.

public void addSteps(WizardContext context, ModulesProvider modulesProvider, StepSequence sequence, String specific) {
    final ProjectFromSourcesBuilderImpl projectBuilder = new ProjectFromSourcesBuilderImpl(context, modulesProvider);
    myProjectBuilder = projectBuilder;
    final Icon icon = context.getStepIcon();
    if (context.isCreatingNewProject()) {
        addStep(sequence, new ProjectNameStep(context, this), specific);
    }
    addStep(sequence, new RootsDetectionStep(projectBuilder, context, sequence, icon, "reference.dialogs.new.project.fromCode.source"), specific);
    Set<String> detectorTypes = new HashSet<>();
    for (ProjectStructureDetector detector : ProjectStructureDetector.EP_NAME.getExtensions()) {
        detectorTypes.add(detector.getDetectorId());
        for (ModuleWizardStep step : detector.createWizardSteps(projectBuilder, projectBuilder.getProjectDescriptor(detector), icon)) {
            sequence.addSpecificStep(detector.getDetectorId(), step);
        }
    }
    if (FrameworkDetectionStep.isEnabled()) {
        FrameworkDetectionStep frameworkDetectionStep = new FrameworkDetectionStep(icon, projectBuilder) {

            public List<ModuleDescriptor> getModuleDescriptors() {
                final List<ModuleDescriptor> moduleDescriptors = new ArrayList<>();
                for (ProjectDescriptor descriptor : projectBuilder.getSelectedDescriptors()) {
                    moduleDescriptors.addAll(descriptor.getModules());
                }
                return moduleDescriptors;
            }
        };
        projectBuilder.addConfigurationUpdater(frameworkDetectionStep);
        sequence.addCommonFinishingStep(frameworkDetectionStep, detectorTypes);
    }
}
Also used : ArrayList(java.util.ArrayList) ProjectFromSourcesBuilderImpl(com.intellij.ide.util.projectWizard.importSources.impl.ProjectFromSourcesBuilderImpl) ModuleDescriptor(com.intellij.ide.util.importProject.ModuleDescriptor) ProjectStructureDetector(com.intellij.ide.util.projectWizard.importSources.ProjectStructureDetector) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ProjectNameStep(com.intellij.ide.util.newProjectWizard.ProjectNameStep) ProjectDescriptor(com.intellij.ide.util.importProject.ProjectDescriptor) FrameworkDetectionStep(com.intellij.ide.util.importProject.FrameworkDetectionStep) RootsDetectionStep(com.intellij.ide.util.importProject.RootsDetectionStep) HashSet(java.util.HashSet)

Example 3 with ModuleDescriptor

use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-community by JetBrains.

the class CloudGitChooseAccountStepImpl method updateDataModel.

@Override
public void updateDataModel() {
    super.updateDataModel();
    final MultiMap<CloudGitProjectRoot, DetectedSourceRoot> project2sourceRoots = new MultiMap<>();
    new RootIterator() {

        CloudGitProjectRoot lastProjectRoot = null;

        @Override
        protected void processProjectRoot(CloudGitProjectRoot root) {
            lastProjectRoot = root;
            project2sourceRoots.put(lastProjectRoot, new ArrayList<>());
        }

        @Override
        protected void processJavaSourceRoot(DetectedSourceRoot root) {
            project2sourceRoots.putValue(lastProjectRoot, root);
        }
    }.iterate();
    List<ModuleDescriptor> modules = new ArrayList<>(myProjectDescriptor.getModules());
    for (Map.Entry<CloudGitProjectRoot, Collection<DetectedSourceRoot>> project2sourceRootsEntry : project2sourceRoots.entrySet()) {
        final CloudGitProjectRoot projectRoot = project2sourceRootsEntry.getKey();
        final File directory = projectRoot.getDirectory();
        ModuleDescriptor moduleDescriptor = new ModuleDescriptor(directory, StdModuleTypes.JAVA, project2sourceRootsEntry.getValue());
        final String applicationName = projectRoot.getApplicationName();
        moduleDescriptor.addConfigurationUpdater(new ModuleBuilder.ModuleConfigurationUpdater() {

            @Override
            public void update(@NotNull final Module module, @NotNull ModifiableRootModel rootModel) {
                final MessageBusConnection connection = module.getProject().getMessageBus().connect();
                connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {

                    @Override
                    public void moduleAdded(@NotNull Project project, @NotNull Module addedModule) {
                        if (addedModule == module) {
                            StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> onModuleAdded(module));
                            connection.disconnect();
                        }
                    }
                });
            }

            private void onModuleAdded(Module module) {
                createRunConfiguration(module, applicationName);
                GitInit.refreshAndConfigureVcsMappings(module.getProject(), projectRoot.getRepositoryRoot(), directory.getAbsolutePath());
            }
        });
        modules.add(moduleDescriptor);
    }
    myProjectDescriptor.setModules(modules);
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ModuleListener(com.intellij.openapi.project.ModuleListener) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull) DetectedSourceRoot(com.intellij.ide.util.projectWizard.importSources.DetectedSourceRoot) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) MultiMap(com.intellij.util.containers.MultiMap) ModuleDescriptor(com.intellij.ide.util.importProject.ModuleDescriptor) Project(com.intellij.openapi.project.Project) Collection(java.util.Collection) Module(com.intellij.openapi.module.Module) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) File(java.io.File)

Example 4 with ModuleDescriptor

use of com.intellij.ide.util.importProject.ModuleDescriptor in project android by JetBrains.

the class AndroidProjectStructureDetector method setupProjectStructure.

@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots, @NotNull ProjectDescriptor projectDescriptor, @NotNull ProjectFromSourcesBuilder builder) {
    final List<File> existingRoots = new ArrayList<File>();
    for (ProjectStructureDetector detector : ProjectStructureDetector.EP_NAME.getExtensions()) {
        if (detector != this) {
            for (DetectedProjectRoot root : builder.getProjectRoots(detector)) {
                existingRoots.add(root.getDirectory());
            }
        }
    }
    final List<ModuleDescriptor> modules = new ArrayList<ModuleDescriptor>();
    for (DetectedProjectRoot root : roots) {
        final File dir = root.getDirectory();
        boolean javaSrcRootInside = false;
        for (File javaSourceRoot : existingRoots) {
            if (FileUtil.isAncestor(dir, javaSourceRoot, false)) {
                javaSrcRootInside = true;
            }
        }
        if (!javaSrcRootInside) {
            modules.add(new ModuleDescriptor(root.getDirectory(), JavaModuleType.getModuleType(), Collections.<DetectedSourceRoot>emptyList()));
        }
    }
    projectDescriptor.setModules(modules);
}
Also used : DetectedSourceRoot(com.intellij.ide.util.projectWizard.importSources.DetectedSourceRoot) DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot) ModuleDescriptor(com.intellij.ide.util.importProject.ModuleDescriptor) ProjectStructureDetector(com.intellij.ide.util.projectWizard.importSources.ProjectStructureDetector) ArrayList(java.util.ArrayList) File(java.io.File)

Example 5 with ModuleDescriptor

use of com.intellij.ide.util.importProject.ModuleDescriptor in project intellij-elixir by KronicDeth.

the class ElixirProjectStructureDetector method setupProjectStructure.

/**
   * This detector just for import non-organization project which not like mix-project
   * So that it's no need to detect directories such as libs, deps, tests etc
   *
   * And mix-project will imported by the MixProjectImportBuilder.java
   * */
@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots, @NotNull ProjectDescriptor projectDescriptor, @NotNull ProjectFromSourcesBuilder builder) {
    if (!roots.isEmpty() && !builder.hasRootsFromOtherDetectors(this)) {
        List<ModuleDescriptor> modules = projectDescriptor.getModules();
        if (modules.isEmpty()) {
            modules = new ArrayList<ModuleDescriptor>();
            for (DetectedProjectRoot root : roots) {
                modules.add(new ModuleDescriptor(root.getDirectory(), ElixirModuleType.getInstance(), ContainerUtil.<DetectedSourceRoot>emptyList()));
            }
            projectDescriptor.setModules(modules);
        }
    }
}
Also used : DetectedSourceRoot(com.intellij.ide.util.projectWizard.importSources.DetectedSourceRoot) ModuleDescriptor(com.intellij.ide.util.importProject.ModuleDescriptor) DetectedProjectRoot(com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot)

Aggregations

ModuleDescriptor (com.intellij.ide.util.importProject.ModuleDescriptor)7 ArrayList (java.util.ArrayList)4 DetectedProjectRoot (com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot)3 DetectedSourceRoot (com.intellij.ide.util.projectWizard.importSources.DetectedSourceRoot)3 File (java.io.File)3 ProjectDescriptor (com.intellij.ide.util.importProject.ProjectDescriptor)2 ProjectStructureDetector (com.intellij.ide.util.projectWizard.importSources.ProjectStructureDetector)2 FrameworkDetectionStep (com.intellij.ide.util.importProject.FrameworkDetectionStep)1 LibraryDescriptor (com.intellij.ide.util.importProject.LibraryDescriptor)1 RootsDetectionStep (com.intellij.ide.util.importProject.RootsDetectionStep)1 ProjectNameStep (com.intellij.ide.util.newProjectWizard.ProjectNameStep)1 ExistingModuleLoader (com.intellij.ide.util.projectWizard.ExistingModuleLoader)1 ModuleBuilder (com.intellij.ide.util.projectWizard.ModuleBuilder)1 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 ProjectFromSourcesBuilderImpl (com.intellij.ide.util.projectWizard.importSources.impl.ProjectFromSourcesBuilderImpl)1 Module (com.intellij.openapi.module.Module)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ModuleListener (com.intellij.openapi.project.ModuleListener)1 Project (com.intellij.openapi.project.Project)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1