@@ -68,6 +68,11 @@ import kotlinx.coroutines.withContext
6868import org.zeroturnaround.exec.ProcessExecutor
6969import java.awt.Component
7070import java.awt.Dimension
71+ import java.awt.event.MouseEvent
72+ import java.awt.event.MouseListener
73+ import java.awt.event.MouseMotionListener
74+ import java.awt.font.TextAttribute
75+ import java.awt.font.TextAttribute.UNDERLINE_ON
7176import javax.swing.Icon
7277import javax.swing.JTable
7378import javax.swing.JTextField
@@ -80,6 +85,8 @@ private const val CODER_URL_KEY = "coder-url"
8085
8186private const val SESSION_TOKEN = " session-token"
8287
88+ private const val MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW = " MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW"
89+
8390class CoderWorkspacesStepView (val enableNextButtonCallback : (Boolean ) -> Unit ) : CoderWorkspacesWizardStep, Disposable {
8491 private val cs = CoroutineScope (Dispatchers .Main )
8592 private var localWizardModel = CoderWorkspacesWizardModel ()
@@ -123,6 +130,49 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
123130 }
124131 updateWorkspaceActions()
125132 }
133+
134+ addMouseListener(object : MouseListener {
135+ override fun mouseClicked (e : MouseEvent ? ) {
136+ if (e?.source is TableView <* >) {
137+ val tblView = e.source as TableView <WorkspaceAgentModel >
138+ val col = tblView.selectedColumn
139+ val workspace = tblView.selectedObject
140+
141+ if (col == 2 && workspace != null ) {
142+ BrowserUtil .browse(coderClient.coderURL.toURI().resolve(" /templates/${workspace.templateName} " ))
143+ }
144+ }
145+ }
146+
147+ override fun mousePressed (e : MouseEvent ? ) {
148+ }
149+
150+ override fun mouseReleased (e : MouseEvent ? ) {
151+ }
152+
153+ override fun mouseEntered (e : MouseEvent ? ) {
154+ }
155+
156+ override fun mouseExited (e : MouseEvent ? ) {
157+ }
158+ })
159+ addMouseMotionListener(object : MouseMotionListener {
160+ override fun mouseMoved (e : MouseEvent ? ) {
161+ if (e?.source is TableView <* >) {
162+ val tblView = e.source as TableView <WorkspaceAgentModel >
163+ val row = tblView.rowAtPoint(e.point)
164+ if (tblView.columnAtPoint(e.point) == 2 && row in 0 until tblView.listTableModel.rowCount) {
165+ tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW , row)
166+ } else {
167+ tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW , - 1 )
168+ }
169+ }
170+
171+ }
172+
173+ override fun mouseDragged (e : MouseEvent ? ) {
174+ }
175+ })
126176 }
127177
128178 private val goToDashboardAction = GoToDashboardAction ()
@@ -569,9 +619,10 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
569619 override fun isCenterAlignment () = true
570620
571621 override fun getTableCellRendererComponent (table : JTable ? , value : Any? , selected : Boolean , focus : Boolean , row : Int , column : Int ): Component {
572- return super .getTableCellRendererComponent(table, value, selected, focus, row, column).apply {
573- border = JBUI .Borders .empty(10 , 10 )
622+ super .getTableCellRendererComponent(table, value, selected, focus, row, column).apply {
623+ border = JBUI .Borders .empty(10 )
574624 }
625+ return this
575626 }
576627 }
577628 }
@@ -590,6 +641,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
590641 text = value
591642 }
592643 font = JBFont .h3().asBold()
644+ border = JBUI .Borders .empty()
593645 return this
594646 }
595647 }
@@ -602,13 +654,27 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
602654 }
603655
604656 override fun getRenderer (item : WorkspaceAgentModel ? ): TableCellRenderer {
657+ val simpleH3 = JBFont .h3()
658+
659+ val h3AttributesWithUnderlining = simpleH3.attributes as MutableMap <TextAttribute , Any >
660+ h3AttributesWithUnderlining[TextAttribute .UNDERLINE ] = UNDERLINE_ON
661+ val underlinedH3 = JBFont .h3().deriveFont(h3AttributesWithUnderlining)
605662 return object : DefaultTableCellRenderer () {
606663 override fun getTableCellRendererComponent (table : JTable , value : Any , isSelected : Boolean , hasFocus : Boolean , row : Int , column : Int ): Component {
607664 super .getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
608665 if (value is String ) {
609666 text = value
610667 }
611- font = JBFont .h3()
668+ border = JBUI .Borders .empty()
669+
670+ if (table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW ) != null ) {
671+ val mouseOverRow = table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW ) as Int
672+ if (mouseOverRow >= 0 && mouseOverRow == row) {
673+ font = underlinedH3
674+ return this
675+ }
676+ }
677+ font = simpleH3
612678 return this
613679 }
614680 }
@@ -628,6 +694,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
628694 text = value
629695 }
630696 font = JBFont .h3()
697+ border = JBUI .Borders .empty()
631698 return this
632699 }
633700 }
@@ -647,6 +714,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
647714 text = value
648715 }
649716 font = JBFont .h3()
717+ border = JBUI .Borders .empty()
650718 foreground = (table.model as ListTableModel <WorkspaceAgentModel >).getRowValue(row).statusColor()
651719 return this
652720 }
0 commit comments