Skip to content

Commit 104dc3e

Browse files
committed
revalidate envs panel
Signed-off-by: shalom <[email protected]>
1 parent 467a1dd commit 104dc3e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/kotlin/org/digma/intellij/plugin/ui/common/EnvironmentsPanel.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import java.awt.GridLayout
1717
import java.util.*
1818
import java.util.function.Function
1919
import javax.swing.JPanel
20+
import kotlin.math.abs
21+
import kotlin.math.max
2022
import kotlin.math.min
2123

2224
fun environmentsPanel(project: Project, environmentsSupplier: EnvironmentsSupplier): JPanel {
@@ -64,9 +66,17 @@ class EnvironmentsPanel(project: Project, private val environmentsSupplier: Envi
6466
override fun getPreferredSize(): Dimension {
6567
if (startup < 5) {
6668
startup++
67-
val d = super.getPreferredSize()
68-
if (d != null) {
69-
return Dimension(d.width, min(d.height, 300))
69+
val myPs = super.getPreferredSize()
70+
if (myPs != null && myPs.width > 0 && myPs.height > 0) {
71+
var aggregatedWidth = 0
72+
var height = 30
73+
components.forEach {
74+
aggregatedWidth += abs(it.preferredSize.width)
75+
height = max(height, abs(it.preferredSize.height))
76+
}
77+
val lines = (aggregatedWidth / (abs(myPs.width) + 1)) + 1
78+
val preferredHeight = (lines * height) + (lines * 3)
79+
return Dimension(myPs.width, min(min(myPs.height, preferredHeight), 300))
7080
}
7181
}
7282
return super.getPreferredSize()

0 commit comments

Comments
 (0)