Skip to content

Commit 9f2b8f4

Browse files
authored
Removing usage of validating panel (#3857)
* removed validating panel * removed validating panel * removed validating panel * input validation * input validation * fixed tests * fixed detekt
1 parent 99b0e85 commit 9f2b8f4

File tree

5 files changed

+46
-437
lines changed

5 files changed

+46
-437
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/core/tools/ToolConfigurable.kt

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,45 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
77
import com.intellij.openapi.options.BoundConfigurable
88
import com.intellij.openapi.options.SearchableConfigurable
99
import com.intellij.openapi.ui.emptyText
10-
import com.intellij.openapi.util.ClearableLazyValue
1110
import com.intellij.ui.components.JBTextField
1211
import com.intellij.ui.dsl.builder.Align
1312
import com.intellij.ui.dsl.builder.bindText
1413
import com.intellij.ui.dsl.builder.panel
1514
import com.intellij.ui.layout.applyToComponent
16-
import software.aws.toolkits.jetbrains.ui.ValidatingPanel
1715
import software.aws.toolkits.resources.message
1816
import java.nio.file.Path
1917

2018
class ToolConfigurable : BoundConfigurable(message("executableCommon.configurable.title")), SearchableConfigurable {
2119
private val settings = ToolSettings.getInstance()
2220
private val manager = ToolManager.getInstance()
23-
private val panel = ClearableLazyValue.create {
24-
ValidatingPanel(
25-
disposable ?: throw RuntimeException("Should never happen as `createPanel` is called after disposable is assigned"),
26-
checkContinuously = false,
27-
contentPanel = panel {
28-
ToolType.EP_NAME.extensionList.forEach { toolType ->
29-
row(toolType.displayName) {
30-
textFieldWithBrowseButton(fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor())
31-
.bindText(
32-
{ settings.getExecutablePath(toolType) ?: "" },
33-
{ settings.setExecutablePath(toolType, it.takeIf { v -> v.isNotBlank() }) }
34-
)
35-
.validationOnApply {
36-
it.textField.text.takeIf { t -> t.isNotBlank() }?.let { path ->
37-
manager.validateCompatability(Path.of(path), toolType).toValidationInfo(toolType, component)
38-
}
39-
}.applyToComponent {
40-
setEmptyText(toolType, textField as JBTextField)
41-
}.resizableColumn()
42-
.align(Align.FILL)
43-
44-
browserLink(message("aws.settings.learn_more"), toolType.documentationUrl())
45-
}
21+
private val panel by lazy {
22+
panel {
23+
ToolType.EP_NAME.extensionList.forEach { toolType ->
24+
row(toolType.displayName) {
25+
textFieldWithBrowseButton(fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor())
26+
.bindText(
27+
{ settings.getExecutablePath(toolType) ?: "" },
28+
{ settings.setExecutablePath(toolType, it.takeIf { v -> v.isNotBlank() }) }
29+
)
30+
.validationOnInput {
31+
it.textField.text.takeIf { t -> t.isNotBlank() }?.let { path ->
32+
manager.validateCompatability(Path.of(path), toolType).toValidationInfo(toolType, component)
33+
}
34+
}.applyToComponent {
35+
setEmptyText(toolType, textField as JBTextField)
36+
}.resizableColumn()
37+
.align(Align.FILL)
38+
39+
browserLink(message("aws.settings.learn_more"), toolType.documentationUrl())
4640
}
47-
},
48-
emptyMap()
49-
)
41+
}
42+
}
5043
}
5144

52-
override fun createPanel() = panel.value.contentPanel
45+
override fun createPanel() = panel
5346

5447
override fun apply() {
55-
panel.value.apply()
56-
}
57-
58-
override fun disposeUIResources() {
59-
// TODO: why are we overriding and not allowing the disposable to be disposed?
60-
panel.drop()
48+
panel.apply()
6149
}
6250

6351
override fun getId(): String = "aws.tools"

jetbrains-core/src/software/aws/toolkits/jetbrains/ui/CredentialIdentifierSelector.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CredentialIdentifierSelector(identifiers: List<CredentialIdentifier> = Cre
8383
*/
8484
fun getSelectedValidCredentialIdentifier(): CredentialIdentifier? = comboBoxModel.selected?.takeIf { isSelectionValid() }
8585

86-
private class InvalidCredentialIdentifier(override val id: String) : CredentialIdentifier {
86+
class InvalidCredentialIdentifier(override val id: String) : CredentialIdentifier {
8787
override val displayName: String = message("credentials.invalid.not_found", id)
8888
override val factoryId: String = "InvalidCredentialIdentifier"
8989
override val credentialType: CredentialType? = null
@@ -120,7 +120,7 @@ class CredentialIdentifierSelector(identifiers: List<CredentialIdentifier> = Cre
120120
.withValidationOnInput { validateSelection(it) }
121121
}
122122

123-
private fun ValidationInfoBuilder.validateSelection(selector: CredentialIdentifierSelector): ValidationInfo? = if (!selector.isSelectionValid()) {
123+
fun ValidationInfoBuilder.validateSelection(selector: CredentialIdentifierSelector): ValidationInfo? = if (!selector.isSelectionValid()) {
124124
error(message("credentials.invalid.invalid_selection"))
125125
} else {
126126
null

jetbrains-core/src/software/aws/toolkits/jetbrains/ui/ValidatingPanel.kt

Lines changed: 0 additions & 216 deletions
This file was deleted.

0 commit comments

Comments
 (0)