diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-18 11:43:07 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-09-18 11:43:28 -0700 |
commit | e782c57d74000722f9db4c9426317410520670c6 (patch) | |
tree | 6e5d3e8934107ffabb7661f8bfc0e1a08eb37faf /platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java | |
parent | c3d3a90f6b4ead083d63e28e6b9fcea93d675678 (diff) | |
download | idea-e782c57d74000722f9db4c9426317410520670c6.tar.gz |
Snapshot idea/138.2210 from git://git.jetbrains.org/idea/community.git
Change-Id: I8f0204d7887ee78cf1fd8c09f936c5afff0edd2f
Diffstat (limited to 'platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java')
-rw-r--r-- | platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java | 64 |
1 files changed, 36 insertions, 28 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 064bd020183b..18b28e3409f3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocUtil.java @@ -26,9 +26,9 @@ import com.intellij.psi.PsiElement; import com.intellij.ui.content.Content; import com.intellij.ui.popup.AbstractPopup; import com.intellij.util.Producer; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; - -import javax.swing.*; +import org.jetbrains.annotations.Nullable; /** * @author gregsh @@ -40,33 +40,41 @@ public class QuickDocUtil { ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { - final String documentation = docProducer.produce(); - if (StringUtil.isEmpty(documentation)) return; - // modal dialogs with fragment editors fix: can't guess proper modality state here - //noinspection SSBasedInspection - SwingUtilities.invokeLater(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; - } - if (component != null) { - component.replaceText(documentation, element); - } - } - }); + updateQuickDoc(project, element, docProducer.produce()); } }); } + + public static void updateQuickDoc(@NotNull final Project project, @NotNull final PsiElement element, @Nullable final String documentation) { + if (StringUtil.isEmpty(documentation)) return; + // modal dialogs with fragment editors fix: can't guess proper modality state here + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + 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; + } } |