diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java index c98577d04743..d443aae9de3b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java @@ -1,4 +1,4 @@ -// 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. +// Copyright 2000-2020 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.openapi.wm.impl; import com.intellij.ide.ui.UISettings; @@ -132,12 +132,11 @@ final class Stripe extends JPanel implements UISettingsListener { } } - void addButton(@NotNull StripeButton button, @NotNull Comparator comparator) { + void addButton(@NotNull StripeButton button, @NotNull Comparator comparator) { preferredSize = null; buttons.add(button); buttons.sort(comparator); add(button); - revalidate(); } void removeButton(@NotNull StripeButton button) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.kt index 5bb561a45243..a9335d9eb965 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.kt @@ -966,8 +966,7 @@ open class ToolWindowManagerImpl(val project: Project) : ToolWindowManagerEx(), val button = StripeButton(toolWindowPane!!, toolWindow) - val anchor = (contentFactory as? ToolWindowFactoryEx)?.anchor ?: info.anchor - toolWindowPane.addStripeButton(button, anchor, layout.MyStripeButtonComparator(anchor, this)) + addStripeButton(button, (contentFactory as? ToolWindowFactoryEx)?.anchor ?: info.anchor) val entry = ToolWindowEntry(button, toolWindow, disposable) idToEntry.put(task.id, entry) @@ -1333,7 +1332,13 @@ open class ToolWindowManagerImpl(val project: Project) : ToolWindowManagerEx(), val otherInfo = layout.getInfo(otherId)?.copy() ?: continue otherEntry.applyWindowInfo(otherInfo) } - toolWindowPane.addStripeButton(entry.stripeButton, anchor, layout.MyStripeButtonComparator(currentInfo.anchor, this)) + addStripeButton(entry.stripeButton, anchor, currentAnchor = currentInfo.anchor) + } + + private fun addStripeButton(button: StripeButton, anchor: ToolWindowAnchor, currentAnchor: ToolWindowAnchor = anchor) { + val stripe = toolWindowPane!!.getStripeFor(anchor) + stripe.addButton(button, layout.MyStripeButtonComparator(currentAnchor, this)) + stripe.revalidate() } internal fun setSideTool(id: String, isSplit: Boolean) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java index 775c008876e3..7b63e010d41d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java @@ -33,8 +33,10 @@ import javax.swing.*; import java.awt.*; import java.awt.geom.Point2D; import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; -import java.util.*; +import java.util.Objects; import java.util.function.Function; import static com.intellij.util.ui.UIUtil.useSafely; @@ -364,7 +366,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi return getComponentAt(ToolWindowAnchor.BOTTOM) != null; } - @Nullable + @NotNull Stripe getStripeFor(@NotNull ToolWindowAnchor anchor) { if (ToolWindowAnchor.TOP == anchor) { return topStripe; @@ -827,24 +829,6 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi } } - void addStripeButton(@NotNull StripeButton button, @NotNull ToolWindowAnchor anchor, @NotNull Comparator comparator) { - if (ToolWindowAnchor.TOP == anchor) { - topStripe.addButton(button, comparator); - } - else if (ToolWindowAnchor.LEFT == anchor) { - leftStripe.addButton(button, comparator); - } - else if (ToolWindowAnchor.BOTTOM == anchor) { - bottomStripe.addButton(button, comparator); - } - else if (ToolWindowAnchor.RIGHT == anchor) { - rightStripe.addButton(button, comparator); - } - else { - LOG.error("unknown anchor: " + anchor); - } - } - void removeStripeButton(@NotNull StripeButton button) { Container parent = button.getParent(); if (parent != null) {