@@ -7,9 +7,15 @@ import com.intellij.openapi.project.Project
7
7
import com.intellij.openapi.ui.DialogPanel
8
8
import com.intellij.ui.SimpleListCellRenderer
9
9
import com.intellij.ui.components.JBRadioButton
10
- import com.intellij.ui.layout.GrowPolicy
10
+ import com.intellij.ui.dsl.builder.Align
11
+ import com.intellij.ui.dsl.builder.AlignX
12
+ import com.intellij.ui.dsl.builder.BottomGap
13
+ import com.intellij.ui.dsl.builder.bindIntText
14
+ import com.intellij.ui.dsl.builder.bindItem
15
+ import com.intellij.ui.dsl.builder.bindText
16
+ import com.intellij.ui.dsl.builder.columns
17
+ import com.intellij.ui.dsl.builder.panel
11
18
import com.intellij.ui.layout.or
12
- import com.intellij.ui.layout.panel
13
19
import com.intellij.ui.layout.selected
14
20
import software.amazon.awssdk.services.apprunner.model.ConnectionSummary
15
21
import software.amazon.awssdk.services.apprunner.model.Runtime
@@ -25,7 +31,6 @@ import software.aws.toolkits.jetbrains.ui.KeyValueTextField
25
31
import software.aws.toolkits.jetbrains.ui.ResourceSelector
26
32
import software.aws.toolkits.jetbrains.ui.intTextField
27
33
import software.aws.toolkits.jetbrains.utils.toHumanReadable
28
- import software.aws.toolkits.jetbrains.utils.ui.contextualHelp
29
34
import software.aws.toolkits.jetbrains.utils.ui.installOnParent
30
35
import software.aws.toolkits.jetbrains.utils.ui.selected
31
36
import software.aws.toolkits.jetbrains.utils.ui.visibleIf
@@ -90,20 +95,23 @@ class CreationPanel(private val project: Project, ecrUri: String? = null) {
90
95
91
96
val imagePanel = panel {
92
97
row(message(" apprunner.creation.panel.image.uri" )) {
93
- textField(::containerUri )
98
+ textField()
94
99
.apply { component.emptyText.text = " 111111111111.dkr.ecr.us-east-1.amazonaws.com/name:tag" }
95
- .withErrorOnApplyIf(message(" apprunner.creation.panel.image.uri.missing" )) { it.text.isBlank() }
96
- .constraints(pushX)
100
+ .bindText(::containerUri)
101
+ .errorOnApply(message(" apprunner.creation.panel.image.uri.missing" )) { it.text.isBlank() }
102
+ .align(AlignX .FILL )
97
103
}
98
104
99
105
row(message(" apprunner.creation.panel.start_command" )) {
100
- textField({ startCommand ? : " " }, { startCommand = it } )
106
+ textField()
101
107
.apply { component.toolTipText = message(" apprunner.creation.panel.start_command.image.tooltip" ) }
102
- .constraints(pushX)
108
+ .bindText({ startCommand ? : " " }, { startCommand = it })
109
+ .align(AlignX .FILL )
103
110
}
104
111
105
112
row(message(" apprunner.creation.panel.port" )) {
106
- intTextField(::port, range = IntRange (1 , 65535 ))
113
+ intTextField(range = IntRange (1 , 65535 )).bindIntText(::port)
114
+ .align(AlignX .FILL )
107
115
}
108
116
109
117
row {
@@ -120,10 +128,10 @@ class CreationPanel(private val project: Project, ecrUri: String? = null) {
120
128
selectedItem { it.name == APPRUNNER_ECR_DEFAULT_ROLE_NAME }
121
129
toolTipText = message(" apprunner.creation.panel.image.access_role.tooltip" )
122
130
}
123
- ecrPolicy(grow)
124
- .growPolicy(GrowPolicy .MEDIUM_TEXT )
125
- .withErrorOnApplyIf(message(" apprunner.creation.panel.image.access_role.missing" )) { it.selected() == null }
131
+ cell(ecrPolicy)
132
+ .errorOnApply(message(" apprunner.creation.panel.image.access_role.missing" )) { it.selected() == null && ecr.isSelected }
126
133
.visibleIf(ecr.selected)
134
+ .columns(40 )
127
135
button(message(" general.create_button" )) {
128
136
val iamRoleDialog = CreateIamServiceRoleDialog (
129
137
project,
@@ -142,128 +150,126 @@ class CreationPanel(private val project: Project, ecrUri: String? = null) {
142
150
}
143
151
row {
144
152
label(message(" apprunner.creation.panel.cpu" ))
145
- comboBox(DefaultComboBoxModel (CreationPanel .cpuValues.toTypedArray()), { cpu }, { it?.let { cpu = it } })
146
- .withErrorOnApplyIf( message(" apprunner.creation.panel.cpu.missing" )) { it.selected() == null }
147
- .constraints(pushX, growX)
153
+ comboBox(DefaultComboBoxModel (CreationPanel .cpuValues.toTypedArray())).bindItem( { cpu }, { it?.let { cpu = it } }).errorOnApply(
154
+ message(" apprunner.creation.panel.cpu.missing" )
155
+ ) { it.selected() == null }
148
156
label(message(" apprunner.creation.panel.memory" ))
149
- comboBox(DefaultComboBoxModel (CreationPanel .memoryValues.toTypedArray()), { memory }, { it?.let { memory = it } })
150
- .withErrorOnApplyIf(message(" apprunner.creation.panel.memory.missing" )) { it.selected() == null }
151
- .constraints(pushX, growX)
157
+ comboBox(DefaultComboBoxModel (CreationPanel .memoryValues.toTypedArray())).bindItem({ memory }, { it?.let { memory = it } })
158
+ .errorOnApply(message(" apprunner.creation.panel.memory.missing" )) { it.selected() == null }
152
159
}
153
160
}
154
161
155
162
val repoSettings = panel {
156
163
row(message(" apprunner.creation.panel.repository.runtime" )) {
157
- comboBox(DefaultComboBoxModel (Runtime .knownValues().toTypedArray()), { runtime }, { runtime = it })
164
+ comboBox(DefaultComboBoxModel (Runtime .knownValues().toTypedArray())).bindItem( { runtime }, { runtime = it })
158
165
.apply {
159
166
component.toolTipText = message(" apprunner.creation.panel.repository.runtime.tooltip" )
160
167
component.renderer = SimpleListCellRenderer .create(" " ) { it?.toString()?.toHumanReadable() }
161
168
}
162
- .withErrorOnApplyIf(message(" apprunner.creation.panel.repository.runtime.missing" )) { it.selected() == null }
163
- .constraints(pushX, growX)
169
+ .errorOnApply(message(" apprunner.creation.panel.repository.runtime.missing" )) { it.selected() == null }
170
+ .columns(35 )
171
+
164
172
label(message(" apprunner.creation.panel.port" ))
165
- intTextField(::port, range = IntRange (1 , 65535 ))
173
+ intTextField(range = IntRange (1 , 65535 )).bindIntText(::port )
166
174
}
167
175
row(message(" apprunner.creation.panel.repository.build_command" )) {
168
- textField(::buildCommand)
176
+ textField().bindText( ::buildCommand)
169
177
.apply { component.toolTipText = message(" apprunner.creation.panel.repository.build_command.tooltip" ) }
170
- .withErrorOnApplyIf(message(" apprunner.creation.panel.repository.build_command.missing" )) { it.text.isBlank() }
171
- .constraints(pushX, growX)
178
+ .errorOnApply(message(" apprunner.creation.panel.repository.build_command.missing" )) { it.text.isBlank() }
179
+ .resizableColumn()
180
+ .align(Align .FILL )
172
181
}
173
182
row(message(" apprunner.creation.panel.start_command" )) {
174
- textField({ startCommand ? : " " }, { startCommand = it })
183
+ textField().bindText( { startCommand ? : " " }, { startCommand = it })
175
184
.apply { component.toolTipText = message(" apprunner.creation.panel.start_command.repo.tooltip" ) }
176
- .withErrorOnApplyIf(message(" apprunner.creation.panel.start_command.missing" )) { it.text.isBlank() }
177
- .constraints(pushX, growX)
178
- }.largeGapAfter()
185
+ .errorOnApply(message(" apprunner.creation.panel.start_command.missing" )) { it.text.isBlank() }
186
+ .resizableColumn()
187
+ .align(Align .FILL )
188
+ }.bottomGap(BottomGap .MEDIUM )
179
189
}
180
190
181
191
val repoPanel = panel {
182
- row(message( " apprunner.creation.panel.repository.connection " )) {
183
- cell(isFullWidth = true ) {
184
- connection = ResourceSelector .builder()
185
- .resource { AppRunnerResources .LIST_CONNECTIONS }
186
- .customRenderer(SimpleListCellRenderer .create(" " ) { " ${it.connectionName()} (${it.providerTypeAsString().toHumanReadable()} )" })
187
- .awsConnection(project)
188
- .build()
189
- connection(growX, pushX )
190
- .withErrorOnApplyIf (message(" apprunner.creation.panel.repository.connection.missing" )) { it.isLoading || it.selected() == null }
191
- contextualHelp(message( " apprunner.creation.panel.repository.connection.help " ) )
192
- }
193
- }
192
+ row {
193
+ label(message( " apprunner.creation.panel.repository.connection " ))
194
+ connection = ResourceSelector .builder()
195
+ .resource { AppRunnerResources .LIST_CONNECTIONS }
196
+ .customRenderer(SimpleListCellRenderer .create(" " ) { " ${it.connectionName()} (${it.providerTypeAsString().toHumanReadable()} )" })
197
+ .awsConnection(project)
198
+ .build()
199
+ cell(connection )
200
+ .errorOnApply (message(" apprunner.creation.panel.repository.connection.missing" )) { it.isLoading || it.selected() == null }
201
+ .resizableColumn( )
202
+ .align( Align . FILL )
203
+ }.contextHelp(message( " apprunner.creation.panel.repository.connection.help " ))
194
204
row {
195
205
label(message(" apprunner.creation.panel.repository.url" )).apply {
196
206
component.toolTipText = message(" apprunner.creation.panel.repository.url.tooltip" )
197
207
}
198
- textField(::repository, columns = 20 ).constraints(growX )
208
+ textField().bindText( ::repository).columns( 20 )
199
209
label(message(" apprunner.creation.panel.repository.branch" ))
200
- textField(::branch, columns = 15 ).constraints(growX )
210
+ textField().bindText( ::branch).columns( 15 )
201
211
}
202
- row(message(" apprunner.creation.panel.repository.configuration" )) {
203
- buttonGroup {
204
- cell(isFullWidth = true ) {
205
- repoConfigFromSettings()
206
- repoConfigFromFile()
207
- }
212
+ buttonsGroup {
213
+ row(message(" apprunner.creation.panel.repository.configuration" )) {
214
+ cell(repoConfigFromSettings)
215
+ cell(repoConfigFromFile)
208
216
}
209
217
}
218
+
210
219
row {
211
- repoSettings(growX )
220
+ cell(repoSettings )
212
221
.installOnParent { repoConfigFromSettings.isSelected }
213
222
.visibleIf(repoConfigFromSettings.selected)
214
223
}
215
224
row {
216
225
label(message(" apprunner.creation.panel.cpu" ))
217
- comboBox(DefaultComboBoxModel (CreationPanel .cpuValues.toTypedArray()), { cpu }, { it?.let { cpu = it } })
218
- .withErrorOnApplyIf (message(" apprunner.creation.panel.cpu.missing" )) { it.selected() == null }
219
- .constraints(pushX, growX )
226
+ comboBox(DefaultComboBoxModel (CreationPanel .cpuValues.toTypedArray())).bindItem( { cpu }, { it?.let { cpu = it } })
227
+ .errorOnApply (message(" apprunner.creation.panel.cpu.missing" )) { it.selected() == null }
228
+ .resizableColumn().align( Align . FILL )
220
229
label(message(" apprunner.creation.panel.memory" ))
221
- comboBox(DefaultComboBoxModel (CreationPanel .memoryValues.toTypedArray()), { memory }, { it?.let { memory = it } })
222
- .withErrorOnApplyIf(message(" apprunner.creation.panel.memory.missing" )) { it.selected() == null }
223
- .constraints(pushX, growX)
230
+ comboBox(DefaultComboBoxModel (CreationPanel .memoryValues.toTypedArray())).bindItem({ memory }, { it?.let { memory = it } })
231
+ .errorOnApply(message(" apprunner.creation.panel.memory.missing" )) { it.selected() == null }
224
232
}
225
233
}
226
234
227
235
val component: DialogPanel = panel {
228
236
row(message(" apprunner.creation.panel.name" )) {
229
- textField(::name)
230
- .withErrorOnApplyIf (message(" apprunner.creation.panel.name.missing" )) { it.text.isNullOrBlank() }
231
- .constraints(pushX )
237
+ textField().bindText( ::name)
238
+ .errorOnApply (message(" apprunner.creation.panel.name.missing" )) { it.text.isNullOrBlank() }
239
+ .columns( 40 )
232
240
}
233
- row(message(" apprunner.creation.panel.source" )) {
234
- buttonGroup {
235
- cell {
236
- ecr()
237
- ecrPublic()
238
- repo()
239
- }
241
+ buttonsGroup {
242
+ row(message(" apprunner.creation.panel.source" )) {
243
+ cell(ecr)
244
+ cell(ecrPublic)
245
+ cell(repo)
240
246
}
241
247
}
242
- row(message(" apprunner.creation.panel.deployment" )) {
248
+
249
+ buttonsGroup {
243
250
// ECR public disables selecting deployment options
244
- buttonGroup {
245
- cell {
246
- manualDeployment()
247
- automaticDeployment()
248
- }
251
+ row(message(" apprunner.creation.panel.deployment" )) {
252
+ cell(manualDeployment)
253
+ cell(automaticDeployment)
249
254
}
250
255
}.visibleIf(ecr.selected.or (repo.selected))
256
+
251
257
row {
252
- subRowIndent = 0
253
- cell(isFullWidth = true ) {
254
- // TODO HACK making this flow right means we don't have issues with weird spacing above or
255
- // to the left
256
- repoPanel(grow)
257
- .installOnParent { repo.isSelected }
258
- .visibleIf(repo.selected)
258
+ cell(repoPanel)
259
+ .installOnParent { repo.isSelected }
260
+ .visibleIf(repo.selected)
261
+ .resizableColumn()
262
+ .align(Align .FILL )
259
263
260
- imagePanel(grow)
261
- .installOnParent { ecr.isSelected || ecrPublic.isSelected }
262
- .visibleIf(ecr.selected.or (ecrPublic.selected))
263
- }
264
+ cell(imagePanel)
265
+ .installOnParent { ecr.isSelected || ecrPublic.isSelected }
266
+ .visibleIf(ecr.selected.or (ecrPublic.selected))
267
+ .resizableColumn()
268
+ .align(Align .FILL )
264
269
}
265
270
row(message(" apprunner.creation.panel.environment" )) {
266
- environmentVariables(growX)
271
+ cell(environmentVariables)
272
+ .resizableColumn().align(Align .FILL )
267
273
}
268
274
}
269
275
}
0 commit comments