[Kotlin UI DSL] textfield binding not working

Answered

Hi there,

I am currently implementing a SettingsEditor for a run configuration of one of my plugins. For this I want to use the Kotlin UI DSL.

The problem I have is that the text field binding seems to not work; the value entered is not applied. Even when debugging I see no change in the bound property.

My prototype code in the SettingsEditor looks like the following:

private var vamosPath = ""

override fun createEditor(): JComponent {
return panel {
row {
textField(::vamosPath)
}
}
}

Is there anything obvious that I overlooked?

Thanks in advance,
Marco

5 comments
Comment actions Permalink

Please show the full code.

0
Comment actions Permalink

Here is the VamosSettingsEditor code:

class VamosSettingsEditor : SettingsEditor<VamosRunConfiguration>() {

var vamosPath = ""

override fun createEditor(): JComponent {
return panel {
row {
textField(::vamosPath)
}
}
}

override fun resetEditorFrom(config: VamosRunConfiguration) {
println("VamosSettingsEditor::resetEditorFrom, vamosPath: ${config.options.vamosPath}")
config.options.vamosPath?.let { println("vamosPath $vamosPath -> cfg $it"); vamosPath = it }
}

override fun applyEditorTo(config: VamosRunConfiguration) {
println("VamosSettingsEditor::applyEditorTo, vamosPath: $vamosPath, config vamosPath: ${config.options.vamosPath}")
config.options.vamosPath = vamosPath
}
}

And this is the corresponding options type (referenced above via config.options):

package com.github.mrolappe.intellij.runconfiguration.vamos

import com.intellij.execution.configurations.ModuleBasedConfigurationOptions

class VamosRunConfigurationOptions : ModuleBasedConfigurationOptions() {
var vamosPath by string()
}
0
Comment actions Permalink

Let me know, if you need anything else for diagnosing the problem.

0
Comment actions Permalink

Any update? Or a hint/link to other documentation/support?

0
Comment actions Permalink

Sorry for delay.

Some additional code is required in this case.

Please add

private lateinit var panel: DialogPanel

and store panel {...} result from createEditor().

Then, in resetEditorFrom(), please add as last line

panel.reset()

and in applyEditorTo() as first line

panel.apply()

 

Reference: https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl.html#dialogs

 

0

Please sign in to leave a comment.