Moving fx to kotlin
This commit is contained in:
parent
1d51ae6702
commit
97195f8104
@ -3,8 +3,7 @@ package inr.numass.control.cryotemp
|
||||
import hep.dataforge.control.devices.Sensor
|
||||
import hep.dataforge.control.measurements.Measurement
|
||||
import hep.dataforge.control.measurements.MeasurementListener
|
||||
import hep.dataforge.fx.fragments.FXFragment
|
||||
import hep.dataforge.fx.fragments.FragmentWindow
|
||||
import hep.dataforge.fx.bindWindow
|
||||
import hep.dataforge.fx.fragments.LogFragment
|
||||
import hep.dataforge.fx.plots.PlotContainer
|
||||
import hep.dataforge.meta.Meta
|
||||
@ -92,15 +91,14 @@ class PKT8ViewConnection : DeviceViewConnection<PKT8Device>(), MeasurementListen
|
||||
|
||||
plotButton = togglebutton("Plot") {
|
||||
isSelected = false
|
||||
FragmentWindow.build(this) { FXFragment.buildFromNode(plotView.title) { plotView.root } }
|
||||
plotView.bindWindow(selectedProperty())
|
||||
}
|
||||
|
||||
logButton = togglebutton("Log") {
|
||||
isSelected = false
|
||||
FragmentWindow.build(this) {
|
||||
LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
}
|
||||
bindWindow(selectedProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import hep.dataforge.control.NamedValueListener
|
||||
import hep.dataforge.control.devices.DeviceListener
|
||||
import hep.dataforge.control.devices.PortSensor
|
||||
import hep.dataforge.control.devices.Sensor
|
||||
import hep.dataforge.fx.fragments.FragmentWindow
|
||||
import hep.dataforge.fx.bindWindow
|
||||
import hep.dataforge.fx.fragments.LogFragment
|
||||
import hep.dataforge.fx.plots.PlotContainer
|
||||
import hep.dataforge.meta.Meta
|
||||
@ -173,9 +173,11 @@ class MspViewConnection() : DeviceViewConnection<MspDevice>(), DeviceListener, N
|
||||
|
||||
togglebutton("Log") {
|
||||
isSelected = false
|
||||
FragmentWindow.build(this){LogFragment().apply {
|
||||
|
||||
LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
}}
|
||||
bindWindow(selectedProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,15 +5,13 @@ import hep.dataforge.control.devices.Device
|
||||
import hep.dataforge.control.devices.DeviceListener
|
||||
import hep.dataforge.control.devices.PortSensor
|
||||
import hep.dataforge.control.devices.Sensor
|
||||
import hep.dataforge.fx.fragments.FXFragment
|
||||
import hep.dataforge.fx.fragments.FragmentWindow
|
||||
import hep.dataforge.fx.bindWindow
|
||||
import hep.dataforge.values.Value
|
||||
import javafx.beans.binding.BooleanBinding
|
||||
import javafx.beans.binding.ObjectBinding
|
||||
import javafx.beans.property.BooleanProperty
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.Node
|
||||
import javafx.scene.Parent
|
||||
import javafx.scene.layout.HBox
|
||||
import javafx.scene.layout.Priority
|
||||
@ -68,10 +66,6 @@ abstract class DeviceViewConnection<D : Device> : Component(), Connection, Devic
|
||||
deviceProperty.set(null)
|
||||
}
|
||||
|
||||
override fun getFXNode(): Node {
|
||||
return view.root;
|
||||
}
|
||||
|
||||
abstract fun buildView(device: D): View;
|
||||
|
||||
/**
|
||||
@ -85,10 +79,10 @@ abstract class DeviceViewConnection<D : Device> : Component(), Connection, Devic
|
||||
return bindings.computeIfAbsent(state) { stateName ->
|
||||
object : ObjectBinding<Value>() {
|
||||
override fun computeValue(): Value {
|
||||
if (isOpen) {
|
||||
return device.getState(stateName)
|
||||
return if (isOpen) {
|
||||
device.getState(stateName)
|
||||
} else {
|
||||
return Value.NULL
|
||||
Value.NULL
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,7 +134,7 @@ abstract class DeviceViewConnection<D : Device> : Component(), Connection, Devic
|
||||
}
|
||||
togglebutton("View") {
|
||||
isSelected = false
|
||||
FragmentWindow.build(this){FXFragment.buildFromNode(device.name) { getFxNode() }}
|
||||
view.bindWindow(this.selectedProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ abstract class NumassControlApplication<D : Device> : App() {
|
||||
device = setupDevice()
|
||||
val controller = buildView(device)
|
||||
device.connect(controller, Roles.VIEW_ROLE, Roles.DEVICE_LISTENER_ROLE)
|
||||
val scene = Scene(controller.getPane())
|
||||
val scene = Scene(controller.view.root)
|
||||
stage.scene = scene
|
||||
|
||||
stage.show()
|
||||
|
@ -10,7 +10,7 @@ import hep.dataforge.control.connections.Roles
|
||||
import hep.dataforge.control.devices.Sensor
|
||||
import hep.dataforge.control.measurements.Measurement
|
||||
import hep.dataforge.control.measurements.MeasurementListener
|
||||
import hep.dataforge.fx.fragments.FragmentWindow
|
||||
import hep.dataforge.fx.bindWindow
|
||||
import hep.dataforge.fx.fragments.LogFragment
|
||||
import hep.dataforge.plots.data.TimePlot
|
||||
import hep.dataforge.plots.data.TimePlottableGroup
|
||||
@ -89,9 +89,10 @@ class VacCollectorViewConnection : DeviceViewConnection<VacCollectorDevice>() {
|
||||
separator(Orientation.VERTICAL)
|
||||
togglebutton("Log") {
|
||||
isSelected = false
|
||||
FragmentWindow.build(this){LogFragment().apply {
|
||||
LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
}}
|
||||
bindWindow(selectedProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,7 +109,7 @@ class VacCollectorViewConnection : DeviceViewConnection<VacCollectorDevice>() {
|
||||
hbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
|
||||
vbox {
|
||||
viewList.forEach {
|
||||
add(it.getFxNode())
|
||||
add(it.view)
|
||||
separator(Orientation.HORIZONTAL)
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import hep.dataforge.meta.Laminate
|
||||
import hep.dataforge.tables.Table
|
||||
import hep.dataforge.values.ValueType.NUMBER
|
||||
import hep.dataforge.values.ValueType.STRING
|
||||
import inr.numass.NumassUtils
|
||||
import inr.numass.data.api.NumassAnalyzer
|
||||
import inr.numass.data.api.NumassSet
|
||||
|
||||
|
@ -2,8 +2,8 @@ package inr.numass.viewer
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.fx.bindWindow
|
||||
import hep.dataforge.fx.dfIcon
|
||||
import hep.dataforge.fx.fragments.FragmentWindow
|
||||
import hep.dataforge.fx.fragments.LogFragment
|
||||
import hep.dataforge.fx.runGoal
|
||||
import hep.dataforge.fx.ui
|
||||
@ -122,10 +122,9 @@ class StorageView(private val context: Context = Global.instance()) : View(title
|
||||
}
|
||||
togglebutton("Console") {
|
||||
isSelected = false
|
||||
FragmentWindow.build(this) {
|
||||
LogFragment().apply {
|
||||
addRootLogHandler()
|
||||
}
|
||||
addLogHandler(storage.logger)
|
||||
bindWindow(selectedProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user