Moving fx to kotlin

This commit is contained in:
Alexander Nozik 2017-11-08 17:01:38 +03:00
parent 1d51ae6702
commit 97195f8104
7 changed files with 26 additions and 31 deletions

View File

@ -3,8 +3,7 @@ package inr.numass.control.cryotemp
import hep.dataforge.control.devices.Sensor import hep.dataforge.control.devices.Sensor
import hep.dataforge.control.measurements.Measurement import hep.dataforge.control.measurements.Measurement
import hep.dataforge.control.measurements.MeasurementListener import hep.dataforge.control.measurements.MeasurementListener
import hep.dataforge.fx.fragments.FXFragment import hep.dataforge.fx.bindWindow
import hep.dataforge.fx.fragments.FragmentWindow
import hep.dataforge.fx.fragments.LogFragment import hep.dataforge.fx.fragments.LogFragment
import hep.dataforge.fx.plots.PlotContainer import hep.dataforge.fx.plots.PlotContainer
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
@ -92,15 +91,14 @@ class PKT8ViewConnection : DeviceViewConnection<PKT8Device>(), MeasurementListen
plotButton = togglebutton("Plot") { plotButton = togglebutton("Plot") {
isSelected = false isSelected = false
FragmentWindow.build(this) { FXFragment.buildFromNode(plotView.title) { plotView.root } } plotView.bindWindow(selectedProperty())
} }
logButton = togglebutton("Log") { logButton = togglebutton("Log") {
isSelected = false isSelected = false
FragmentWindow.build(this) {
LogFragment().apply { LogFragment().apply {
addLogHandler(device.logger) addLogHandler(device.logger)
} bindWindow(selectedProperty())
} }
} }
} }

View File

@ -19,7 +19,7 @@ import hep.dataforge.control.NamedValueListener
import hep.dataforge.control.devices.DeviceListener import hep.dataforge.control.devices.DeviceListener
import hep.dataforge.control.devices.PortSensor import hep.dataforge.control.devices.PortSensor
import hep.dataforge.control.devices.Sensor 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.fragments.LogFragment
import hep.dataforge.fx.plots.PlotContainer import hep.dataforge.fx.plots.PlotContainer
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
@ -173,9 +173,11 @@ class MspViewConnection() : DeviceViewConnection<MspDevice>(), DeviceListener, N
togglebutton("Log") { togglebutton("Log") {
isSelected = false isSelected = false
FragmentWindow.build(this){LogFragment().apply {
LogFragment().apply {
addLogHandler(device.logger) addLogHandler(device.logger)
}} bindWindow(selectedProperty())
}
} }
} }
} }

View File

@ -5,15 +5,13 @@ import hep.dataforge.control.devices.Device
import hep.dataforge.control.devices.DeviceListener import hep.dataforge.control.devices.DeviceListener
import hep.dataforge.control.devices.PortSensor import hep.dataforge.control.devices.PortSensor
import hep.dataforge.control.devices.Sensor import hep.dataforge.control.devices.Sensor
import hep.dataforge.fx.fragments.FXFragment import hep.dataforge.fx.bindWindow
import hep.dataforge.fx.fragments.FragmentWindow
import hep.dataforge.values.Value import hep.dataforge.values.Value
import javafx.beans.binding.BooleanBinding import javafx.beans.binding.BooleanBinding
import javafx.beans.binding.ObjectBinding import javafx.beans.binding.ObjectBinding
import javafx.beans.property.BooleanProperty import javafx.beans.property.BooleanProperty
import javafx.beans.property.SimpleObjectProperty import javafx.beans.property.SimpleObjectProperty
import javafx.geometry.Pos import javafx.geometry.Pos
import javafx.scene.Node
import javafx.scene.Parent import javafx.scene.Parent
import javafx.scene.layout.HBox import javafx.scene.layout.HBox
import javafx.scene.layout.Priority import javafx.scene.layout.Priority
@ -68,10 +66,6 @@ abstract class DeviceViewConnection<D : Device> : Component(), Connection, Devic
deviceProperty.set(null) deviceProperty.set(null)
} }
override fun getFXNode(): Node {
return view.root;
}
abstract fun buildView(device: D): View; abstract fun buildView(device: D): View;
/** /**
@ -85,10 +79,10 @@ abstract class DeviceViewConnection<D : Device> : Component(), Connection, Devic
return bindings.computeIfAbsent(state) { stateName -> return bindings.computeIfAbsent(state) { stateName ->
object : ObjectBinding<Value>() { object : ObjectBinding<Value>() {
override fun computeValue(): Value { override fun computeValue(): Value {
if (isOpen) { return if (isOpen) {
return device.getState(stateName) device.getState(stateName)
} else { } else {
return Value.NULL Value.NULL
} }
} }
} }
@ -140,7 +134,7 @@ abstract class DeviceViewConnection<D : Device> : Component(), Connection, Devic
} }
togglebutton("View") { togglebutton("View") {
isSelected = false isSelected = false
FragmentWindow.build(this){FXFragment.buildFromNode(device.name) { getFxNode() }} view.bindWindow(this.selectedProperty())
} }
} }
} }

View File

@ -27,7 +27,7 @@ abstract class NumassControlApplication<D : Device> : App() {
device = setupDevice() device = setupDevice()
val controller = buildView(device) val controller = buildView(device)
device.connect(controller, Roles.VIEW_ROLE, Roles.DEVICE_LISTENER_ROLE) 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.scene = scene
stage.show() stage.show()

View File

@ -10,7 +10,7 @@ import hep.dataforge.control.connections.Roles
import hep.dataforge.control.devices.Sensor import hep.dataforge.control.devices.Sensor
import hep.dataforge.control.measurements.Measurement import hep.dataforge.control.measurements.Measurement
import hep.dataforge.control.measurements.MeasurementListener 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.fx.fragments.LogFragment
import hep.dataforge.plots.data.TimePlot import hep.dataforge.plots.data.TimePlot
import hep.dataforge.plots.data.TimePlottableGroup import hep.dataforge.plots.data.TimePlottableGroup
@ -89,9 +89,10 @@ class VacCollectorViewConnection : DeviceViewConnection<VacCollectorDevice>() {
separator(Orientation.VERTICAL) separator(Orientation.VERTICAL)
togglebutton("Log") { togglebutton("Log") {
isSelected = false isSelected = false
FragmentWindow.build(this){LogFragment().apply { LogFragment().apply {
addLogHandler(device.logger) addLogHandler(device.logger)
}} bindWindow(selectedProperty())
}
} }
} }
} }
@ -108,7 +109,7 @@ class VacCollectorViewConnection : DeviceViewConnection<VacCollectorDevice>() {
hbarPolicy = ScrollPane.ScrollBarPolicy.NEVER hbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
vbox { vbox {
viewList.forEach { viewList.forEach {
add(it.getFxNode()) add(it.view)
separator(Orientation.HORIZONTAL) separator(Orientation.HORIZONTAL)
} }
} }

View File

@ -9,6 +9,7 @@ import hep.dataforge.meta.Laminate
import hep.dataforge.tables.Table import hep.dataforge.tables.Table
import hep.dataforge.values.ValueType.NUMBER import hep.dataforge.values.ValueType.NUMBER
import hep.dataforge.values.ValueType.STRING import hep.dataforge.values.ValueType.STRING
import inr.numass.NumassUtils
import inr.numass.data.api.NumassAnalyzer import inr.numass.data.api.NumassAnalyzer
import inr.numass.data.api.NumassSet import inr.numass.data.api.NumassSet

View File

@ -2,8 +2,8 @@ package inr.numass.viewer
import hep.dataforge.context.Context import hep.dataforge.context.Context
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.fx.bindWindow
import hep.dataforge.fx.dfIcon import hep.dataforge.fx.dfIcon
import hep.dataforge.fx.fragments.FragmentWindow
import hep.dataforge.fx.fragments.LogFragment import hep.dataforge.fx.fragments.LogFragment
import hep.dataforge.fx.runGoal import hep.dataforge.fx.runGoal
import hep.dataforge.fx.ui import hep.dataforge.fx.ui
@ -122,10 +122,9 @@ class StorageView(private val context: Context = Global.instance()) : View(title
} }
togglebutton("Console") { togglebutton("Console") {
isSelected = false isSelected = false
FragmentWindow.build(this) {
LogFragment().apply { LogFragment().apply {
addRootLogHandler() addLogHandler(storage.logger)
} bindWindow(selectedProperty())
} }
} }
} }