@@ -8,6 +8,7 @@ import com.coder.gateway.models.toIdeWithStatus
88import com.coder.gateway.models.withWorkspaceProject
99import com.coder.gateway.sdk.v2.models.Workspace
1010import com.coder.gateway.sdk.v2.models.WorkspaceAgent
11+ import com.coder.gateway.services.CoderSettingsService
1112import com.coder.gateway.util.Arch
1213import com.coder.gateway.util.OS
1314import com.coder.gateway.util.humanizeDuration
@@ -20,6 +21,7 @@ import com.coder.gateway.views.LazyBrowserLink
2021import com.intellij.openapi.application.ApplicationManager
2122import com.intellij.openapi.application.ModalityState
2223import com.intellij.openapi.application.asContextElement
24+ import com.intellij.openapi.components.service
2325import com.intellij.openapi.diagnostic.Logger
2426import com.intellij.openapi.ui.ComboBox
2527import com.intellij.openapi.ui.ComponentValidator
@@ -79,6 +81,11 @@ import javax.swing.ListCellRenderer
7981import javax.swing.SwingConstants
8082import javax.swing.event.DocumentEvent
8183
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+
8289/* *
8390 * View for a single workspace. In particular, show available IDEs and a button
8491 * to select an IDE and project to run on the workspace.
@@ -88,6 +95,8 @@ class CoderWorkspaceProjectIDEStepView(
8895) : CoderWizardStep<WorkspaceProjectIDE>(
8996 CoderGatewayBundle .message("gateway.connector.view.coder.remoteproject.next.text"),
9097) {
98+ private val settings: CoderSettingsService = service<CoderSettingsService >()
99+
91100 private val cs = CoroutineScope (Dispatchers .IO )
92101 private var ideComboBoxModel = DefaultComboBoxModel <IdeWithStatus >()
93102 private var state: CoderWorkspacesStepSelection ? = null
@@ -258,9 +267,24 @@ class CoderWorkspaceProjectIDEStepView(
258267 )
259268 },
260269 )
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+
261285 withContext(Dispatchers .IO ) {
262286 ideComboBoxModel.addAll(ides)
263- cbIDE.selectedIndex = 0
287+ cbIDE.selectedIndex = index
264288 }
265289 } catch (e: Exception ) {
266290 if (isCancellation(e)) {
@@ -457,9 +481,9 @@ class CoderWorkspaceProjectIDEStepView(
457481 add(JLabel (ideWithStatus.product.ideName, ideWithStatus.product.icon, SwingConstants .LEFT ))
458482 add(
459483 JLabel (
460- " ${ideWithStatus.product.productCode} ${ideWithStatus.presentableVersion} ${ideWithStatus.buildNumber} | ${ideWithStatus.status.name.lowercase (
461- Locale .getDefault() ,
462- )} " ,
484+ displayIdeWithStatus (
485+ ideWithStatus ,
486+ ),
463487 ).apply {
464488 foreground = UIUtil .getLabelDisabledForeground()
465489 },
0 commit comments