How to call the File -> Open project action? (Without showing the file chooser dialog)

Answered

We have our own “Open Project” button that will pre-run certain commands to bootstrap the project. However, some projects don't need any special logic, so we were wondering how we could programmatically invoke the “File → Open” action. In this case, we already have the path we want to open, so we don't need to show the file chooser. Is there an API we can use to do something like

```
if (noSpecialStepsNeeded()) {

  openProject(projectPath);

} else {

  // Open the project using a Wizard that pre-runs setup steps

  importWizard.showAndGet();

  NewProjectUtil.createFromWizard(importWizard, project);

}
```

0
3 comments

Can't you use com.intellij.projectImport.ProjectOpenProcessor instead?

0

Should I use it as
ProjectOpenProcessor.getImportProvider(file).doOpenProject(file, project, false)?

0

I meant implementing your own variant of it for your kind of projects.

0

Please sign in to leave a comment.