@@ -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
@@ -79,6 +81,11 @@ import javax.swing.ListCellRenderer
79
81
import javax.swing.SwingConstants
80
82
import javax.swing.event.DocumentEvent
81
83
84
+ // Just extracting the way we display the IDE info into a helper function.
85
+ private fun displayIdeWithStatus (ideWithStatus : IdeWithStatus ): String = " ${ideWithStatus.product.productCode} ${ideWithStatus.presentableVersion} ${ideWithStatus.buildNumber} | ${ideWithStatus.status.name.lowercase(
86
+ Locale .getDefault(),
87
+ )} "
88
+
82
89
/* *
83
90
* View for a single workspace. In particular, show available IDEs and a button
84
91
* to select an IDE and project to run on the workspace.
@@ -88,6 +95,8 @@ class CoderWorkspaceProjectIDEStepView(
88
95
) : CoderWizardStep<WorkspaceProjectIDE>(
89
96
CoderGatewayBundle .message("gateway.connector.view.coder.remoteproject.next.text"),
90
97
) {
98
+ private val settings: CoderSettingsService = service<CoderSettingsService >()
99
+
91
100
private val cs = CoroutineScope (Dispatchers .IO )
92
101
private var ideComboBoxModel = DefaultComboBoxModel <IdeWithStatus >()
93
102
private var state: CoderWorkspacesStepSelection ? = null
@@ -258,9 +267,24 @@ class CoderWorkspaceProjectIDEStepView(
258
267
)
259
268
},
260
269
)
270
+
271
+ // Check the provided setting to see if there's a default IDE to set.
272
+ val defaultIde = ides.find { it ->
273
+ // Using contains on the displayable version of the ide means they can be as specific or as vague as they want
274
+ // CL 2023.3.6 233.15619.8 -> a specific Clion build
275
+ // CL 2023.3.6 -> a specific Clion version
276
+ // 2023.3.6 -> a specific version (some customers will only have one specific IDE in their list anyway)
277
+ if (settings.defaultIde.isEmpty()) {
278
+ false
279
+ } else {
280
+ displayIdeWithStatus(it).contains(settings.defaultIde)
281
+ }
282
+ }
283
+ val index = ides.indexOf(defaultIde ? : ides.firstOrNull())
284
+
261
285
withContext(Dispatchers .IO ) {
262
286
ideComboBoxModel.addAll(ides)
263
- cbIDE.selectedIndex = 0
287
+ cbIDE.selectedIndex = index
264
288
}
265
289
} catch (e: Exception ) {
266
290
if (isCancellation(e)) {
@@ -457,9 +481,9 @@ class CoderWorkspaceProjectIDEStepView(
457
481
add(JLabel (ideWithStatus.product.ideName, ideWithStatus.product.icon, SwingConstants .LEFT ))
458
482
add(
459
483
JLabel (
460
- " ${ideWithStatus.product.productCode} ${ideWithStatus.presentableVersion} ${ideWithStatus.buildNumber} | ${ideWithStatus.status.name.lowercase (
461
- Locale .getDefault() ,
462
- )} " ,
484
+ displayIdeWithStatus (
485
+ ideWithStatus ,
486
+ ),
463
487
).apply {
464
488
foreground = UIUtil .getLabelDisabledForeground()
465
489
},
0 commit comments