[Plugin Dev]How to open a project in current window.


StartupManager.getInstance(project).registerPostStartupActivity(createToolWindowRunnable(project, moduleBuilder));


private Runnable createToolWindowRunnable(final Project project, final JavaModuleBuilder moduleBuilder) {

        return new Runnable() {

            public void run() {

                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {

                        ToolWindow toolwindow =  ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW);

                        if (toolwindow != null)


                        if (moduleBuilder == null)

                            ModulesConfigurator.showDialog(project, null, null);






We create a intellij plugin to create and open a project programatically.

We wrote the above codes to open the newly created project. However the project got openned in a separate new Intellij window frame.

What we expected is to open the project in the same existing intellji idea window frame.

Could some one give us a clue how to achieve that? Thanks.


You need to call ProjectUtil.closeAndDispose() for the project that you want to close befrore calling openProject().


Thanks, it works. I use  in follow way.

Project currProject = (Project) DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT);


Please sign in to leave a comment.