commonMain.jetbrains.datalore.base.observable.children.ChildProperty.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lets-plot-common Show documentation
Show all versions of lets-plot-common Show documentation
Lets-Plot JVM package without rendering part
/*
* Copyright (c) 2020. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.base.observable.children
import jetbrains.datalore.base.observable.property.ValueProperty
class ChildProperty>(private val myParent: ParentT) :
ValueProperty(null) {
override fun set(value: ChildT?) {
if (get() === value) return
if (value != null && value.parent().get() != null) {
throw IllegalStateException()
}
val oldValue = get()
if (oldValue != null) {
oldValue.parent().set(null)
oldValue.setPositionData(null)
}
if (value != null) {
value.parent().set(myParent)
value.setPositionData(object :
PositionData {
override fun get(): Position {
return object : Position {
override val role: Any
get() = this@ChildProperty
override fun get(): ChildT? {
return [email protected]()
}
}
}
override fun remove() {
set(null)
}
})
}
super.set(value)
if (oldValue != null) {
oldValue.parent().flush()
}
value?.parent()?.flush()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy