@@ -8,6 +8,7 @@ import com.coder.gateway.models.toIdeWithStatus
8
8
import com.coder.gateway.models.withWorkspaceProject
9
9
import com.coder.gateway.sdk.v2.models.Workspace
10
10
import com.coder.gateway.sdk.v2.models.WorkspaceAgent
11
+ import com.coder.gateway.services.CoderSettingsService
11
12
import com.coder.gateway.util.Arch
12
13
import com.coder.gateway.util.OS
13
14
import com.coder.gateway.util.humanizeDuration
@@ -20,6 +21,7 @@ import com.coder.gateway.views.LazyBrowserLink
20
21
import com.intellij.openapi.application.ApplicationManager
21
22
import com.intellij.openapi.application.ModalityState
22
23
import com.intellij.openapi.application.asContextElement
24
+ import com.intellij.openapi.components.service
23
25
import com.intellij.openapi.diagnostic.Logger
24
26
import com.intellij.openapi.ui.ComboBox
25
27
import com.intellij.openapi.ui.ComponentValidator
@@ -54,6 +56,7 @@ import com.jetbrains.gateway.ssh.IdeWithStatus
54
56
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
55
57
import com.jetbrains.gateway.ssh.deploy.DeployException
56
58
import com.jetbrains.gateway.ssh.util.validateRemotePath
59
+ import com.jetbrains.rd.generator.nova.PredefinedType
57
60
import kotlinx.coroutines.CoroutineScope
58
61
import kotlinx.coroutines.Dispatchers
59
62
import kotlinx.coroutines.Job
@@ -79,6 +82,13 @@ import javax.swing.ListCellRenderer
79
82
import javax.swing.SwingConstants
80
83
import javax.swing.event.DocumentEvent
81
84
85
+ // Just extracting the way we display the IDE info into a helper function.
86
+ private fun displayIdeWithStatus (ideWithStatus : IdeWithStatus ): String {
87
+ return " ${ideWithStatus.product.productCode} ${ideWithStatus.presentableVersion} ${ideWithStatus.buildNumber} | ${ideWithStatus.status.name.lowercase(
88
+ Locale .getDefault(),
89
+ )} "
90
+ }
91
+
82
92
/* *
83
93
* View for a single workspace. In particular, show available IDEs and a button
84
94
* to select an IDE and project to run on the workspace.
@@ -88,6 +98,8 @@ class CoderWorkspaceProjectIDEStepView(
88
98
) : CoderWizardStep<WorkspaceProjectIDE>(
89
99
CoderGatewayBundle .message("gateway.connector.view.coder.remoteproject.next.text"),
90
100
) {
101
+ private val settings: CoderSettingsService = service<CoderSettingsService >()
102
+
91
103
private val cs = CoroutineScope (Dispatchers .IO )
92
104
private var ideComboBoxModel = DefaultComboBoxModel <IdeWithStatus >()
93
105
private var state: CoderWorkspacesStepSelection ? = null
@@ -258,9 +270,24 @@ class CoderWorkspaceProjectIDEStepView(
258
270
)
259
271
},
260
272
)
273
+
274
+ // Check the provided setting to see if there's a default IDE to set.
275
+ val defaultIde = ides.find { it ->
276
+ // Using contains on the displayable version of the ide means they can be as specific or as vague as they want
277
+ // CL 2023.3.6 233.15619.8 -> a specific Clion build
278
+ // CL 2023.3.6 -> a specific Clion version
279
+ // 2023.3.6 -> a specific version (some customers will on have one specific IDE in their list anyway)
280
+ if (settings.defaultIde.isEmpty()) {
281
+ false
282
+ } else {
283
+ displayIdeWithStatus(it).contains(settings.defaultIde)
284
+ }
285
+ }
286
+ val index = ides.indexOf(defaultIde ? : ides.firstOrNull())
287
+
261
288
withContext(Dispatchers .IO ) {
262
289
ideComboBoxModel.addAll(ides)
263
- cbIDE.selectedIndex = 0
290
+ cbIDE.selectedIndex = index
264
291
}
265
292
} catch (e: Exception ) {
266
293
if (isCancellation(e)) {
@@ -456,10 +483,9 @@ class CoderWorkspaceProjectIDEStepView(
456
483
layout = FlowLayout (FlowLayout .LEFT )
457
484
add(JLabel (ideWithStatus.product.ideName, ideWithStatus.product.icon, SwingConstants .LEFT ))
458
485
add(
459
- JLabel (
460
- " ${ideWithStatus.product.productCode} ${ideWithStatus.presentableVersion} ${ideWithStatus.buildNumber} | ${ideWithStatus.status.name.lowercase(
461
- Locale .getDefault(),
462
- )} " ,
486
+ JLabel (displayIdeWithStatus(
487
+ ideWithStatus
488
+ ),
463
489
).apply {
464
490
foreground = UIUtil .getLabelDisabledForeground()
465
491
},
0 commit comments