@@ -22,6 +22,7 @@ import com.coder.gateway.sdk.v2.models.WorkspaceStatus
2222import com.coder.gateway.sdk.v2.models.toAgentModels
2323import com.coder.gateway.sdk.withPath
2424import com.coder.gateway.services.CoderSettingsState
25+ import com.intellij.icons.AllIcons
2526import com.intellij.ide.ActivityTracker
2627import com.intellij.ide.BrowserUtil
2728import com.intellij.ide.IdeBundle
@@ -72,11 +73,6 @@ import kotlinx.coroutines.withContext
7273import org.zeroturnaround.exec.InvalidExitValueException
7374import java.awt.Component
7475import java.awt.Dimension
75- import java.awt.event.MouseEvent
76- import java.awt.event.MouseListener
77- import java.awt.event.MouseMotionListener
78- import java.awt.font.TextAttribute
79- import java.awt.font.TextAttribute.UNDERLINE_ON
8076import java.net.ConnectException
8177import java.net.SocketTimeoutException
8278import java.net.URL
@@ -94,8 +90,6 @@ private const val CODER_URL_KEY = "coder-url"
9490
9591private const val SESSION_TOKEN = " session-token"
9692
97- private const val MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW = " MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW"
98-
9993class CoderWorkspacesStepView (val setNextButtonEnabled : (Boolean ) -> Unit ) : CoderWorkspacesWizardStep, Disposable {
10094 private val cs = CoroutineScope (Dispatchers .Main )
10195 private var localWizardModel = CoderWorkspacesWizardModel ()
@@ -136,52 +130,10 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
136130 }
137131 updateWorkspaceActions()
138132 }
139-
140- addMouseListener(object : MouseListener {
141- override fun mouseClicked (e : MouseEvent ? ) {
142- if (e?.source is TableView <* >) {
143- val tblView = e.source as TableView <WorkspaceAgentModel >
144- val col = tblView.selectedColumn
145- val workspace = tblView.selectedObject
146-
147- if (col == 2 && workspace != null ) {
148- BrowserUtil .browse(clientService.client.url.toURI().resolve(" /templates/${workspace.templateName} " ))
149- }
150- }
151- }
152-
153- override fun mousePressed (e : MouseEvent ? ) {
154- }
155-
156- override fun mouseReleased (e : MouseEvent ? ) {
157- }
158-
159- override fun mouseEntered (e : MouseEvent ? ) {
160- }
161-
162- override fun mouseExited (e : MouseEvent ? ) {
163- }
164- })
165- addMouseMotionListener(object : MouseMotionListener {
166- override fun mouseMoved (e : MouseEvent ? ) {
167- if (e?.source is TableView <* >) {
168- val tblView = e.source as TableView <WorkspaceAgentModel >
169- val row = tblView.rowAtPoint(e.point)
170- if (tblView.columnAtPoint(e.point) == 2 && row in 0 until tblView.listTableModel.rowCount) {
171- tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW , row)
172- } else {
173- tblView.putClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW , - 1 )
174- }
175- }
176-
177- }
178-
179- override fun mouseDragged (e : MouseEvent ? ) {
180- }
181- })
182133 }
183134
184135 private val goToDashboardAction = GoToDashboardAction ()
136+ private val goToTemplateAction = GoToTemplateAction ()
185137 private val startWorkspaceAction = StartWorkspaceAction ()
186138 private val stopWorkspaceAction = StopWorkspaceAction ()
187139 private val updateWorkspaceTemplateAction = UpdateWorkspaceTemplateAction ()
@@ -191,7 +143,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
191143 .disableAddAction()
192144 .disableRemoveAction()
193145 .disableUpDownActions()
194- .addExtraActions(goToDashboardAction, startWorkspaceAction, stopWorkspaceAction, updateWorkspaceTemplateAction, createWorkspaceAction as AnAction )
146+ .addExtraActions(goToDashboardAction, startWorkspaceAction, stopWorkspaceAction, updateWorkspaceTemplateAction, createWorkspaceAction, goToTemplateAction as AnAction )
195147
196148
197149 private var poller: Job ? = null
@@ -274,6 +226,16 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
274226 }
275227 }
276228
229+ private inner class GoToTemplateAction :
230+ AnActionButton (CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.template.text" ), CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.template.text" ), AllIcons .Nodes .Template ) {
231+ override fun actionPerformed (p0 : AnActionEvent ) {
232+ if (tableOfWorkspaces.selectedObject != null ) {
233+ val workspace = tableOfWorkspaces.selectedObject as WorkspaceAgentModel
234+ BrowserUtil .browse(clientService.client.url.toURI().resolve(" /templates/${workspace.templateName} " ))
235+ }
236+ }
237+ }
238+
277239 private inner class StartWorkspaceAction :
278240 AnActionButton (CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.start.text" ), CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.start.text" ), CoderIcons .RUN ) {
279241 override fun actionPerformed (p0 : AnActionEvent ) {
@@ -376,6 +338,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
376338 private fun updateWorkspaceActions () {
377339 goToDashboardAction.isEnabled = clientService.isReady
378340 createWorkspaceAction.isEnabled = clientService.isReady
341+ goToTemplateAction.isEnabled = tableOfWorkspaces.selectedObject != null
379342 when (tableOfWorkspaces.selectedObject?.workspaceStatus) {
380343 WorkspaceStatus .RUNNING -> {
381344 startWorkspaceAction.isEnabled = false
@@ -815,19 +778,8 @@ class WorkspacesTableModel : ListTableModel<WorkspaceAgentModel>(
815778 if (value is String ) {
816779 text = value
817780 }
781+ font = table.tableHeader.font
818782 border = JBUI .Borders .empty(0 , 8 )
819-
820- val simpleH3 = table.tableHeader.font
821- if (table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW ) != null ) {
822- val mouseOverRow = table.getClientProperty(MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW ) as Int
823- if (mouseOverRow >= 0 && mouseOverRow == row) {
824- val h3AttributesWithUnderlining = simpleH3.attributes as MutableMap <TextAttribute , Any >
825- h3AttributesWithUnderlining[TextAttribute .UNDERLINE ] = UNDERLINE_ON
826- font = JBFont .h3().deriveFont(h3AttributesWithUnderlining)
827- return this
828- }
829- }
830- font = simpleH3
831783 return this
832784 }
833785 }
0 commit comments