@@ -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
@@ -54,6 +56,7 @@ import com.jetbrains.gateway.ssh.IdeWithStatus
5456import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
5557import com.jetbrains.gateway.ssh.deploy.DeployException
5658import com.jetbrains.gateway.ssh.util.validateRemotePath
59+ import com.jetbrains.rd.generator.nova.PredefinedType
5760import kotlinx.coroutines.CoroutineScope
5861import kotlinx.coroutines.Dispatchers
5962import kotlinx.coroutines.Job
@@ -79,6 +82,13 @@ import javax.swing.ListCellRenderer
7982import javax.swing.SwingConstants
8083import javax.swing.event.DocumentEvent
8184
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+
8292/* *
8393 * View for a single workspace. In particular, show available IDEs and a button
8494 * to select an IDE and project to run on the workspace.
@@ -88,6 +98,8 @@ class CoderWorkspaceProjectIDEStepView(
8898) : CoderWizardStep<WorkspaceProjectIDE>(
8999 CoderGatewayBundle .message("gateway.connector.view.coder.remoteproject.next.text"),
90100) {
101+ private val settings: CoderSettingsService = service<CoderSettingsService >()
102+
91103 private val cs = CoroutineScope (Dispatchers .IO )
92104 private var ideComboBoxModel = DefaultComboBoxModel <IdeWithStatus >()
93105 private var state: CoderWorkspacesStepSelection ? = null
@@ -258,9 +270,24 @@ class CoderWorkspaceProjectIDEStepView(
258270 )
259271 },
260272 )
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+
261288 withContext(Dispatchers .IO ) {
262289 ideComboBoxModel.addAll(ides)
263- cbIDE.selectedIndex = 0
290+ cbIDE.selectedIndex = index
264291 }
265292 } catch (e: Exception ) {
266293 if (isCancellation(e)) {
@@ -456,10 +483,9 @@ class CoderWorkspaceProjectIDEStepView(
456483 layout = FlowLayout (FlowLayout .LEFT )
457484 add(JLabel (ideWithStatus.product.ideName, ideWithStatus.product.icon, SwingConstants .LEFT ))
458485 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+ ),
463489 ).apply {
464490 foreground = UIUtil .getLabelDisabledForeground()
465491 },
0 commit comments