Search in sources :

Example 21 with ModuleWizardStep

use of com.intellij.ide.util.projectWizard.ModuleWizardStep in project intellij-community by JetBrains.

the class GradleProjectOpenProcessor method setupGradleProjectSettingsInHeadlessMode.

private boolean setupGradleProjectSettingsInHeadlessMode(GradleProjectImportProvider projectImportProvider, WizardContext wizardContext) {
    final ModuleWizardStep[] wizardSteps = projectImportProvider.createSteps(wizardContext);
    if (wizardSteps.length > 0 && wizardSteps[0] instanceof SelectExternalProjectStep) {
        SelectExternalProjectStep selectExternalProjectStep = (SelectExternalProjectStep) wizardSteps[0];
        wizardContext.setProjectBuilder(getBuilder());
        try {
            selectExternalProjectStep.updateStep();
            final ImportFromGradleControl importFromGradleControl = getBuilder().getControl(wizardContext.getProject());
            GradleProjectSettingsControl gradleProjectSettingsControl = (GradleProjectSettingsControl) importFromGradleControl.getProjectSettingsControl();
            final GradleProjectSettings projectSettings = gradleProjectSettingsControl.getInitialSettings();
            if (GRADLE_DISTRIBUTION_TYPE != null) {
                for (DistributionType type : DistributionType.values()) {
                    if (type.name().equals(GRADLE_DISTRIBUTION_TYPE)) {
                        projectSettings.setDistributionType(type);
                        break;
                    }
                }
            }
            if (GRADLE_HOME != null) {
                projectSettings.setGradleHome(GRADLE_HOME);
            }
            gradleProjectSettingsControl.reset();
            final GradleSystemSettingsControl systemSettingsControl = (GradleSystemSettingsControl) importFromGradleControl.getSystemSettingsControl();
            assert systemSettingsControl != null;
            final GradleSettings gradleSettings = systemSettingsControl.getInitialSettings();
            if (GRADLE_VM_OPTIONS != null) {
                gradleSettings.setGradleVmOptions(GRADLE_VM_OPTIONS);
            }
            if (GRADLE_OFFLINE != null) {
                gradleSettings.setOfflineWork(Boolean.parseBoolean(GRADLE_OFFLINE));
            }
            String serviceDirectory = GRADLE_SERVICE_DIRECTORY;
            if (GRADLE_SERVICE_DIRECTORY != null) {
                gradleSettings.setServiceDirectoryPath(serviceDirectory);
            }
            systemSettingsControl.reset();
            if (!selectExternalProjectStep.validate()) {
                return false;
            }
        } catch (ConfigurationException e) {
            Messages.showErrorDialog(wizardContext.getProject(), e.getMessage(), e.getTitle());
            return false;
        }
        selectExternalProjectStep.updateDataModel();
    }
    return true;
}
Also used : GradleProjectSettingsControl(org.jetbrains.plugins.gradle.service.settings.GradleProjectSettingsControl) GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) GradleSystemSettingsControl(org.jetbrains.plugins.gradle.service.settings.GradleSystemSettingsControl) ImportFromGradleControl(org.jetbrains.plugins.gradle.service.settings.ImportFromGradleControl) SelectExternalProjectStep(com.intellij.openapi.externalSystem.service.project.wizard.SelectExternalProjectStep) DistributionType(org.jetbrains.plugins.gradle.settings.DistributionType)

Example 22 with ModuleWizardStep

use of com.intellij.ide.util.projectWizard.ModuleWizardStep in project intellij-community by JetBrains.

the class GradleProjectWizardTest method testGradleProject.

public void testGradleProject() throws Exception {
    final String projectName = "testProject";
    Project project = createProject(new Consumer<Step>() {

        @Override
        public void consume(Step step) {
            if (step instanceof ProjectTypeStep) {
                assertTrue(((ProjectTypeStep) step).setSelectedTemplate("Gradle", null));
                List<ModuleWizardStep> steps = myWizard.getSequence().getSelectedSteps();
                assertEquals(5, steps.size());
                final ProjectBuilder projectBuilder = myWizard.getProjectBuilder();
                assertInstanceOf(projectBuilder, GradleModuleBuilder.class);
                ((GradleModuleBuilder) projectBuilder).setName(projectName);
            }
        }
    });
    assertEquals(projectName, project.getName());
    Module[] modules = ModuleManager.getInstance(project).getModules();
    assertEquals(1, modules.length);
    final Module module = modules[0];
    assertTrue(ModuleRootManager.getInstance(module).isSdkInherited());
    assertEquals(projectName, module.getName());
    VirtualFile root = ProjectRootManager.getInstance(project).getContentRoots()[0];
    VirtualFile settingsScript = VfsUtilCore.findRelativeFile("settings.gradle", root);
    assertNotNull(settingsScript);
    assertEquals(String.format("rootProject.name = '%s'\n\n", projectName), StringUtil.convertLineSeparators(VfsUtilCore.loadText(settingsScript)));
    VirtualFile buildScript = VfsUtilCore.findRelativeFile("build.gradle", root);
    assertNotNull(buildScript);
    assertEquals("group '" + projectName + "'\n" + "version '1.0-SNAPSHOT'\n" + "\n" + "apply plugin: 'java'\n" + "\n" + "sourceCompatibility = 1.8\n" + "\n" + "repositories {\n" + "    mavenCentral()\n" + "}\n" + "\n" + "dependencies {\n" + "    testCompile group: 'junit', name: 'junit', version: '4.12'\n" + "}\n", StringUtil.convertLineSeparators(VfsUtilCore.loadText(buildScript)));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) GradleModuleBuilder(org.jetbrains.plugins.gradle.service.project.wizard.GradleModuleBuilder) ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) List(java.util.List) ProjectTypeStep(com.intellij.ide.projectWizard.ProjectTypeStep) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) Step(com.intellij.ide.wizard.Step) Module(com.intellij.openapi.module.Module) ProjectTypeStep(com.intellij.ide.projectWizard.ProjectTypeStep)

Example 23 with ModuleWizardStep

use of com.intellij.ide.util.projectWizard.ModuleWizardStep in project intellij-community by JetBrains.

the class EduCCModuleBuilder method modifySettingsStep.

@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
    ModuleWizardStep javaSettingsStep = ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.alwaysTrue());
    Function<JTextField, String> getValue = JTextComponent::getText;
    getWizardInputField("ccname", "", "Name:", myPanel.getNameField(), getValue).addToSettings(settingsStep);
    getWizardInputField("ccauthor", "", "Author:", myPanel.getAuthorField(), getValue).addToSettings(settingsStep);
    LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(EduCourseConfigurator.EP_NAME).getExtensions();
    myLanguageComboBox.removeAllItems();
    for (LanguageExtensionPoint extension : extensions) {
        String languageId = extension.getKey();
        Language language = Language.findLanguageByID(languageId);
        if (language == null) {
            LOG.info("Language with id " + languageId + " not found");
        }
        myLanguageComboBox.addItem(new LanguageWrapper(language));
    }
    getWizardInputField("cclang", "", "Language:", myLanguageComboBox, comboBox -> (String) comboBox.getSelectedItem()).addToSettings(settingsStep);
    getWizardInputField("ccdescr", "", "Description:", myPanel.getDescriptionField(), JTextArea::getText).addToSettings(settingsStep);
    return javaSettingsStep;
}
Also used : Language(com.intellij.lang.Language) ModuleWithNameAlreadyExists(com.intellij.openapi.module.ModuleWithNameAlreadyExists) InvalidDataException(com.intellij.openapi.util.InvalidDataException) Function(java.util.function.Function) WizardInputField(com.intellij.ide.util.projectWizard.WizardInputField) JDOMException(org.jdom.JDOMException) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) CCNewProjectPanel(com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel) StudyProjectGenerator(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator) EduCourseModuleBuilder(com.jetbrains.edu.learning.intellij.generation.EduCourseModuleBuilder) Project(com.intellij.openapi.project.Project) Conditions(com.intellij.openapi.util.Conditions) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ComboBox(com.intellij.openapi.ui.ComboBox) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson) IOException(java.io.IOException) StudyTaskManager(com.jetbrains.edu.learning.StudyTaskManager) ProjectWizardStepFactory(com.intellij.ide.util.projectWizard.ProjectWizardStepFactory) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) Task(com.jetbrains.edu.learning.courseFormat.Task) JTextComponent(javax.swing.text.JTextComponent) File(java.io.File) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) ExtensionPointName(com.intellij.openapi.extensions.ExtensionPointName) Nullable(org.jetbrains.annotations.Nullable) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) CCUtils(com.jetbrains.edu.coursecreator.CCUtils) Course(com.jetbrains.edu.learning.courseFormat.Course) javax.swing(javax.swing) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) Language(com.intellij.lang.Language) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with ModuleWizardStep

use of com.intellij.ide.util.projectWizard.ModuleWizardStep in project android by JetBrains.

the class SourceToGradleModuleStep method createDependentSteps.

@NotNull
@Override
protected Collection<? extends ModelWizardStep> createDependentSteps() {
    WizardContext context = getModel().getContext();
    ArrayList<ModelWizardStep> wrappedSteps = new ArrayList<>();
    for (ModuleImporter importer : ModuleImporter.getAllImporters(context)) {
        for (ModuleWizardStep inputStep : importer.createWizardSteps()) {
            wrappedSteps.add(new ModuleWizardStepAdapter(context, inputStep));
        }
    }
    return wrappedSteps;
}
Also used : ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModuleImporter(com.android.tools.idea.gradle.project.ModuleImporter) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) ArrayList(java.util.ArrayList) ModelWizardStep(com.android.tools.idea.wizard.model.ModelWizardStep) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with ModuleWizardStep

use of com.intellij.ide.util.projectWizard.ModuleWizardStep in project android by JetBrains.

the class LegacyPathWrapper method navigateToNamedStep.

@Override
public void navigateToNamedStep(@NotNull String stepName, boolean requireVisible) {
    for (ModuleWizardStep step : mySteps) {
        if (stepName.equals(step.getName())) {
            myCurrentStep = mySteps.indexOf(step);
            updateWizard();
            return;
        }
    }
}
Also used : ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep)

Aggregations

ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)27 Project (com.intellij.openapi.project.Project)5 ArrayList (java.util.ArrayList)5 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 DelegatingProgressIndicator (com.intellij.ide.util.DelegatingProgressIndicator)2 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)2 ProjectWizardStepFactory (com.intellij.ide.util.projectWizard.ProjectWizardStepFactory)2 SettingsStep (com.intellij.ide.util.projectWizard.SettingsStep)2 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)2 ProjectStructureDetector (com.intellij.ide.util.projectWizard.importSources.ProjectStructureDetector)2 Step (com.intellij.ide.wizard.Step)2 Module (com.intellij.openapi.module.Module)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 ModuleImporter (com.android.tools.idea.gradle.project.ModuleImporter)1 WrapArchiveWizardPath (com.android.tools.idea.npw.deprecated.WrapArchiveWizardPath)1 Template (com.android.tools.idea.templates.Template)1 TemplateManager (com.android.tools.idea.templates.TemplateManager)1 ModelWizardStep (com.android.tools.idea.wizard.model.ModelWizardStep)1