mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't call createContentIfNeeded inside content manager initialization
GitOrigin-RevId: 9c66858945296fb82bc0e41bf7cf4bad131887c1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a1d39aed8
commit
9bfbfc9c39
@@ -103,31 +103,10 @@ class ToolWindowImpl internal constructor(val toolWindowManager: ToolWindowManag
|
||||
|
||||
private fun createContentManager(): ContentManagerImpl {
|
||||
val contentUi = ToolWindowContentUi(this, windowInfo.contentUiType)
|
||||
this.contentUi = contentUi
|
||||
val contentManager = ContentManagerImpl(contentUi, canCloseContent, toolWindowManager.project, parentDisposable)
|
||||
|
||||
UIUtil.putClientProperty(contentUi.component, UIUtil.NOT_IN_HIERARCHY_COMPONENTS, object : Iterable<JComponent> {
|
||||
override fun iterator(): Iterator<JComponent> {
|
||||
if (contentManager.contentCount == 0) {
|
||||
return Collections.emptyIterator()
|
||||
}
|
||||
|
||||
return contentManager.contents
|
||||
.asSequence()
|
||||
.mapNotNull { content: Content ->
|
||||
var last: JComponent? = null
|
||||
var parent: Component? = content.component
|
||||
while (parent != null) {
|
||||
if (parent === contentUi.component || parent !is JComponent) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
last = parent
|
||||
parent = parent.getParent()
|
||||
}
|
||||
last
|
||||
}
|
||||
.iterator()
|
||||
}
|
||||
})
|
||||
addContentNotInHierarchyComponents(contentUi)
|
||||
|
||||
val contentComponent = contentManager.component
|
||||
InternalDecorator.installFocusTraversalPolicy(contentComponent, LayoutFocusTraversalPolicy())
|
||||
@@ -154,10 +133,6 @@ class ToolWindowImpl internal constructor(val toolWindowManager: ToolWindowManag
|
||||
|
||||
toolWindowFocusWatcher = ToolWindowManagerImpl.ToolWindowFocusWatcher(this, contentComponent)
|
||||
|
||||
if (windowInfo.isVisible) {
|
||||
createContentIfNeeded()
|
||||
}
|
||||
|
||||
// after init, as it was before contentManager creation was changed to be lazy
|
||||
pendingContentManagerListeners?.let { list ->
|
||||
pendingContentManagerListeners = null
|
||||
@@ -460,7 +435,6 @@ class ToolWindowImpl internal constructor(val toolWindowManager: ToolWindowManag
|
||||
contentManager.value
|
||||
}
|
||||
|
||||
// if content manager due to some incorrect call was already initialized, content will be not created
|
||||
internal fun scheduleContentInitializationIfNeeded() {
|
||||
if (contentFactory != null) {
|
||||
// todo use lazy loading (e.g. JBLoadingPanel)
|
||||
@@ -655,4 +629,31 @@ private fun addSorted(main: DefaultActionGroup, group: ActionGroup) {
|
||||
if (children.isNotEmpty() && !separatorText.isNullOrEmpty()) {
|
||||
main.addAction(Separator(separatorText), Constraints.FIRST)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addContentNotInHierarchyComponents(contentUi: ToolWindowContentUi) {
|
||||
UIUtil.putClientProperty(contentUi.component, UIUtil.NOT_IN_HIERARCHY_COMPONENTS, object : Iterable<JComponent> {
|
||||
override fun iterator(): Iterator<JComponent> {
|
||||
val contentManager = contentUi.contentManager ?: return Collections.emptyIterator()
|
||||
if (contentManager.contentCount == 0) {
|
||||
return Collections.emptyIterator()
|
||||
}
|
||||
|
||||
return contentManager.contents
|
||||
.asSequence()
|
||||
.mapNotNull { content: Content ->
|
||||
var last: JComponent? = null
|
||||
var parent: Component? = content.component
|
||||
while (parent != null) {
|
||||
if (parent === contentUi.component || parent !is JComponent) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
last = parent
|
||||
parent = parent.getParent()
|
||||
}
|
||||
last
|
||||
}
|
||||
.iterator()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.vcs.log.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -76,7 +76,9 @@ public class VcsLogContentUtil {
|
||||
@NotNull Class<U> clazz, boolean select,
|
||||
@NotNull Condition<? super U> condition) {
|
||||
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
|
||||
if (toolWindow == null) return null;
|
||||
if (toolWindow == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ContentManager manager = toolWindow.getContentManager();
|
||||
JComponent component = ContentUtilEx.findContentComponent(manager, c -> {
|
||||
@@ -87,11 +89,17 @@ public class VcsLogContentUtil {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (component == null) return null;
|
||||
if (component == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (select) {
|
||||
if (!toolWindow.isVisible()) toolWindow.activate(null);
|
||||
if (!ContentUtilEx.selectContent(manager, component, true)) return null;
|
||||
if (!toolWindow.isVisible()) {
|
||||
toolWindow.activate(null);
|
||||
}
|
||||
if (!ContentUtilEx.selectContent(manager, component, true)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (U)getLogUi(component);
|
||||
@@ -135,7 +143,9 @@ public class VcsLogContentUtil {
|
||||
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
|
||||
ContentUtilEx.addTabbedContent(toolWindow.getContentManager(),
|
||||
new VcsLogPanel(logManager, logUi), tabGroupName, shortName, focus, logUi);
|
||||
if (focus) toolWindow.activate(null);
|
||||
if (focus) {
|
||||
toolWindow.activate(null);
|
||||
}
|
||||
logManager.scheduleInitialization();
|
||||
return logUi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user