@@ -33,6 +33,7 @@ import com.intellij.openapi.ui.panel.ComponentPanelBuilder
33
33
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
34
34
import com.intellij.ui.AnimatedIcon
35
35
import com.intellij.ui.DocumentAdapter
36
+ import com.intellij.ui.JBColor
36
37
import com.intellij.ui.SearchTextField
37
38
import com.intellij.ui.components.ActionLink
38
39
import com.intellij.ui.components.JBScrollPane
@@ -57,6 +58,7 @@ import kotlinx.coroutines.delay
57
58
import kotlinx.coroutines.isActive
58
59
import kotlinx.coroutines.launch
59
60
import kotlinx.coroutines.withContext
61
+ import java.awt.Color
60
62
import java.awt.Component
61
63
import java.awt.Dimension
62
64
import java.util.Locale
@@ -194,26 +196,24 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
194
196
TopGap .MEDIUM
195
197
}
196
198
row {
197
- // icon(status.first).applyToComponent {
198
- // foreground = status.second
199
- // }.align(AlignX.LEFT).gap(RightGap.SMALL).applyToComponent {
200
- // size = Dimension(JBUI.scale(16), JBUI.scale(16))
201
- // }
202
199
label(workspaceName).applyToComponent {
203
200
font = JBFont .h3().asBold()
204
201
}.align(AlignX .LEFT ).gap(RightGap .SMALL )
205
202
label(deploymentURL).applyToComponent {
206
203
foreground = UIUtil .getContextHelpForeground()
207
204
font = ComponentPanelBuilder .getCommentFont(font)
208
205
}
209
- label(" " ).resizableColumn().align(AlignX .FILL )
210
- actionButton(
211
- object : DumbAwareAction (
212
- CoderGatewayBundle .message(" gateway.connector.recent-connections.start.button.tooltip" ),
213
- " " ,
214
- CoderIcons .RUN ,
215
- ) {
216
- override fun actionPerformed (e : AnActionEvent ) {
206
+ label(" " ).resizableColumn().align(AlignX .FILL ) }.topGap(gap)
207
+
208
+ row { label(" Select a project to launch." ) }
209
+ connections.forEach { workspaceProjectIDE ->
210
+
211
+ val actionLink = ActionLink (workspaceProjectIDE.projectPathDisplay) {
212
+ if (workspaceWithAgent?.workspace?.latestBuild?.status == WorkspaceStatus .RUNNING && workspaceWithAgent.status == WorkspaceAndAgentStatus .READY ) {
213
+ CoderRemoteConnectionHandle ().connect { workspaceProjectIDE }
214
+ GatewayUI .getInstance().reset()
215
+ } else {
216
+ // Start the workspace
217
217
withoutNull(workspaceWithAgent?.workspace, deployment?.client) { workspace, client ->
218
218
jobs[workspace.id]?.cancel()
219
219
jobs[workspace.id] =
@@ -227,78 +227,20 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
227
227
}
228
228
}
229
229
}
230
+ cs.launch {
231
+ jobs[workspace.id]?.join()
232
+ CoderRemoteConnectionHandle ().connect { workspaceProjectIDE }
233
+ GatewayUI .getInstance().reset()
234
+ }
230
235
}
236
+
231
237
}
232
- },
233
- ).applyToComponent {
234
- isEnabled =
235
- listOf (
236
- WorkspaceStatus .STOPPED ,
237
- WorkspaceStatus .FAILED ,
238
- ).contains(workspaceWithAgent?.workspace?.latestBuild?.status)
239
- }
240
- .gap(RightGap .SMALL )
241
- actionButton(
242
- object : DumbAwareAction (
243
- CoderGatewayBundle .message(" gateway.connector.recent-connections.stop.button.tooltip" ),
244
- " " ,
245
- CoderIcons .STOP ,
246
- ) {
247
- override fun actionPerformed (e : AnActionEvent ) {
248
- withoutNull(workspaceWithAgent?.workspace, deployment?.client) { workspace, client ->
249
- jobs[workspace.id]?.cancel()
250
- jobs[workspace.id] =
251
- cs.launch(ModalityState .current().asContextElement()) {
252
- withContext(Dispatchers .IO ) {
253
- try {
254
- client.stopWorkspace(workspace)
255
- fetchWorkspaces()
256
- } catch (e: Exception ) {
257
- logger.error(" Could not stop workspace ${workspace.name} " , e)
258
- }
259
- }
260
- }
261
- }
262
- }
263
- },
264
- ).applyToComponent { isEnabled = workspaceWithAgent?.workspace?.latestBuild?.status == WorkspaceStatus .RUNNING }
265
- .gap(RightGap .SMALL )
266
- actionButton(
267
- object : DumbAwareAction (
268
- CoderGatewayBundle .message(" gateway.connector.recent-connections.terminal.button.tooltip" ),
269
- " " ,
270
- CoderIcons .OPEN_TERMINAL ,
271
- ) {
272
- override fun actionPerformed (e : AnActionEvent ) {
273
- withoutNull(workspaceWithAgent, deployment?.client) { ws, client ->
274
- val link = client.url.withPath(" /me/${ws.name} /terminal" )
275
- BrowserUtil .browse(link.toString())
276
- }
277
- }
278
- },
279
- )
280
- }.topGap(gap)
281
- if (deploymentError == null || showError) {
282
- row {
283
- // There must be a way to make this properly wrap?
284
- if (status.first == CoderIcons .PENDING ) {
285
- icon(AnimatedIcon .Default ())
286
238
}
287
- label(" <html><body style='width:350px;'>" + status.third + " </html>" ).applyToComponent {
288
- foreground = status.second
289
- }
290
- }
291
- }
292
- if (workspaceWithAgent?.workspace?.latestBuild?.status == WorkspaceStatus .RUNNING && workspaceWithAgent.status == WorkspaceAndAgentStatus .READY ) {
293
- row { label(" Select a project to launch." ) }
294
- connections.forEach { workspaceProjectIDE ->
239
+
295
240
row {
296
241
icon(workspaceProjectIDE.ideProduct.icon)
297
242
cell(
298
- ActionLink (workspaceProjectIDE.projectPathDisplay) {
299
- CoderRemoteConnectionHandle ().connect { workspaceProjectIDE }
300
- GatewayUI .getInstance().reset()
301
- },
243
+ actionLink,
302
244
)
303
245
label(" " ).resizableColumn().align(AlignX .FILL )
304
246
label(workspaceProjectIDE.ideName).applyToComponent {
@@ -323,7 +265,7 @@ class CoderGatewayRecentWorkspaceConnectionsView(private val setContentCallback:
323
265
)
324
266
}
325
267
}
326
- }
268
+
327
269
}
328
270
}
329
271
}.apply {
0 commit comments