@Override
  protected void doOpenProject(
      @NotNull String projectPath, Project projectToClose, boolean forceOpenInNewFrame) {
    if (new File(projectPath).isDirectory()
        && !new File(projectPath, Project.DIRECTORY_STORE_FOLDER).exists()) {
      VirtualFile projectDir =
          LocalFileSystem.getInstance()
              .findFileByPath(FileUtil.toSystemIndependentName(projectPath));
      PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstanceIfItExists();
      if (projectDir != null && processor != null) {
        processor.doOpenProject(projectDir, projectToClose, forceOpenInNewFrame);
        return;
      }
    }

    ProjectUtil.openProject(projectPath, projectToClose, forceOpenInNewFrame);
  }
  @Nullable
  private Project generateProject(
      @NotNull final Project project, @NotNull final AbstractProjectSettingsStep settings) {
    final DirectoryProjectGenerator generator = settings.getProjectGenerator();
    final File location = new File(settings.getProjectLocation());
    if (!location.exists() && !location.mkdirs()) {
      Messages.showErrorDialog(
          project, "Cannot create directory '" + location + "'", "Create Project");
      return null;
    }

    final VirtualFile baseDir =
        ApplicationManager.getApplication()
            .runWriteAction(
                new Computable<VirtualFile>() {
                  public VirtualFile compute() {
                    return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(location);
                  }
                });
    LOG.assertTrue(baseDir != null, "Couldn't find '" + location + "' in VFS");
    baseDir.refresh(false, true);

    if (baseDir.getChildren().length > 0) {
      int rc =
          Messages.showYesNoDialog(
              project,
              "The directory '"
                  + location
                  + "' is not empty. Would you like to create a project from existing sources instead?",
              "Create New Project",
              Messages.getQuestionIcon());
      if (rc == Messages.YES) {
        return PlatformProjectOpenProcessor.getInstance().doOpenProject(baseDir, null, false);
      }
    }

    String generatorName =
        generator == null ? "empty" : ConvertUsagesUtil.ensureProperKey(generator.getName());
    UsageTrigger.trigger("NewDirectoryProjectAction." + generatorName);

    GeneralSettings.getInstance().setLastProjectCreationLocation(location.getParent());

    return PlatformProjectOpenProcessor.doOpenProject(
        baseDir,
        null,
        false,
        -1,
        new ProjectOpenedCallback() {
          @Override
          public void projectOpened(Project project, Module module) {
            if (generator != null) {
              Object projectSettings = null;
              if (generator instanceof PythonProjectGenerator) {
                projectSettings = ((PythonProjectGenerator) generator).getProjectSettings();
              } else if (generator instanceof WebProjectTemplate) {
                projectSettings = ((WebProjectTemplate) generator).getPeer().getSettings();
              }
              if (projectSettings instanceof PyNewProjectSettings) {
                ((PyNewProjectSettings) projectSettings).setSdk(settings.getSdk());
                ((PyNewProjectSettings) projectSettings)
                    .setInstallFramework(settings.installFramework());
              }
              //noinspection unchecked
              generator.generateProject(project, baseDir, projectSettings, module);
            }
          }
        },
        false);
  }