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