mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplify - reuse getStripeFor
GitOrigin-RevId: 45102590c007ba0f9e9a6820f3a176203dc4b9a0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3204233f29
commit
63a75c9562
@@ -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<? super StripeButton> comparator) {
|
||||
void addButton(@NotNull StripeButton button, @NotNull Comparator<StripeButton> comparator) {
|
||||
preferredSize = null;
|
||||
buttons.add(button);
|
||||
buttons.sort(comparator);
|
||||
add(button);
|
||||
revalidate();
|
||||
}
|
||||
|
||||
void removeButton(@NotNull StripeButton button) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<? super StripeButton> 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) {
|
||||
|
||||
Reference in New Issue
Block a user