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

hi:

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

ProjectManagerEx.getInstanceEx().openProject(project);


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)

                            toolwindow.activate(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.

2 comments

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

0

Thanks, it works. I use  in follow way.

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

0

Please sign in to leave a comment.