diff --git a/src/main/java/jiux/net/plugin/restful/listener/ProjectOpenCloseListener.java b/src/main/java/jiux/net/plugin/restful/listener/ProjectOpenCloseListener.java new file mode 100644 index 0000000..1e9bda9 --- /dev/null +++ b/src/main/java/jiux/net/plugin/restful/listener/ProjectOpenCloseListener.java @@ -0,0 +1,34 @@ +package jiux.net.plugin.restful.listener; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManagerListener; +import jiux.net.plugin.restful.navigator.RestServicesNavigator; +import jiux.net.plugin.utils.ToolkitUtil; +import org.jetbrains.annotations.NotNull; + +public class ProjectOpenCloseListener implements ProjectManagerListener { + + @Override + public void projectOpened(@NotNull Project project) { + if (ApplicationManager.getApplication().isUnitTestMode()) { + return; + } + + RestServicesNavigator restServicesNavigator = RestServicesNavigator.getInstance( + project + ); + + restServicesNavigator.listenForProjectsChanges(); + + ToolkitUtil.runWhenInitialized( + project, + () -> { + if (project.isDisposed()) { + return; + } + restServicesNavigator.initToolWindow(); + } + ); + } +}