@@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.ActionGroup
55import com.intellij.openapi.actionSystem.ActionManager
66import com.intellij.openapi.actionSystem.ActionToolbar
77import com.intellij.openapi.actionSystem.DefaultActionGroup
8+ import com.intellij.openapi.diagnostic.Logger
89import com.intellij.openapi.project.DumbAware
910import com.intellij.openapi.ui.JBMenuItem
1011import com.intellij.openapi.ui.JBPopupMenu
@@ -22,16 +23,16 @@ import no.spk.fiskeoye.plugin.actions.window.ScrollToTopAction
2223import no.spk.fiskeoye.plugin.actions.window.SettingAction
2324import no.spk.fiskeoye.plugin.component.LabelIcon
2425import no.spk.fiskeoye.plugin.component.LabelIconRenderer
26+ import no.spk.fiskeoye.plugin.component.menu.CopyLinkForJiraMenuItem
27+ import no.spk.fiskeoye.plugin.component.menu.CopyLinkForMarkdownMenuItem
28+ import no.spk.fiskeoye.plugin.component.menu.CopyLinkMenuItem
29+ import no.spk.fiskeoye.plugin.component.menu.CopyTextMenuItem
2530import no.spk.fiskeoye.plugin.icons.FiskeoyeIcons
26- import no.spk.fiskeoye.plugin.icons.FiskeoyeIcons.CopyLink
27- import no.spk.fiskeoye.plugin.icons.FiskeoyeIcons.CopyLinkForJira
28- import no.spk.fiskeoye.plugin.icons.FiskeoyeIcons.CopyLinkForMarkdown
2931import no.spk.fiskeoye.plugin.listeners.button.FiskeoyeActionListener
3032import no.spk.fiskeoye.plugin.listeners.table.TableCellKeyListener
3133import no.spk.fiskeoye.plugin.listeners.table.TableCellMouseListener
3234import no.spk.fiskeoye.plugin.listeners.toggle.ToggleKeyListener
3335import no.spk.fiskeoye.plugin.settings.FiskeoyeState
34- import no.spk.fiskeoye.plugin.util.copy
3536import java.awt.Dimension
3637import java.awt.Font
3738import java.awt.event.KeyListener
@@ -45,6 +46,8 @@ import javax.swing.event.PopupMenuEvent
4546
4647internal abstract class FiskeoyePanel : SimpleToolWindowPanel (true , true ), DumbAware {
4748
49+ private val logger: Logger = Logger .getInstance(FiskeoyePanel ::class .java)
50+
4851 protected fun buildToolbar (place : String , actionGroup : ActionGroup , horizontal : Boolean = false): ActionToolbar {
4952 return ActionManager .getInstance().createActionToolbar(place, actionGroup, horizontal).apply {
5053 setShowSeparatorTitles(true )
@@ -108,58 +111,22 @@ internal abstract class FiskeoyePanel : SimpleToolWindowPanel(true, true), DumbA
108111 val isNotNull = table.model.getValueAt(table.selectedRow, 1 ) != null
109112 isNotNull && hasData && isNotEmpty
110113 } catch (e: Exception ) {
114+ logger.error(e)
111115 false
112116 }
113117 if (! isValid) {
114- val nothingHere = JBMenuItem (" Nothing here" )
115- add(nothingHere)
118+ add(JBMenuItem (" Nothing here" ))
116119 return
117120 }
118- val copyLink = buildCopyLink(table)
119- add(copyLink)
120- val copyLinkForMarkdown = buildCopyLinkForMarkdown(table)
121- add(copyLinkForMarkdown)
122- val copyLinkForJira = buildCopyLinkForJira(table)
123- add(copyLinkForJira)
121+ add(CopyTextMenuItem (table))
122+ add(CopyLinkMenuItem (table))
123+ add(CopyLinkForMarkdownMenuItem (table))
124+ add(CopyLinkForJiraMenuItem (table))
124125 }
125126 })
126127 }
127128 }
128129
129- private fun buildCopyLink (table : JBTable ): JBMenuItem {
130- return JBMenuItem (" Copy Link" , CopyLink ).apply {
131- this .addActionListener {
132- val selectedRow = table.selectedRow
133- val url = table.model.getValueAt(selectedRow, 1 ).toString()
134- copy(url)
135- }
136- }
137- }
138-
139- private fun buildCopyLinkForMarkdown (table : JBTable ): JBMenuItem {
140- return JBMenuItem (" Copy Link for Markdown" , CopyLinkForMarkdown ).apply {
141- this .addActionListener {
142- val selectedRow = table.selectedRow
143- val url = table.model.getValueAt(selectedRow, 1 ).toString()
144- val text = table.model.getValueAt(selectedRow, 2 ).toString()
145- val markdown = " [$text ]($url )"
146- copy(markdown)
147- }
148- }
149- }
150-
151- private fun buildCopyLinkForJira (table : JBTable ): JBMenuItem {
152- return JBMenuItem (" Copy Link for Jira" , CopyLinkForJira ).apply {
153- this .addActionListener {
154- val selectedRow = table.selectedRow
155- val url = table.model.getValueAt(selectedRow, 1 ).toString()
156- val text = table.model.getValueAt(selectedRow, 2 ).toString()
157- val markdown = " [$text |$url ]"
158- copy(markdown)
159- }
160- }
161- }
162-
163130 protected fun buildTextField (colums : Int , keyListener : KeyListener ? = null): JBTextField {
164131 return JBTextField ().apply {
165132 columns = colums
0 commit comments