Wizard: fix filtering values in DropDownComponent

This commit is contained in:
Ilya Kirillov
2020-08-25 21:17:21 +03:00
committed by Ilya Goncharov
parent 98f98d5856
commit f824f03fa2
3 changed files with 12 additions and 5 deletions
@@ -1,6 +1,7 @@
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui package org.jetbrains.kotlin.tools.projectWizard.wizard.ui
import com.intellij.openapi.application.ApplicationManager
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.Reader import org.jetbrains.kotlin.tools.projectWizard.core.Reader
import org.jetbrains.kotlin.tools.projectWizard.core.SettingsWriter import org.jetbrains.kotlin.tools.projectWizard.core.SettingsWriter
@@ -46,7 +47,9 @@ abstract class DynamicComponent(private val context: Context) : Component() {
init { init {
write { write {
eventManager.addSettingUpdaterEventListener { reference -> eventManager.addSettingUpdaterEventListener { reference ->
if (isInitialized) onValueUpdated(reference) if (isInitialized) ApplicationManager.getApplication().invokeLater {
onValueUpdated(reference)
}
} }
} }
} }
@@ -8,6 +8,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingValidator import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingValidator
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settingValidator import org.jetbrains.kotlin.tools.projectWizard.core.entity.settingValidator
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import java.awt.event.ItemEvent import java.awt.event.ItemEvent
@@ -103,6 +104,11 @@ class DropDownComponent<T : DisplayableSettingItem>(
uiComponent.selectedItem = newValue uiComponent.selectedItem = newValue
} }
override fun onValueUpdated(reference: SettingReference<*, *>?) {
super.onValueUpdated(reference)
filterValues()
}
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
override fun getUiValue(): T? = uiComponent.selectedItem as? T override fun getUiValue(): T? = uiComponent.selectedItem as? T
} }
@@ -37,10 +37,8 @@ abstract class UIComponentDelegatingSettingComponent<V : Any, T : SettingType<V>
override fun onValueUpdated(reference: SettingReference<*, *>?) { override fun onValueUpdated(reference: SettingReference<*, *>?) {
super.onValueUpdated(reference) super.onValueUpdated(reference)
if (reference == this.reference) { if (reference == this.reference) {
ApplicationManager.getApplication().invokeLater { if (uiComponent.getUiValue() != value) {
if (uiComponent.getUiValue() != value) { value?.let(uiComponent::updateUiValue)
value?.let(uiComponent::updateUiValue)
}
} }
} }
} }