Skip to content

Commit d112e61

Browse files
Improved displaying of formatted time difference for "Date from" label
1 parent d17fcd5 commit d112e61

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package org.digma.intellij.plugin.ui.list.insights
22

33
import com.intellij.openapi.project.Project
44
import com.intellij.ui.components.ActionLink
5-
import com.intellij.ui.components.JBPanel
65
import com.intellij.util.ui.JBUI.Borders.empty
76
import org.digma.intellij.plugin.document.CodeObjectsUtil
87
import org.digma.intellij.plugin.model.rest.insights.SpanDurationBreakdown
@@ -94,9 +93,10 @@ fun durationBreakdownRowPanel(
9493
val spanDisplayNameLabel = getSpanDisplayNameLabel(durationBreakdown, project, moreData)
9594
val breakdownDurationLabelPanel = getBreakdownDurationLabelPanel(durationBreakdown, layoutHelper)
9695

97-
durationBreakdownPanel.add(telescopeIconLabel, BorderLayout.WEST)
98-
durationBreakdownPanel.add(spanDisplayNameLabel, BorderLayout.CENTER)
99-
durationBreakdownPanel.add(breakdownDurationLabelPanel, BorderLayout.EAST)
96+
durationBreakdownPanel.add(telescopeIconLabel)
97+
durationBreakdownPanel.add(spanDisplayNameLabel)
98+
durationBreakdownPanel.add(Box.createHorizontalGlue())
99+
durationBreakdownPanel.add(breakdownDurationLabelPanel)
100100

101101
return durationBreakdownPanel
102102
}
@@ -160,9 +160,9 @@ private fun updateDurationBreakdownPanel(durationBreakdownEntries: List<SpanDura
160160
resultBreakdownPanel!!.reset()
161161
}
162162

163-
private fun getDurationBreakdownPanel(): JBPanel<JBPanel<*>> {
164-
val durationBreakdownPanel = JBPanel<JBPanel<*>>()
165-
durationBreakdownPanel.layout = BorderLayout(5, 0)
163+
private fun getDurationBreakdownPanel(): JPanel {
164+
val durationBreakdownPanel = JPanel()
165+
durationBreakdownPanel.layout = BoxLayout(durationBreakdownPanel, BoxLayout.LINE_AXIS)
166166
durationBreakdownPanel.border = empty()
167167
durationBreakdownPanel.isOpaque = false
168168
return durationBreakdownPanel
@@ -192,7 +192,7 @@ private fun getSpanDisplayNameLabel(
192192
JLabel(asHtml(displayName), SwingConstants.LEFT)
193193
}
194194
messageLabel.toolTipText = displayName
195-
messageLabel.border = empty(0, 0, 5, 0)
195+
messageLabel.border = empty(0, 5, 5, 0)
196196
messageLabel.isOpaque = false
197197

198198
return messageLabel
@@ -208,10 +208,10 @@ private fun getBreakdownDurationLabelPanel(
208208
boldFonts(pLabel)
209209

210210
val breakdownDurationLabelPanel = JPanel()
211-
breakdownDurationLabelPanel.layout = BorderLayout()
212-
breakdownDurationLabelPanel.border = empty()
211+
breakdownDurationLabelPanel.layout = BoxLayout(breakdownDurationLabelPanel, BoxLayout.LINE_AXIS)
212+
breakdownDurationLabelPanel.border = empty(0, 0, 0, 5)
213213
breakdownDurationLabelPanel.isOpaque = false
214-
breakdownDurationLabelPanel.add(pLabel, BorderLayout.WEST)
214+
breakdownDurationLabelPanel.add(pLabel)
215215
addCurrentLargestWidthDurationPLabel(layoutHelper, breakdownDurationLabelPanel.preferredSize.width)
216216

217217
return breakdownDurationLabelPanel

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ private fun getTimeInfoMessagePanel(
193193
val timeInfoMessageLabel = JLabel(asHtml(timeInfoMessage), SwingConstants.LEFT)
194194

195195
val timeInfoMessageLabelPanel = JPanel()
196-
timeInfoMessageLabelPanel.layout = GridLayout(2, 1,0,0)
197-
timeInfoMessageLabelPanel.border = empty(2, 0)
196+
timeInfoMessageLabelPanel.layout = BoxLayout(timeInfoMessageLabelPanel, BoxLayout.Y_AXIS)
197+
timeInfoMessageLabelPanel.border = empty(0, 0, 5, 0)
198198
timeInfoMessageLabelPanel.isOpaque = false
199199
timeInfoMessageLabelPanel.add(timeInfoMessageLabel)
200200
if (shouldShowApplyNewTimeFilterLabel(isRecalculateButtonPressed, identicalStartTimes)) {
@@ -209,13 +209,15 @@ private fun shouldShowApplyNewTimeFilterLabel(isRecalculateButtonPressed: Boolea
209209

210210
private fun getFormattedTimeDifference(diff: Duration): String {
211211
val builder = StringBuilder()
212-
if (diff.toDays() > 0)
213-
builder.append(diff.toDays()," days ")
214-
if (diff.toHoursPart() > 0)
215-
builder.append( diff.toHoursPart()," hours ")
216-
if (diff.toMinutesPart() > 0)
212+
if (diff.toDays() > 0) {
213+
builder.append(diff.toDays(), " days ")
214+
} else if (diff.toHoursPart() > 0) {
215+
builder.append(diff.toHoursPart(), " hours ")
216+
} else if (diff.toMinutesPart() > 0) {
217217
builder.append(diff.toMinutesPart(), " minutes ")
218-
else builder.append(1, " minute ")
218+
} else {
219+
builder.append(1, " minute ")
220+
}
219221
return builder.toString()
220222
}
221223
private fun getBasicEmptyListPanel(): JPanel {

0 commit comments

Comments
 (0)