Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd27a65e

Browse files
authored
Initial impl of defaultIde selection setting (#522)
defaultIde selection setting
1 parentfaddd24 commitd27a65e

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

‎CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
##Unreleased
66

7+
###Added
8+
9+
- Added setting "Default IDE Selection" which will look for a matching IDE
10+
code/version/build number to set as the preselected IDE in the select
11+
component.
12+
713
##2.15.2 - 2025-01-06
814

915
###Changed

‎src/main/kotlin/com/coder/gateway/CoderSettingsConfigurable.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ class CoderSettingsConfigurable : BoundConfigurable("Coder") {
149149
.bindText(state::workspaceFilter)
150150
.comment(CoderGatewayBundle.message("gateway.connector.settings.workspace-filter.comment"))
151151
}.layout(RowLayout.PARENT_GRID)
152+
row(CoderGatewayBundle.message("gateway.connector.settings.default-ide")) {
153+
textField().resizableColumn().align(AlignX.FILL)
154+
.bindText(state::defaultIde)
155+
.comment(
156+
"The default IDE version to display in the IDE selection dropdown."+
157+
"Example format: CL 2023.3.6 233.15619.8",
158+
)
159+
}
152160
}
153161
}
154162

‎src/main/kotlin/com/coder/gateway/settings/CoderSettings.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ open class CoderSettingsState(
100100
openvarsshLogDirectory:String ="",
101101
// Default filter for fetching workspaces
102102
openvarworkspaceFilter:String ="owner:me",
103+
// Default version of IDE to display in IDE selection dropdown
104+
openvardefaultIde:String ="",
103105
)
104106

105107
/**
@@ -174,6 +176,12 @@ open class CoderSettings(
174176
val setupCommand:String
175177
get()= state.setupCommand
176178

179+
/**
180+
* The default IDE version to display in the selection menu
181+
*/
182+
val defaultIde:String
183+
get()= state.defaultIde
184+
177185
/**
178186
* Whether to ignore a failed setup command.
179187
*/

‎src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspaceProjectIDEStepView.kt

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.coder.gateway.models.toIdeWithStatus
88
importcom.coder.gateway.models.withWorkspaceProject
99
importcom.coder.gateway.sdk.v2.models.Workspace
1010
importcom.coder.gateway.sdk.v2.models.WorkspaceAgent
11+
importcom.coder.gateway.services.CoderSettingsService
1112
importcom.coder.gateway.util.Arch
1213
importcom.coder.gateway.util.OS
1314
importcom.coder.gateway.util.humanizeDuration
@@ -20,6 +21,7 @@ import com.coder.gateway.views.LazyBrowserLink
2021
importcom.intellij.openapi.application.ApplicationManager
2122
importcom.intellij.openapi.application.ModalityState
2223
importcom.intellij.openapi.application.asContextElement
24+
importcom.intellij.openapi.components.service
2325
importcom.intellij.openapi.diagnostic.Logger
2426
importcom.intellij.openapi.ui.ComboBox
2527
importcom.intellij.openapi.ui.ComponentValidator
@@ -79,6 +81,11 @@ import javax.swing.ListCellRenderer
7981
importjavax.swing.SwingConstants
8082
importjavax.swing.event.DocumentEvent
8183

84+
// Just extracting the way we display the IDE info into a helper function.
85+
privatefundisplayIdeWithStatus(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+
privateval settings:CoderSettingsService= service<CoderSettingsService>()
99+
91100
privateval cs=CoroutineScope(Dispatchers.IO)
92101
privatevar ideComboBoxModel=DefaultComboBoxModel<IdeWithStatus>()
93102
privatevar 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
},

‎src/main/resources/messages/CoderGatewayBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ gateway.connector.settings.workspace-filter.comment=The filter to apply when \
138138
the plugin fetches resources individually for each non-running workspace, \
139139
which can be slow with many workspaces, and it adds every agent to the SSH \
140140
config, which can result in a large SSH config with many workspaces.
141+
gateway.connector.settings.default-ide=Default IDE Selection

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp