Wizard: do not show drop down component if it has <= 1 possible values
This commit is contained in:
+3
-5
@@ -19,7 +19,7 @@ class DropDownComponent<T : DisplayableSettingItem>(
|
||||
initialValues: List<T> = emptyList(),
|
||||
initiallySelectedValue: T? = null,
|
||||
labelText: String? = null,
|
||||
private val filter: (T) -> Boolean = { true },
|
||||
filter: (T) -> Boolean = { true },
|
||||
private val validator: SettingValidator<T> = settingValidator { ValidationResult.OK },
|
||||
private val iconProvider: (T) -> Icon? = { null },
|
||||
onValueUpdate: (T) -> Unit = {}
|
||||
@@ -68,10 +68,8 @@ class DropDownComponent<T : DisplayableSettingItem>(
|
||||
}
|
||||
}
|
||||
|
||||
fun setValues(newValues: List<T>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
uiComponent.model = DefaultComboBoxModel(newValues.filter(filter).toTypedArray<DisplayableSettingItem>() as Array<T>)
|
||||
}
|
||||
val valuesCount
|
||||
get() = uiComponent.model.size
|
||||
|
||||
override fun updateUiValue(newValue: T) = safeUpdateUi {
|
||||
uiComponent.selectedItem = newValue
|
||||
|
||||
+3
@@ -118,6 +118,9 @@ class DropdownSettingComponent(
|
||||
labelText = setting.title.takeIf { needLabel },
|
||||
onValueUpdate = { newValue -> value = newValue }
|
||||
).asSubComponent()
|
||||
|
||||
override fun shouldBeShow(): Boolean =
|
||||
uiComponent.valuesCount > 1
|
||||
}
|
||||
|
||||
class BooleanSettingComponent(
|
||||
|
||||
Reference in New Issue
Block a user