Skip to content

Commit 4a1902c

Browse files
authored
Migrate from ui dsl v1 to v2 -6 (#3841)
* modified dialog * feedback changes * addressed feedback
1 parent 50b84fb commit 4a1902c

File tree

1 file changed

+31
-39
lines changed

1 file changed

+31
-39
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/services/ecr/actions/PushToRepositoryAction.kt

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ import com.intellij.ui.components.JBRadioButton
2727
import com.intellij.ui.components.fields.ExtendableTextComponent
2828
import com.intellij.ui.components.fields.ExtendableTextField
2929
import com.intellij.ui.dsl.builder.COLUMNS_MEDIUM
30+
import com.intellij.ui.dsl.builder.bindItem
3031
import com.intellij.ui.dsl.builder.bindText
3132
import com.intellij.ui.dsl.builder.columns
33+
import com.intellij.ui.dsl.builder.panel
3234
import com.intellij.ui.dsl.builder.toMutableProperty
33-
import com.intellij.ui.layout.GrowPolicy
35+
import com.intellij.ui.dsl.builder.toNullableProperty
3436
import com.intellij.ui.layout.applyToComponent
3537
import com.intellij.ui.layout.listCellRenderer
36-
import com.intellij.ui.layout.panel
3738
import com.intellij.ui.layout.selected
3839
import com.intellij.util.text.nullize
3940
import kotlinx.coroutines.Deferred
@@ -68,7 +69,6 @@ import software.aws.toolkits.telemetry.EcrTelemetry
6869
import software.aws.toolkits.telemetry.Result
6970
import javax.swing.JTextField
7071
import javax.swing.plaf.basic.BasicComboBoxEditor
71-
import com.intellij.ui.dsl.builder.panel as panelv2
7272

7373
class PushToRepositoryAction : EcrDockerAction() {
7474
override fun actionPerformed(selected: EcrRepositoryNode, e: AnActionEvent) {
@@ -157,7 +157,7 @@ internal class PushToEcrDialog(
157157
}
158158
}
159159

160-
override fun createCenterPanel() = panelv2 {
160+
override fun createCenterPanel() = panel {
161161
// valid tag is ascii letters, numbers, underscores, periods, or dashes
162162
// https://docs.docker.com/engine/reference/commandline/tag/#extended-description
163163
val validTagRegex = "[a-zA-Z0-9_.-]{1,128}".toRegex()
@@ -203,54 +203,46 @@ internal class PushToEcrDialog(
203203

204204
private fun localImageSelectorPanel() = panel {
205205
row(message("ecr.push.source")) {
206-
// property binding syntax causes kotlin compiler error for some reason
207206
comboBox(
208207
localImageRepoTags,
209-
{ localImage },
210-
{ ::localImage.set(it) },
211208
listCellRenderer { value, _, _ ->
212209
text = value.tag ?: value.imageId.take(15)
213210
}
214-
)
211+
).bindItem(::localImage.toNullableProperty())
215212
.applyToComponent { ComboboxSpeedSearch(this) }
216-
.growPolicy(GrowPolicy.MEDIUM_TEXT)
217-
.withErrorOnApplyIf(message("ecr.image.not_selected")) { it.selected() == null }
213+
.errorOnApply(message("ecr.image.not_selected")) { it.selected() == null }
214+
.columns(30) // The size of the entire dialog is doubling if specific columns are not set for this component
218215
}
219216
}
220217

221218
private fun dockerfileConfigurationSelectorPanel() = panel {
222219
row(message("ecr.dockerfile.configuration.label")) {
223-
cell {
224-
val model = CollectionComboBoxModel<DockerRunConfiguration>()
225-
rebuildRunConfigurationComboBoxModel(model)
226-
comboBox(
227-
model,
228-
{ runConfiguration },
229-
{ ::runConfiguration.set(it) },
230-
listCellRenderer { value, _, _ ->
231-
icon = value.icon
232-
text = value.name
233-
}
234-
)
235-
.applyToComponent {
236-
// TODO: how do we render both the Docker icon and action items correctly?
237-
isEditable = true
238-
editor = object : BasicComboBoxEditor.UIResource() {
239-
override fun createEditorComponent(): JTextField {
240-
val textField = ExtendableTextField()
241-
textField.isEditable = false
242-
243-
buildDockerfileActions(model, textField)
244-
textField.border = null
245-
246-
return textField
247-
}
220+
val model = CollectionComboBoxModel<DockerRunConfiguration>()
221+
rebuildRunConfigurationComboBoxModel(model)
222+
comboBox(
223+
model,
224+
listCellRenderer { value, _, _ ->
225+
icon = value.icon
226+
text = value.name
227+
}
228+
).bindItem(::runConfiguration.toNullableProperty())
229+
.applyToComponent {
230+
// TODO: how do we render both the Docker icon and action items correctly?
231+
isEditable = true
232+
editor = object : BasicComboBoxEditor.UIResource() {
233+
override fun createEditorComponent(): JTextField {
234+
val textField = ExtendableTextField()
235+
textField.isEditable = false
236+
237+
buildDockerfileActions(model, textField)
238+
textField.border = null
239+
240+
return textField
248241
}
249242
}
250-
.growPolicy(GrowPolicy.MEDIUM_TEXT)
251-
.withErrorOnApplyIf(message("ecr.dockerfile.configuration.invalid")) { it.selected() == null }
252-
.withErrorOnApplyIf(message("ecr.dockerfile.configuration.invalid_server")) { it.selected()?.serverName == null }
253-
}
243+
}
244+
.errorOnApply(message("ecr.dockerfile.configuration.invalid")) { it.selected() == null }
245+
.errorOnApply(message("ecr.dockerfile.configuration.invalid_server")) { it.selected()?.serverName == null }
254246
}
255247
}
256248

0 commit comments

Comments
 (0)