Closed ASchmidt84 closed 4 years ago
I tried a few things.
val k = StringConverter[Locale](e ⇒ Locale.CANADA, e ⇒ e.getCountry)
this.converterFactory.converterMap.put("countryIsoCodeConverter",k)
println("KLASS: " + k.getClass ) //class scalafx.util.StringConverter$$anon$2
if (property.isDefined && property.get.isInstanceOf[StringProperty])
println(property.get.isInstanceOf[StringProperty])
else
println("NOPE!") //This is shown
println( converterFactory.getConverterByName("countryIsoCodeConverter") ) //javafx.util.converter.DefaultStringConverter@13a8bd28
But the problem is that the guessPropertyForNode is
Some(ObjectProperty [bean: ComboBox[id=countryCombo, styleClass=combo-box-base combo-box], name: value, value: null])
So I will never have the possibilty to set the combo item with an binding.
I try to get an objectproperty of FXBean to set it all manual. But their is always a simplestringproperty.
def getObjectProperty[S <: Any](key: String): ObjectProperty[S] = getProperty(key).asInstanceOf[ObjectProperty[S]]
def getProperty(key: String): Property[_] = {
....
value match {
case i: Integer => result = new SimpleIntegerProperty(bean, info.name, i)
case l: Long => result = new SimpleLongProperty(bean, info.name, l)
case f: Float => result = new SimpleFloatProperty(bean, info.name, f)
case d: Double => result = new SimpleDoubleProperty(bean, info.name, d)
case b: Boolean => result = new SimpleBooleanProperty(bean, info.name, b)
case ld: LocalDate => result = new SimpleObjectProperty(bean, info.name, ld)
case _ => result = createSimpleStringPropertyForObject(value, info.name)
}
....
}
I try to create an object property in case of unprocessed AnyRef values, maybe that will work. Please send me a simple usecase forme to try it out.
A workaround is always set combobox value on setBean programatically and add a listener to the combobox to update bean value on change.
Hello Tom,
I have now a combobox with locale. I defined a converter for this combo to display the Countryname. This works fine. Now I have an adapter for an external object. I set this to the adapter as current element. Field name is countryIsoCode. Now I want convert the iso code "de" to locale Germany. I set up an converter
I get now an error NPE. So I looked at FXBeanAdapter:58 whichs bindBidirectional the bean.
I think