From 29f261213c5a4585580e26eae89faec90a995705 Mon Sep 17 00:00:00 2001 From: Sergey Savenko Date: Mon, 19 Jan 2015 21:58:59 +0300 Subject: [PATCH] fix ContentManagerUtil#getContentManagerFromContext Return a content manager from context if a visible toolwindow is not required --- .../intellij/ui/content/ContentManagerUtil.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/content/ContentManagerUtil.java b/platform/platform-impl/src/com/intellij/ui/content/ContentManagerUtil.java index b1a1a2f8a2eb..9129f3c3bb73 100644 --- a/platform/platform-impl/src/com/intellij/ui/content/ContentManagerUtil.java +++ b/platform/platform-impl/src/com/intellij/ui/content/ContentManagerUtil.java @@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.ex.ToolWindowEx; import com.intellij.openapi.wm.ex.ToolWindowManagerEx; +import com.intellij.util.ObjectUtils; public class ContentManagerUtil { private ContentManagerUtil() { @@ -43,18 +44,14 @@ public class ContentManagerUtil { id = mgr.getLastActiveToolWindowId(); } } - if(id == null){ + + ToolWindowEx toolWindow = id != null ? (ToolWindowEx)mgr.getToolWindow(id) : null; + if (requiresVisibleToolWindow && (toolWindow == null || !toolWindow.isVisible())) { return null; } - ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id); - if (requiresVisibleToolWindow && !toolWindow.isVisible()) { - return null; - } - - final ContentManager fromContext = PlatformDataKeys.CONTENT_MANAGER.getData(dataContext); - if (fromContext != null) return fromContext; - - return toolWindow != null ? toolWindow.getContentManager() : null; + ContentManager fromToolWindow = toolWindow != null ? toolWindow.getContentManager() : null; + ContentManager fromContext = PlatformDataKeys.CONTENT_MANAGER.getData(dataContext); + return ObjectUtils.chooseNotNull(fromContext, fromToolWindow); } }