@@ -27,16 +27,22 @@ import java.awt.event.MouseEvent
2727import java.time.Duration
2828import java.time.LocalDateTime
2929import java.time.ZoneId
30- import java.util.*
31- import javax.swing.*
30+ import java.util.Date
31+ import javax.swing.Box
32+ import javax.swing.Icon
33+ import javax.swing.JButton
34+ import javax.swing.JComponent
35+ import javax.swing.JLabel
36+ import javax.swing.JPanel
37+ import javax.swing.SwingConstants
3238import kotlin.math.max
3339
3440private const val RECALCULATE = " Recalculate"
3541private const val REFRESH = " Refresh"
3642
3743fun insightTitlePanel (panel : JPanel ): JPanel {
3844 panel.isOpaque = false
39- panel.border = empty( 0 , 5 )
45+ panel.border = empty(0 , 5 )
4046 return panel
4147}
4248
@@ -141,22 +147,22 @@ private fun rebuildPanel(
141147 insightPanel as DigmaResettablePanel
142148 ), BorderLayout .EAST )
143149
144- if (bodyPanel != null || buttons != null ){
150+ if (bodyPanel != null || buttons != null ) {
145151 val bodyWrapper = createDefaultBoxLayoutYAxisPanel()
146152 bodyWrapper.isOpaque = false
147153
148- if (insight.customStartTime != null || isRecalculateButtonPressed)
154+ if (insight.customStartTime != null || isRecalculateButtonPressed)
149155 bodyWrapper.add(getTimeInfoMessagePanel(
150156 customStartTime = insight.customStartTime,
151157 actualStartTime = insight.actualStartTime,
152158 isRecalculateButtonPressed = isRecalculateButtonPressed,
153159 project = project
154160 ))
155161
156- if (bodyPanel != null )
162+ if (bodyPanel != null )
157163 bodyWrapper.add(bodyPanel)
158164
159- if (buttons != null ){
165+ if (buttons != null ) {
160166 val buttonsListPanel = getBasicEmptyListPanel()
161167 buttonsListPanel.border = JBUI .Borders .emptyTop(5 )
162168 buttons.filterNotNull().forEach {
@@ -166,11 +172,11 @@ private fun rebuildPanel(
166172 bodyWrapper.add(buttonsListPanel)
167173 }
168174
169- if (paginationComponent != null ){
175+ if (paginationComponent != null ) {
170176 bodyWrapper.add(getPaginationPanel(paginationComponent))
171177 }
172178
173- insightPanel.add(bodyWrapper,BorderLayout .SOUTH )
179+ insightPanel.add(bodyWrapper, BorderLayout .SOUTH )
174180 }
175181 return insightPanel
176182}
@@ -224,15 +230,16 @@ private fun getFormattedTimeDifference(diff: Duration): String {
224230 }
225231 return builder.toString()
226232}
233+
227234private fun getBasicEmptyListPanel (): JPanel {
228- val listPanel = JPanel (FlowLayout (FlowLayout .RIGHT , 0 , 0 ))
235+ val listPanel = JPanel (FlowLayout (FlowLayout .RIGHT , 0 , 0 ))
229236 listPanel.isOpaque = false
230237 listPanel.border = empty()
231238 return listPanel
232239}
233240
234241private fun getPaginationPanel (paginationComponent : JComponent ? ): JPanel {
235- val paginationPanel = JPanel (FlowLayout (FlowLayout .LEFT , 0 , 0 ))
242+ val paginationPanel = JPanel (FlowLayout (FlowLayout .LEFT , 0 , 0 ))
236243 paginationPanel.isOpaque = false
237244 paginationPanel.border = empty()
238245
@@ -242,7 +249,7 @@ private fun getPaginationPanel(paginationComponent: JComponent?): JPanel {
242249}
243250
244251private fun getMessageLabel (title : String , description : String ): JLabel {
245- val messageLabel = JLabel (buildBoldTitleGrayedComment(title,description), SwingConstants .LEFT )
252+ val messageLabel = JLabel (buildBoldTitleGrayedComment(title, description), SwingConstants .LEFT )
246253 messageLabel.isOpaque = false
247254 messageLabel.verticalAlignment = SwingConstants .TOP
248255 return messageLabel
@@ -258,7 +265,7 @@ private fun getIconsListPanel(
258265 if (iconsList != null ) {
259266 icons.addAll(iconsList)
260267 }
261- if (insight.prefixedCodeObjectId != null ) {
268+ if (insight.prefixedCodeObjectId != null ) {
262269 icons.add(Laf .Icons .Insight .THREE_DOTS )
263270 }
264271
@@ -269,9 +276,9 @@ private fun getIconsListPanel(
269276 iconLabel.horizontalAlignment = SwingConstants .RIGHT
270277 iconLabel.verticalAlignment = SwingConstants .TOP
271278 iconLabel.isOpaque = false
272- iconLabel.border = empty(2 ,2 , 2 , 4 )
279+ iconLabel.border = empty(2 , 2 , 2 , 4 )
273280
274- if (it.instanceOf(ThreeDotsIcon ::class )) {
281+ if (it.instanceOf(ThreeDotsIcon ::class )) {
275282 iconLabel.cursor = Cursor .getPredefinedCursor(Cursor .HAND_CURSOR )
276283 iconLabel.addMouseListener(object : MouseAdapter () {
277284 override fun mouseClicked (e : MouseEvent ? ) {
@@ -283,6 +290,7 @@ private fun getIconsListPanel(
283290 project = project
284291 )
285292 }
293+
286294 override fun mouseEntered (e : MouseEvent ? ) {
287295 showHintMessage(
288296 threeDotsIcon = iconLabel,
@@ -292,6 +300,7 @@ private fun getIconsListPanel(
292300 project = project
293301 )
294302 }
303+
295304 override fun mouseExited (e : MouseEvent ? ) {}
296305 override fun mousePressed (e : MouseEvent ? ) {}
297306 })
@@ -352,38 +361,54 @@ fun genericPanelForSingleInsight(project: Project, modelObject: Any?): JPanel {
352361}
353362
354363
355- internal fun getInsightIconPanelRightBorderSize ():Int {
364+ internal fun getInsightIconPanelRightBorderSize (): Int {
356365 return 5
357366}
358- internal fun getCurrentLargestWidthIconPanel (layoutHelper : PanelsLayoutHelper , width : Int ):Int {
367+
368+ internal fun getCurrentLargestWidthIconPanel (layoutHelper : PanelsLayoutHelper , width : Int ): Int {
359369 // this method should never return null and never throw NPE
360370 val currentLargest: Int =
361- (layoutHelper.getObjectAttribute(" insightsIconPanelBorder" ," largestWidth" )? : 0 ) as Int
362- return max(width,currentLargest)
371+ (layoutHelper.getObjectAttribute(" insightsIconPanelBorder" , " largestWidth" ) ? : 0 ) as Int
372+ return max(width, currentLargest)
363373}
364- internal fun addCurrentLargestWidthIconPanel (layoutHelper : PanelsLayoutHelper ,width : Int ){
374+
375+ internal fun addCurrentLargestWidthIconPanel (layoutHelper : PanelsLayoutHelper , width : Int ) {
365376 // this method should never throw NPE
366377 val currentLargest: Int =
367- (layoutHelper.getObjectAttribute(" insightsIconPanelBorder" ," largestWidth" )? : 0 ) as Int
368- layoutHelper.addObjectAttribute(" insightsIconPanelBorder" ," largestWidth" ,
369- max(currentLargest,width))
378+ (layoutHelper.getObjectAttribute(" insightsIconPanelBorder" , " largestWidth" ) ? : 0 ) as Int
379+ layoutHelper.addObjectAttribute(" insightsIconPanelBorder" , " largestWidth" ,
380+ max(currentLargest, width))
370381}
371382
383+ const val NoDataYetDescription = " No data received yet for this span, please trigger some actions using this code to see more insights."
384+
385+ fun noDataYetInsightPanel (): JPanel {
372386
387+ val thePanel = object : DigmaResettablePanel () {
388+ override fun reset () {
389+ }
390+ }
391+ thePanel.layout = BorderLayout ()
392+ thePanel.add(getMessageLabel(" No Data Yet" , " " ), BorderLayout .WEST )
393+ thePanel.add(JLabel (asHtml(NoDataYetDescription )), BorderLayout .SOUTH )
373394
374- class InsightAlignedPanel (private val layoutHelper : PanelsLayoutHelper ): JPanel(){
395+ return insightItemPanel(thePanel as DigmaResettablePanel )
396+ }
397+
398+ class InsightAlignedPanel (private val layoutHelper : PanelsLayoutHelper ) : JPanel() {
375399
376400 init {
377401 border = JBUI .Borders .emptyRight(getInsightIconPanelRightBorderSize())
378402 }
403+
379404 override fun getPreferredSize (): Dimension {
380405 val ps = super .getPreferredSize()
381- if (ps == null ){
406+ if (ps == null ) {
382407 return ps
383408 }
384409 val h = ps.height
385410 val w = ps.width
386- addCurrentLargestWidthIconPanel(layoutHelper,w)
387- return Dimension (getCurrentLargestWidthIconPanel(layoutHelper,w), h)
411+ addCurrentLargestWidthIconPanel(layoutHelper, w)
412+ return Dimension (getCurrentLargestWidthIconPanel(layoutHelper, w), h)
388413 }
389414}
0 commit comments