-
Notifications
You must be signed in to change notification settings - Fork 15
Initial impl of defaultIde selection setting #522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import com.coder.gateway.models.withWorkspaceProject | ||
import com.coder.gateway.sdk.v2.models.Workspace | ||
import com.coder.gateway.sdk.v2.models.WorkspaceAgent | ||
import com.coder.gateway.services.CoderSettingsService | ||
import com.coder.gateway.util.Arch | ||
import com.coder.gateway.util.OS | ||
import com.coder.gateway.util.humanizeDuration | ||
|
@@ -20,6 +21,7 @@ | |
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.application.ModalityState | ||
import com.intellij.openapi.application.asContextElement | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.diagnostic.Logger | ||
import com.intellij.openapi.ui.ComboBox | ||
import com.intellij.openapi.ui.ComponentValidator | ||
|
@@ -54,6 +56,7 @@ | |
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct | ||
import com.jetbrains.gateway.ssh.deploy.DeployException | ||
import com.jetbrains.gateway.ssh.util.validateRemotePath | ||
import com.jetbrains.rd.generator.nova.PredefinedType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably already see the warning but appears to be unused (I think |
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.Job | ||
|
@@ -79,6 +82,13 @@ | |
import javax.swing.SwingConstants | ||
import javax.swing.event.DocumentEvent | ||
|
||
// Just extracting the way we display the IDE info into a helper function. | ||
private fun displayIdeWithStatus(ideWithStatus: IdeWithStatus): String { | ||
return "${ideWithStatus.product.productCode} ${ideWithStatus.presentableVersion} ${ideWithStatus.buildNumber} | ${ideWithStatus.status.name.lowercase( | ||
Locale.getDefault(), | ||
)}" | ||
} | ||
|
||
/** | ||
* View for a single workspace. In particular, show available IDEs and a button | ||
* to select an IDE and project to run on the workspace. | ||
|
@@ -88,6 +98,8 @@ | |
) : CoderWizardStep<WorkspaceProjectIDE>( | ||
CoderGatewayBundle.message("gateway.connector.view.coder.remoteproject.next.text"), | ||
) { | ||
private val settings: CoderSettingsService = service<CoderSettingsService>() | ||
|
||
private val cs = CoroutineScope(Dispatchers.IO) | ||
private var ideComboBoxModel = DefaultComboBoxModel<IdeWithStatus>() | ||
private var state: CoderWorkspacesStepSelection? = null | ||
|
@@ -258,9 +270,24 @@ | |
) | ||
}, | ||
) | ||
|
||
// Check the provided setting to see if there's a default IDE to set. | ||
val defaultIde = ides.find { it -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Qodana will complain about Tangent, but I think there is an alias for Anyway, no need to change to those, more that I nerd sniped myself. 😆 |
||
// Using contains on the displayable version of the ide means they can be as specific or as vague as they want | ||
// CL 2023.3.6 233.15619.8 -> a specific Clion build | ||
// CL 2023.3.6 -> a specific Clion version | ||
// 2023.3.6 -> a specific version (some customers will on have one specific IDE in their list anyway) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo I think in |
||
if (settings.defaultIde.isEmpty()) { | ||
false | ||
} else { | ||
displayIdeWithStatus(it).contains(settings.defaultIde) | ||
} | ||
} | ||
val index = ides.indexOf(defaultIde ?: ides.firstOrNull()) | ||
|
||
withContext(Dispatchers.IO) { | ||
ideComboBoxModel.addAll(ides) | ||
cbIDE.selectedIndex = 0 | ||
cbIDE.selectedIndex = index | ||
} | ||
} catch (e: Exception) { | ||
if (isCancellation(e)) { | ||
|
@@ -456,10 +483,9 @@ | |
layout = FlowLayout(FlowLayout.LEFT) | ||
add(JLabel(ideWithStatus.product.ideName, ideWithStatus.product.icon, SwingConstants.LEFT)) | ||
add( | ||
JLabel( | ||
"${ideWithStatus.product.productCode} ${ideWithStatus.presentableVersion} ${ideWithStatus.buildNumber} | ${ideWithStatus.status.name.lowercase( | ||
Locale.getDefault(), | ||
)}", | ||
JLabel(displayIdeWithStatus( | ||
ideWithStatus | ||
), | ||
).apply { | ||
foreground = UIUtil.getLabelDisabledForeground() | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need to make mention that JetBrains by default only shows the latest version (latest stable and latest EAP I think, right?), so as soon as JetBrains updates their list this setting may become obsolete unless they are using just the IDE name or year.
But, maybe this option will only be used by folks that have provided their own list instead of fetching from JetBrains, so that might not be an issue.