@@ -22,6 +22,7 @@ import com.coder.gateway.sdk.v2.models.WorkspaceStatus
22
22
import com.coder.gateway.sdk.v2.models.toAgentModels
23
23
import com.coder.gateway.sdk.withPath
24
24
import com.coder.gateway.services.CoderSettingsState
25
+ import com.intellij.icons.AllIcons
25
26
import com.intellij.ide.ActivityTracker
26
27
import com.intellij.ide.BrowserUtil
27
28
import com.intellij.ide.IdeBundle
@@ -72,11 +73,6 @@ import kotlinx.coroutines.withContext
72
73
import org.zeroturnaround.exec.InvalidExitValueException
73
74
import java.awt.Component
74
75
import 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
80
76
import java.net.ConnectException
81
77
import java.net.SocketTimeoutException
82
78
import java.net.URL
@@ -94,8 +90,6 @@ private const val CODER_URL_KEY = "coder-url"
94
90
95
91
private const val SESSION_TOKEN = " session-token"
96
92
97
- private const val MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW = " MOUSE_OVER_TEMPLATE_NAME_COLUMN_ON_ROW"
98
-
99
93
class CoderWorkspacesStepView (val setNextButtonEnabled : (Boolean ) -> Unit ) : CoderWorkspacesWizardStep, Disposable {
100
94
private val cs = CoroutineScope (Dispatchers .Main )
101
95
private var localWizardModel = CoderWorkspacesWizardModel ()
@@ -136,52 +130,10 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
136
130
}
137
131
updateWorkspaceActions()
138
132
}
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
- })
182
133
}
183
134
184
135
private val goToDashboardAction = GoToDashboardAction ()
136
+ private val goToTemplateAction = GoToTemplateAction ()
185
137
private val startWorkspaceAction = StartWorkspaceAction ()
186
138
private val stopWorkspaceAction = StopWorkspaceAction ()
187
139
private val updateWorkspaceTemplateAction = UpdateWorkspaceTemplateAction ()
@@ -191,7 +143,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
191
143
.disableAddAction()
192
144
.disableRemoveAction()
193
145
.disableUpDownActions()
194
- .addExtraActions(goToDashboardAction, startWorkspaceAction, stopWorkspaceAction, updateWorkspaceTemplateAction, createWorkspaceAction as AnAction )
146
+ .addExtraActions(goToDashboardAction, startWorkspaceAction, stopWorkspaceAction, updateWorkspaceTemplateAction, createWorkspaceAction, goToTemplateAction as AnAction )
195
147
196
148
197
149
private var poller: Job ? = null
@@ -274,6 +226,16 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
274
226
}
275
227
}
276
228
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
+
277
239
private inner class StartWorkspaceAction :
278
240
AnActionButton (CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.start.text" ), CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.start.text" ), CoderIcons .RUN ) {
279
241
override fun actionPerformed (p0 : AnActionEvent ) {
@@ -376,6 +338,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
376
338
private fun updateWorkspaceActions () {
377
339
goToDashboardAction.isEnabled = clientService.isReady
378
340
createWorkspaceAction.isEnabled = clientService.isReady
341
+ goToTemplateAction.isEnabled = tableOfWorkspaces.selectedObject != null
379
342
when (tableOfWorkspaces.selectedObject?.workspaceStatus) {
380
343
WorkspaceStatus .RUNNING -> {
381
344
startWorkspaceAction.isEnabled = false
@@ -815,19 +778,8 @@ class WorkspacesTableModel : ListTableModel<WorkspaceAgentModel>(
815
778
if (value is String ) {
816
779
text = value
817
780
}
781
+ font = table.tableHeader.font
818
782
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
831
783
return this
832
784
}
833
785
}
0 commit comments