Remove directory watching for now.
This commit is contained in:
parent
6e62b57e0d
commit
0ba8fea70f
@ -1,12 +1,13 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("org.openjfx.javafxplugin")
|
||||
//id("com.github.johnrengelman.shadow")
|
||||
id("org.beryx.runtime") version "1.12.7"
|
||||
application
|
||||
}
|
||||
|
||||
javafx {
|
||||
modules = listOf("javafx.controls", "javafx.web")
|
||||
modules = listOf("javafx.graphics", "javafx.controls", "javafx.web")
|
||||
version = "11"
|
||||
}
|
||||
|
||||
@ -57,7 +58,7 @@ runtime {
|
||||
)
|
||||
jpackage {
|
||||
jvmArgs = addJvmArgs
|
||||
imageOptions = listOf("--linux-deb-maintainer nozik.aa@mipt.ru", "--linux-menu-group Science")
|
||||
//imageOptions = listOf("--linux-deb-maintainer", "nozik.aa@mipt.ru", "--linux-menu-group", "Science")
|
||||
}
|
||||
launcher {
|
||||
jvmArgs = addJvmArgs
|
||||
|
@ -48,7 +48,7 @@ class PointCache : Controller() {
|
||||
}
|
||||
}
|
||||
|
||||
private val cache = Misc.getLRUCache<String, CachedPoint>(1000)
|
||||
private val cache = Misc.getLRUCache<String, CachedPoint>(400)
|
||||
|
||||
fun getCachedPoint(id: String,point: NumassPoint): CachedPoint = cache.getOrPut(id) { CachedPoint(point) }
|
||||
|
||||
|
@ -2,16 +2,12 @@ package inr.numass.viewer
|
||||
|
||||
import hep.dataforge.fx.dfIconView
|
||||
import hep.dataforge.fx.meta.MetaViewer
|
||||
import hep.dataforge.io.envelopes.Envelope
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.Metoid
|
||||
import hep.dataforge.names.AlphanumComparator
|
||||
import hep.dataforge.storage.Storage
|
||||
import hep.dataforge.storage.files.FileStorage
|
||||
import hep.dataforge.storage.files.FileTableLoader
|
||||
import hep.dataforge.storage.tables.TableLoader
|
||||
import inr.numass.data.NumassDataUtils
|
||||
import inr.numass.data.NumassEnvelopeType
|
||||
import inr.numass.data.api.NumassPoint
|
||||
import inr.numass.data.api.NumassSet
|
||||
import inr.numass.data.storage.NumassDataLoader
|
||||
@ -20,15 +16,8 @@ import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.scene.control.ContextMenu
|
||||
import javafx.scene.control.TreeItem
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import tornadofx.*
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardWatchEventKinds.ENTRY_CREATE
|
||||
import java.nio.file.WatchKey
|
||||
import java.nio.file.WatchService
|
||||
|
||||
|
||||
class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
@ -44,11 +33,11 @@ class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
private val hvView: HVView by inject()
|
||||
private val scView: SlowControlView by inject()
|
||||
|
||||
private var watcher: WatchService? = null
|
||||
// private var watcher: WatchService? = null
|
||||
|
||||
|
||||
fun clear() {
|
||||
watcher?.close()
|
||||
//watcher?.close()
|
||||
ampView.clear()
|
||||
timeView.clear()
|
||||
spectrumView.clear()
|
||||
@ -68,7 +57,7 @@ class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
}
|
||||
}
|
||||
|
||||
val watchedProperty = SimpleBooleanProperty(false)
|
||||
//val watchedProperty = SimpleBooleanProperty(false)
|
||||
|
||||
init {
|
||||
checkedProperty.onChange { selected ->
|
||||
@ -101,9 +90,9 @@ class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
}
|
||||
}
|
||||
|
||||
watchedProperty.onChange {
|
||||
toggleWatch(it)
|
||||
}
|
||||
// watchedProperty.onChange {
|
||||
// toggleWatch(it)
|
||||
// }
|
||||
}
|
||||
|
||||
val children: ObservableList<Container>? by lazy {
|
||||
@ -114,7 +103,7 @@ class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
is NumassSet -> content.points
|
||||
.sortedBy { it.index }
|
||||
.map { buildContainer(it, this) }
|
||||
.asObservable()
|
||||
.toObservable()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@ -123,38 +112,38 @@ class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
|
||||
private var watchJob: Job? = null
|
||||
|
||||
private fun toggleWatch(watch: Boolean) {
|
||||
if (watch) {
|
||||
if (watchJob != null && content is NumassDataLoader) {
|
||||
watchJob = app.context.launch(Dispatchers.IO) {
|
||||
val key: WatchKey = content.path.register(watcher!!, ENTRY_CREATE)
|
||||
coroutineContext[Job]?.invokeOnCompletion {
|
||||
key.cancel()
|
||||
}
|
||||
while (watcher != null && isActive) {
|
||||
try {
|
||||
key.pollEvents().forEach { event ->
|
||||
if (event.kind() == ENTRY_CREATE) {
|
||||
val path: Path = event.context() as Path
|
||||
if (path.fileName.toString().startsWith(NumassDataLoader.POINT_FRAGMENT_NAME)) {
|
||||
val envelope: Envelope = NumassEnvelopeType.infer(path)?.reader?.read(path)
|
||||
?: kotlin.error("Can't read point file")
|
||||
val point = NumassDataUtils.read(envelope)
|
||||
children!!.add(buildContainer(point, this@Container))
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (x: Throwable) {
|
||||
app.context.logger.error("Error during dynamic point read", x)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
watchJob?.cancel()
|
||||
watchJob = null
|
||||
}
|
||||
}
|
||||
// private fun toggleWatch(watch: Boolean) {
|
||||
// if (watch) {
|
||||
// if (watchJob != null && content is NumassDataLoader) {
|
||||
// watchJob = app.context.launch(Dispatchers.IO) {
|
||||
// val key: WatchKey = content.path.register(watcher!!, ENTRY_CREATE)
|
||||
// coroutineContext[Job]?.invokeOnCompletion {
|
||||
// key.cancel()
|
||||
// }
|
||||
// while (watcher != null && isActive) {
|
||||
// try {
|
||||
// key.pollEvents().forEach { event ->
|
||||
// if (event.kind() == ENTRY_CREATE) {
|
||||
// val path: Path = event.context() as Path
|
||||
// if (path.fileName.toString().startsWith(NumassDataLoader.POINT_FRAGMENT_NAME)) {
|
||||
// val envelope: Envelope = NumassEnvelopeType.infer(path)?.reader?.read(path)
|
||||
// ?: kotlin.error("Can't read point file")
|
||||
// val point = NumassDataUtils.read(envelope)
|
||||
// children!!.add(buildContainer(point, this@Container))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (x: Throwable) {
|
||||
// app.context.logger.error("Error during dynamic point read", x)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// watchJob?.cancel()
|
||||
// watchJob = null
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -171,12 +160,12 @@ class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
}) {
|
||||
it.value.children
|
||||
}
|
||||
watcher?.close()
|
||||
watcher = if (storage is FileStorage) {
|
||||
storage.path.fileSystem.newWatchService()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
// watcher?.close()
|
||||
// watcher = if (storage is FileStorage) {
|
||||
// storage.path.fileSystem.newWatchService()
|
||||
// } else {
|
||||
// null
|
||||
// }
|
||||
}
|
||||
|
||||
cellFormat { value: Container ->
|
||||
@ -219,11 +208,11 @@ class StorageView : View(title = "Numass storage", icon = dfIconView) {
|
||||
value.infoView.openModal(escapeClosesWindow = true)
|
||||
}
|
||||
}
|
||||
if(value.content is NumassDataLoader) {
|
||||
checkmenuitem("Watch") {
|
||||
selectedProperty().bindBidirectional(value.watchedProperty)
|
||||
}
|
||||
}
|
||||
// if(value.content is NumassDataLoader) {
|
||||
// checkmenuitem("Watch") {
|
||||
// selectedProperty().bindBidirectional(value.watchedProperty)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user