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