@@ -24,6 +24,8 @@ import kotlin.reflect.*
2424import kotlin.reflect.full.*
2525import kotlin.reflect.jvm.*
2626
27+ typealias KObservableProperty <T > = korlibs.io.async.ObservableProperty <T >
28+
2729internal var UiApplication .views by Extra .PropertyThis <UiApplication , Views ?> { null }
2830
2931internal class UiEditProperties (app : UiApplication , view : View ? , val views : Views ) : UiContainer(app) {
@@ -65,7 +67,7 @@ internal class UiEditProperties(app: UiApplication, view: View?, val views: View
6567 val prop = eprop.prop
6668 val viewProp = eprop.viewProp
6769 try {
68- val res = createUiEditableValueFor(instance, prop.returnType, viewProp, prop as KProperty1 <View , * >, null )
70+ val res = createUiEditableValueFor(instance, prop.returnType, viewProp, prop as KProperty1 <Any , * >, null )
6971 val item = res ? : UiLabel (app).also { it.text = " <UNSUPPORTED TYPE>" }
7072 if (item is UiEditableValue <* > || item is UiLabel ) {
7173 addChild(UiRowEditableValue (app, name, item))
@@ -173,7 +175,7 @@ internal class UiEditProperties(app: UiApplication, view: View?, val views: View
173175 override fun toString (): String = if (value == null ) " null" else " $value "
174176 }
175177
176- fun createUiEditableValueFor (instance : Any , type : KType , viewProp : ViewProperty , prop : KProperty1 <View , Any ?>? , obs : ObservableProperty <* >? = null): UiComponent ? {
178+ fun createUiEditableValueFor (instance : Any , type : KType , viewProp : ViewProperty , prop : KProperty1 <Any , Any ?>? , obs : ObservableProperty <* >? = null): UiComponent ? {
177179 val name = prop?.name ? : " Unknown"
178180 val obs: ObservableProperty <Any ?> = (obs ? : ObservableProperty <Any ?>(
179181 name,
@@ -212,6 +214,15 @@ internal class UiEditProperties(app: UiApplication, view: View?, val views: View
212214 }
213215 UiTwoItemEditableValue (app, vv[0 ], vv[1 ])
214216 }
217+ type.isSubtypeOf(KObservableProperty ::class .starProjectedType) -> {
218+ if (prop == null ) return null
219+ val arguments0Type = type.arguments[0 ].type!!
220+ // Nested ObservableProperty types are not supported
221+ if (arguments0Type.isSubtypeOf(KObservableProperty ::class .starProjectedType)) return null
222+ val rprop = prop as KProperty1 <Any , KObservableProperty <Any >>
223+ val obs = ObservableProperty (name, { rprop.get(instance).apply { this (it) } }, { rprop.get(instance).value })
224+ createUiEditableValueFor(rprop.get(instance), arguments0Type, viewProp, KObservableProperty <Any >::value as KProperty1 <Any , Any ?>? , obs)
225+ }
215226 type.isSubtypeOf(MPoint ::class .starProjectedType) -> createPair({ MPoint (it.x, it.y) }, { Two (it.x, it.y) }, instance, prop, viewProp)
216227 type.isSubtypeOf(Vector2D ::class .starProjectedType) -> createPair({ Vector2D (it.x, it.y) }, { Two (it.x, it.y) }, instance, prop, viewProp)
217228 type.isSubtypeOf(Size ::class .starProjectedType) -> createPair({ Size (it.x, it.y) }, { Two (it.width, it.height) }, instance, prop, viewProp)
0 commit comments