Skip to content

Commit 59160df

Browse files
Fix Span Bottleneck layout issue
1 parent 2ea7e82 commit 59160df

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

src/main/kotlin/org/digma/intellij/plugin/ui/list/insights/SlowestSpansPanel.kt

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,56 @@ package org.digma.intellij.plugin.ui.list.insights
33
import com.intellij.openapi.project.Project
44
import com.intellij.ui.components.ActionLink
55
import com.intellij.ui.components.JBLabel
6-
import com.intellij.util.ui.JBUI
6+
import com.intellij.util.ui.JBUI.Borders.empty
7+
import org.apache.commons.lang3.StringUtils
78
import org.digma.intellij.plugin.document.CodeObjectsUtil
89
import org.digma.intellij.plugin.model.rest.insights.*
9-
import org.digma.intellij.plugin.ui.common.Laf
10-
import org.digma.intellij.plugin.ui.common.asHtml
11-
import org.digma.intellij.plugin.ui.common.buildBoldTitleGrayedComment
12-
import org.digma.intellij.plugin.ui.common.buildLinkTextWithTitleAndGrayedComment
10+
import org.digma.intellij.plugin.ui.common.*
1311
import org.digma.intellij.plugin.ui.list.openWorkspaceFileForSpan
12+
import java.awt.BorderLayout
1413
import java.awt.GridLayout
1514
import java.math.BigDecimal
1615
import java.math.RoundingMode
1716
import javax.swing.JPanel
17+
import javax.swing.SwingConstants
1818

1919
fun slowestSpansPanel(project: Project, insight: SlowestSpansInsight, moreData: HashMap<String, Any>): JPanel {
2020

21-
val spansListPanel = JPanel()
22-
spansListPanel.layout = GridLayout(insight.spans.size, 1, 0, 3)
23-
spansListPanel.border = JBUI.Borders.empty()
24-
spansListPanel.isOpaque = false
21+
val spansListPanel = createDefaultBoxLayoutYAxisPanel()
22+
2523
insight.spans.forEach { slowSpan: SlowSpanInfo ->
2624

2725
val displayName = slowSpan.spanInfo.displayName
2826
val description = descriptionOf(slowSpan)
2927
val spanId = CodeObjectsUtil.createSpanId(slowSpan.spanInfo.instrumentationLibrary, slowSpan.spanInfo.name)
3028

3129
if (moreData.contains(spanId)) {
32-
val spanText = buildLinkTextWithTitleAndGrayedComment(displayName,description)
33-
val link = ActionLink(spanText) {
30+
val normalizedDisplayName = StringUtils.normalizeSpace(displayName)
31+
val grayedDescription = asHtml(spanGrayed(description))
32+
val descriptionLabel = JBLabel(grayedDescription, SwingConstants.LEFT)
33+
val link = ActionLink(normalizedDisplayName) {
3434
openWorkspaceFileForSpan(project, moreData, spanId)
3535
}
3636
link.toolTipText = genToolTip(slowSpan)
37-
spansListPanel.add(link)
37+
38+
val spanOneRecordPanel = getDefaultSpanOneRecordPanel()
39+
spanOneRecordPanel.add(link, BorderLayout.NORTH)
40+
spanOneRecordPanel.add(descriptionLabel, BorderLayout.SOUTH)
41+
spansListPanel.add(spanOneRecordPanel)
3842
} else {
39-
val spanText = buildBoldTitleGrayedComment(displayName,description)
40-
val label = JBLabel(spanText)
41-
label.toolTipText = genToolTip(slowSpan)
42-
spansListPanel.add(label)
43+
val normalizedDisplayName = StringUtils.normalizeSpace(displayName)
44+
val grayedDescription = asHtml(spanGrayed(description))
45+
val descriptionLabel = JBLabel(grayedDescription, SwingConstants.LEFT)
46+
47+
val displayNameLabel = JBLabel(normalizedDisplayName, SwingConstants.TRAILING)
48+
displayNameLabel.toolTipText = genToolTip(slowSpan)
49+
displayNameLabel.horizontalAlignment = SwingConstants.LEFT
50+
51+
val spanOneRecordPanel = getDefaultSpanOneRecordPanel()
52+
spanOneRecordPanel.add(displayNameLabel, BorderLayout.NORTH)
53+
spanOneRecordPanel.add(descriptionLabel, BorderLayout.SOUTH)
54+
55+
spansListPanel.add(spanOneRecordPanel)
4356
}
4457
}
4558

@@ -58,12 +71,12 @@ fun slowestSpansPanel(project: Project, insight: SlowestSpansInsight, moreData:
5871
fun spanSlowEndpointsPanel(project: Project, insight: SpanSlowEndpointsInsight): JPanel {
5972
val endpointsListPanel = JPanel()
6073
endpointsListPanel.layout = GridLayout(insight.slowEndpoints.size, 1, 0, 3)
61-
endpointsListPanel.border = JBUI.Borders.empty()
74+
endpointsListPanel.border = empty()
6275
endpointsListPanel.isOpaque = false
6376

6477
insight.slowEndpoints.forEach {slowEndpointInfo ->
6578
val currContainerPanel = JPanel(GridLayout(2, 1, 0, 3))
66-
endpointsListPanel.border = JBUI.Borders.empty()
79+
endpointsListPanel.border = empty()
6780
currContainerPanel.isOpaque = false
6881

6982
val routeInfo = EndpointSchema.getRouteInfo(slowEndpointInfo.endpointInfo.route)
@@ -134,6 +147,13 @@ private fun percentageForDisplaySlowSpanInfo(percentile: Percentile): String {
134147
return decimal.toPlainString()
135148
}
136149

150+
private fun getDefaultSpanOneRecordPanel(): JPanel {
151+
val spanOneRecordPanel = JPanel(BorderLayout())
152+
spanOneRecordPanel.border = empty(5, 0, 0, 0)
153+
spanOneRecordPanel.isOpaque = false
154+
return spanOneRecordPanel
155+
}
156+
137157
fun genToolTip(span: SlowSpanInfo): String {
138158
return asHtml(span.spanInfo.displayName)
139159
// """

src/main/kotlin/org/digma/intellij/plugin/ui/list/insights/SpanPanels.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ fun percentileRowPanel(percentile: SpanDurationsPercentile, panelsLayoutHelper:
106106
}
107107

108108
fun createDefaultBoxLayoutLineAxisPanel(): JPanel {
109+
return createDefaultBoxLayoutLineAxisPanel(0, 0, 0, 0)
110+
}
111+
112+
fun createDefaultBoxLayoutLineAxisPanel(top: Int, left: Int, bottom: Int, right: Int): JPanel {
109113
val defaultPanel = JBPanel<JBPanel<*>>()
110114
defaultPanel.layout = BoxLayout(defaultPanel, BoxLayout.LINE_AXIS)
111-
defaultPanel.border = empty()
115+
defaultPanel.border = empty(top, left, bottom, right)
112116
defaultPanel.isOpaque = false
113117
return defaultPanel
114118
}

0 commit comments

Comments
 (0)