Promise<Void> (@NotNull Object service, @NotNull Class<?> contributorClass, boolean activate, boolean focus) { AsyncPromise<Void> result = new AsyncPromise<>(); // Ensure model is updated, then iterate over service views on EDT in order to find view with service and select it. myModel.getInvoker().invoke(() -> AppUIUtil.invokeLaterIfProjectAlive(myProject, () -> { String toolWindowId = getToolWindowId(contributorClass); if (toolWindowId == null) { result.setError("Contributor group not found"); return; } Runnable runnable = () -> promiseFindView(contributorClass, result, serviceView -> serviceView.select(service, contributorClass), content -> selectContent(content, focus, myProject)); ToolWindow toolWindow = activate ? ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId) : null; if (toolWindow != null) { toolWindow.activate(runnable, focus, focus); } else { runnable.run(); } })); return result; }