mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
IDEA-318666: Port `ManualPathEntryDialog` to Kotlin UI DSL 2
Merge-request: IJ-MR-106615 Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com> GitOrigin-RevId: d309ba087cbbea1b172372ae4a90a018b7787a36
This commit is contained in:
committed by
intellij-monorepo-bot
parent
64fd19dc27
commit
d356803b69
@@ -48,14 +48,15 @@ fun com.intellij.ui.dsl.builder.Row.textFieldWithBrowseTargetButton(targetType:
|
|||||||
targetSupplier: Supplier<out TargetEnvironmentConfiguration>,
|
targetSupplier: Supplier<out TargetEnvironmentConfiguration>,
|
||||||
project: Project,
|
project: Project,
|
||||||
@NlsContexts.DialogTitle title: String,
|
@NlsContexts.DialogTitle title: String,
|
||||||
property: MutableProperty<String>): Cell<TextFieldWithBrowseButton> {
|
property: MutableProperty<String>,
|
||||||
|
targetBrowserHints: TargetBrowserHints = TargetBrowserHints(true)): Cell<TextFieldWithBrowseButton> {
|
||||||
val textFieldWithBrowseButton = TextFieldWithBrowseButton()
|
val textFieldWithBrowseButton = TextFieldWithBrowseButton()
|
||||||
val browser = targetType.createBrowser(project,
|
val browser = targetType.createBrowser(project,
|
||||||
title,
|
title,
|
||||||
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
|
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
|
||||||
textFieldWithBrowseButton.textField,
|
textFieldWithBrowseButton.textField,
|
||||||
targetSupplier,
|
targetSupplier,
|
||||||
TargetBrowserHints(true))
|
targetBrowserHints)
|
||||||
textFieldWithBrowseButton.addActionListener(browser)
|
textFieldWithBrowseButton.addActionListener(browser)
|
||||||
return cell(textFieldWithBrowseButton)
|
return cell(textFieldWithBrowseButton)
|
||||||
.bind(TextFieldWithBrowseButton::getText, TextFieldWithBrowseButton::setText, property)
|
.bind(TextFieldWithBrowseButton::getText, TextFieldWithBrowseButton::setText, property)
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import com.intellij.execution.target.*
|
|||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.ui.DialogWrapper
|
import com.intellij.openapi.ui.DialogWrapper
|
||||||
import com.intellij.openapi.util.io.OSAgnosticPathUtil
|
import com.intellij.openapi.util.io.OSAgnosticPathUtil
|
||||||
import com.intellij.ui.layout.*
|
import com.intellij.ui.dsl.builder.bindText
|
||||||
|
import com.intellij.ui.dsl.builder.panel
|
||||||
|
import com.intellij.ui.dsl.builder.toMutableProperty
|
||||||
import com.jetbrains.python.PyBundle
|
import com.jetbrains.python.PyBundle
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
@@ -36,10 +38,10 @@ class ManualPathEntryDialog(private val project: Project?,
|
|||||||
return panel {
|
return panel {
|
||||||
row(label = label) {
|
row(label = label) {
|
||||||
val textFieldComponent = if (targetConfigAndType == null)
|
val textFieldComponent = if (targetConfigAndType == null)
|
||||||
textField(prop = ::path)
|
textField().bindText(::path)
|
||||||
else
|
else
|
||||||
textFieldWithBrowseTargetButton(this, targetConfigAndType.second, Supplier { targetConfigAndType.first }, project!!, label, this@ManualPathEntryDialog::path.toBinding(), TargetBrowserHints(true))
|
textFieldWithBrowseTargetButton(targetConfigAndType.second, Supplier { targetConfigAndType.first }, project!!, label, this@ManualPathEntryDialog::path.toMutableProperty(), TargetBrowserHints(true))
|
||||||
textFieldComponent.withValidationOnApply { textField ->
|
textFieldComponent.validationOnApply { textField ->
|
||||||
val text = textField.text
|
val text = textField.text
|
||||||
when {
|
when {
|
||||||
text.isBlank() -> error(PyBundle.message("path.must.not.be.empty.error.message"))
|
text.isBlank() -> error(PyBundle.message("path.must.not.be.empty.error.message"))
|
||||||
|
|||||||
Reference in New Issue
Block a user