From de848df1a6261f075cbfbaa8d3e11411e530d736 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Wed, 10 Sep 2014 23:32:11 +0400 Subject: [PATCH] QuickDoc: getActiveDocComponent() utility extracted --- .../documentation/QuickDocUtil.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java index 4fad06ede87e..18b28e3409f3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java @@ -51,24 +51,30 @@ public class QuickDocUtil { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { - DocumentationManager documentationManager = DocumentationManager.getInstance(project); - DocumentationComponent component; - JBPopup hint = documentationManager.getDocInfoHint(); - if (hint != null) { - component = (DocumentationComponent)((AbstractPopup)hint).getComponent(); - } - else if (documentationManager.hasActiveDockedDocWindow()) { - ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION); - Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent(); - component = selectedContent == null ? null : (DocumentationComponent)selectedContent.getComponent(); - } - else { - component = null; - } + DocumentationComponent component = getActiveDocComponent(project); if (component != null) { component.replaceText(documentation, element); } } }); } + + @Nullable + public static DocumentationComponent getActiveDocComponent(@NotNull Project project) { + DocumentationManager documentationManager = DocumentationManager.getInstance(project); + DocumentationComponent component; + JBPopup hint = documentationManager.getDocInfoHint(); + if (hint != null) { + component = (DocumentationComponent)((AbstractPopup)hint).getComponent(); + } + else if (documentationManager.hasActiveDockedDocWindow()) { + ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION); + Content selectedContent = toolWindow == null ? null : toolWindow.getContentManager().getSelectedContent(); + component = selectedContent == null ? null : (DocumentationComponent)selectedContent.getComponent(); + } + else { + component = null; + } + return component; + } }