@Nullable
  ProjectBuilder runModuleWizard(Component dialogParent, boolean anImport) {
    AbstractProjectWizard wizard;
    if (anImport) {
      wizard = ImportModuleAction.selectFileAndCreateWizard(myProject, dialogParent);
      if (wizard == null) return null;
      if (wizard.getStepCount() == 0) {
        ProjectBuilder builder = wizard.getProjectBuilder();
        Disposer.dispose(wizard.getDisposable());
        return builder;
      }
    } else {
      wizard = new NewProjectWizard(myProject, dialogParent, this);
    }
    if (wizard.showAndGet()) {
      final ProjectBuilder builder = wizard.getProjectBuilder();
      if (builder instanceof ModuleBuilder) {
        final ModuleBuilder moduleBuilder = (ModuleBuilder) builder;
        if (moduleBuilder.getName() == null) {
          moduleBuilder.setName(wizard.getProjectName());
        }
        if (moduleBuilder.getModuleFilePath() == null) {
          moduleBuilder.setModuleFilePath(wizard.getModuleFilePath());
        }
      }
      if (!builder.validate(myProject, myProject)) {
        return null;
      }
      return wizard.getProjectBuilder();
    }

    return null;
  }
Esempio n. 2
0
  public static List<Module> createFromWizard(Project project, AbstractProjectWizard wizard) {
    if (project == null && wizard.getStepCount() > 0) {
      Project newProject = NewProjectUtil.createFromWizard(wizard, null);
      return newProject == null
          ? Collections.<Module>emptyList()
          : Arrays.asList(ModuleManager.getInstance(newProject).getModules());
    }

    final ProjectBuilder projectBuilder = wizard.getProjectBuilder();
    try {
      if (wizard.getStepCount() > 0) {
        Module module = new NewModuleAction().createModuleFromWizard(project, null, wizard);
        return Collections.singletonList(module);
      } else {
        return projectBuilder.commit(project);
      }
    } finally {
      if (projectBuilder != null) {
        projectBuilder.cleanup();
      }
    }
  }
 @Nullable
 @Override
 public Sdk getNewProjectSdk(WizardContext wizardContext) {
   return AbstractProjectWizard.getNewProjectJdk(wizardContext);
 }