ActionCallback (@NotNull Project project, final Object toSelect, @Nullable final String viewId, @Nullable final String subviewId, final VirtualFile virtualFile, final boolean requestFocus) { if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug( "ProjectViewSelectInTarget.select: " + "project=" + project + ", toSelect=" + toSelect + ", viewId=" + viewId + ", subviewId=" + subviewId + ", virtualFile=" + virtualFile + ", requestFocus=" + requestFocus ); } ProjectView projectView = ProjectView.getInstance(project); if (projectView == null) { SelectInProjectViewImplKt.getLOG().debug("Not selecting anything because there is no project view"); return ActionCallback.REJECTED; } String id = ObjectUtils.chooseNotNull(viewId, projectView.getDefaultViewId()); if (ApplicationManager.getApplication().isUnitTestMode()) { AbstractProjectViewPane pane = projectView.getProjectViewPaneById(id); if (pane != null) { if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug("Switching to pane " + pane); } pane.select(toSelect, virtualFile, requestFocus); } return ActionCallback.DONE; } Supplier<Object> toSelectSupplier = toSelect instanceof PsiElement ? createPointer((PsiElement)toSelect)::getElement : () -> toSelect; ToolWindow projectViewToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW); if (projectViewToolWindow == null) { SelectInProjectViewImplKt.getLOG().debug("Not selecting anything because there is no project view tool window"); return ActionCallback.REJECTED; } ActionCallback result = new ActionCallback(); Runnable runnable = () -> { if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug( (requestFocus ? "Activated" : "Shown") + ". Changing project view to " + id + " / " + subviewId + ", will continue once changed" ); } projectView.changeViewCB(id, subviewId).doWhenProcessed(() -> { SelectInProjectViewImplKt.getLOG().debug("Changed. Delegating to SelectInProjectViewImpl to continue"); project.getService(SelectInProjectViewImpl.class).ensureSelected(id, virtualFile, toSelectSupplier, requestFocus, true, result); }); }; if (requestFocus) { SelectInProjectViewImplKt.getLOG().debug("Activating the project view tool window, will continue once activated"); projectViewToolWindow.activate(runnable, true); } else { SelectInProjectViewImplKt.getLOG().debug("Showing the project view tool window, will continue once shown"); projectViewToolWindow.show(runnable); } return result; }