@@ -36,6 +36,7 @@ import java.awt.Dimension
3636import java.awt.Font
3737import java.awt.event.KeyListener
3838import javax.swing.JButton
39+ import javax.swing.JTable.AUTO_RESIZE_OFF
3940import javax.swing.JToggleButton
4041import javax.swing.ListSelectionModel
4142import javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
@@ -72,6 +73,7 @@ internal abstract class FiskeoyePanel : SimpleToolWindowPanel(true, true), DumbA
7273 componentPopupMenu = buildPopupMenu(this )
7374 font = buildFont()
7475 autoscrolls = false
76+ autoResizeMode = AUTO_RESIZE_OFF
7577 setDefaultRenderer(LabelIcon ::class .java, LabelIconRenderer ())
7678 setSelectionMode(ListSelectionModel .SINGLE_INTERVAL_SELECTION )
7779 setShowGrid(false )
@@ -97,25 +99,30 @@ internal abstract class FiskeoyePanel : SimpleToolWindowPanel(true, true), DumbA
9799
98100 private fun buildPopupMenu (table : JBTable ): JBPopupMenu {
99101 return JBPopupMenu ().apply popupMenu@{
100- val copyLink = buildCopyLink(table)
101- this .add(copyLink)
102- val copyLinkForMarkdown = buildCopyLinkForMarkdown(table)
103- this .add(copyLinkForMarkdown)
104- val copyLinkForJira = buildCopyLinkForJira(table)
105- this .add(copyLinkForJira)
106- val nothingHere = JBMenuItem (" Nothing here" )
107- this .add(nothingHere)
108-
109102 this .addPopupMenuListener(object : PopupMenuListenerAdapter () {
110103 override fun popupMenuWillBecomeVisible (e : PopupMenuEvent ? ) {
111- val tableIsValid = (! table.isEmpty && table.model.getValueAt(table.selectedRow, 1 ) != null )
112- copyLink.isVisible = tableIsValid
113- copyLinkForMarkdown.isVisible = tableIsValid
114- copyLinkForJira.isVisible = tableIsValid
115- nothingHere.isVisible = ! tableIsValid
104+ removeAll()
105+ val isValid = try {
106+ val isNotEmpty = ! table.isEmpty
107+ val hasData = table.selectedRow >= 0 && table.selectedRow < table.rowCount
108+ val isNotNull = table.model.getValueAt(table.selectedRow, 1 ) != null
109+ isNotNull && hasData && isNotEmpty
110+ } catch (e: Exception ) {
111+ false
112+ }
113+ if (! isValid) {
114+ val nothingHere = JBMenuItem (" Nothing here" )
115+ add(nothingHere)
116+ return
117+ }
118+ val copyLink = buildCopyLink(table)
119+ add(copyLink)
120+ val copyLinkForMarkdown = buildCopyLinkForMarkdown(table)
121+ add(copyLinkForMarkdown)
122+ val copyLinkForJira = buildCopyLinkForJira(table)
123+ add(copyLinkForJira)
116124 }
117125 })
118-
119126 }
120127 }
121128
@@ -174,7 +181,7 @@ internal abstract class FiskeoyePanel : SimpleToolWindowPanel(true, true), DumbA
174181 }
175182
176183 @Suppress(" UnstableApiUsage" )
177- protected fun buildSeachButton (fiskeoyeActionListener : FiskeoyeActionListener ): JButton {
184+ protected fun buildSearchButton (fiskeoyeActionListener : FiskeoyeActionListener ): JButton {
178185 return JButton ().apply {
179186 defaultButton()
180187 text = " Search"
0 commit comments