forked from NPM/numass-framework
Add direct CLI for file watcher
This commit is contained in:
parent
5e33bdbce7
commit
c2d2813622
@ -74,9 +74,7 @@ runtime {
|
||||
installerType = "deb"
|
||||
installerOptions = installerOptions + listOf(
|
||||
"--linux-package-name", "numass-viewer",
|
||||
"--linux-shortcut"
|
||||
)
|
||||
imageOptions = listOf(
|
||||
"--linux-shortcut",
|
||||
"--linux-deb-maintainer", "nozik.aa@mipt.ru",
|
||||
"--linux-menu-group", "Science",
|
||||
"--linux-shortcut"
|
||||
|
@ -173,8 +173,10 @@ class DataController : Controller(), ContextAware {
|
||||
sc.remove(id)
|
||||
}
|
||||
|
||||
//
|
||||
// fun addAllPoints(points: Map<String, NumassPoint>) {
|
||||
// TODO()
|
||||
// }
|
||||
|
||||
|
||||
fun addAllPoints(points: Map<String, NumassPoint>) {
|
||||
TODO()
|
||||
}
|
||||
}
|
@ -52,36 +52,8 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override val root = borderpane {
|
||||
prefHeight = 600.0
|
||||
prefWidth = 800.0
|
||||
top {
|
||||
toolbar {
|
||||
prefHeight = 40.0
|
||||
button("Load directory") {
|
||||
action {
|
||||
val chooser = DirectoryChooser()
|
||||
chooser.title = "Select directory to view"
|
||||
val homeDir = NumassProperties.getNumassProperty("numass.viewer.lastPath")
|
||||
try {
|
||||
if (homeDir == null) {
|
||||
chooser.initialDirectory = File(".").absoluteFile
|
||||
} else {
|
||||
val file = File(homeDir)
|
||||
if (file.isDirectory) {
|
||||
chooser.initialDirectory = file
|
||||
} else {
|
||||
chooser.initialDirectory = file.parentFile
|
||||
}
|
||||
}
|
||||
|
||||
val rootDir = chooser.showDialog(primaryStage.scene.window)
|
||||
|
||||
if (rootDir != null) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", rootDir.absolutePath)
|
||||
private fun loadDirectory(path: Path){
|
||||
app.context.launch {
|
||||
val path = rootDir.toPath()
|
||||
dataController.clear()
|
||||
runLater {
|
||||
pathProperty.set(path)
|
||||
@ -117,34 +89,12 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
||||
error("Error", content = "Failed to laod file with message: ${ex.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
button("Load file") {
|
||||
action {
|
||||
val chooser = FileChooser()
|
||||
chooser.title = "Select file to view"
|
||||
val homeDir = NumassProperties.getNumassProperty("numass.viewer.lastPath")
|
||||
try {
|
||||
if (homeDir == null) {
|
||||
chooser.initialDirectory = File(".").absoluteFile
|
||||
} else {
|
||||
chooser.initialDirectory = File(homeDir)
|
||||
}
|
||||
|
||||
|
||||
val file = chooser.showOpenDialog(primaryStage.scene.window)
|
||||
if (file != null) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath",
|
||||
file.parentFile.absolutePath)
|
||||
private fun loadFile(path: Path){
|
||||
app.context.launch {
|
||||
val path = file.toPath()
|
||||
dataController.clear()
|
||||
runLater {
|
||||
pathProperty.set(file.toPath())
|
||||
pathProperty.set(path)
|
||||
contentView = null
|
||||
}
|
||||
//Reading individual file
|
||||
@ -171,6 +121,90 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun watchDirectory(path: Path){
|
||||
app.context.launch {
|
||||
dataController.clear()
|
||||
runLater {
|
||||
pathProperty.set(path)
|
||||
contentView = directoryWatchView
|
||||
dataController.watchPathProperty.set(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override val root = borderpane {
|
||||
prefHeight = 600.0
|
||||
prefWidth = 800.0
|
||||
top {
|
||||
//bypass top configuration bar and only watch directory
|
||||
app.parameters.named["directory"]?.let{ pathString ->
|
||||
val path = Path.of(pathString).toAbsolutePath()
|
||||
watchDirectory(path)
|
||||
toolbar{
|
||||
prefHeight = 40.0
|
||||
label("Watching $path") {
|
||||
padding = Insets(0.0, 0.0, 0.0, 10.0)
|
||||
font = Font.font("System Bold", 13.0)
|
||||
}
|
||||
pane {
|
||||
hgrow = Priority.ALWAYS
|
||||
}
|
||||
}
|
||||
return@top
|
||||
}
|
||||
|
||||
toolbar {
|
||||
prefHeight = 40.0
|
||||
button("Load directory") {
|
||||
action {
|
||||
val chooser = DirectoryChooser()
|
||||
chooser.title = "Select directory to view"
|
||||
val homeDir = NumassProperties.getNumassProperty("numass.viewer.lastPath")
|
||||
try {
|
||||
if (homeDir == null) {
|
||||
chooser.initialDirectory = File(".").absoluteFile
|
||||
} else {
|
||||
val file = File(homeDir)
|
||||
if (file.isDirectory) {
|
||||
chooser.initialDirectory = file
|
||||
} else {
|
||||
chooser.initialDirectory = file.parentFile
|
||||
}
|
||||
}
|
||||
|
||||
val rootDir = chooser.showDialog(primaryStage.scene.window)
|
||||
|
||||
if (rootDir != null) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", rootDir.absolutePath)
|
||||
loadDirectory(rootDir.toPath())
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
||||
error("Error", content = "Failed to laod file with message: ${ex.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
button("Load file") {
|
||||
action {
|
||||
val chooser = FileChooser()
|
||||
chooser.title = "Select file to view"
|
||||
val homeDir = NumassProperties.getNumassProperty("numass.viewer.lastPath")
|
||||
try {
|
||||
if (homeDir == null) {
|
||||
chooser.initialDirectory = File(".").absoluteFile
|
||||
} else {
|
||||
chooser.initialDirectory = File(homeDir)
|
||||
}
|
||||
|
||||
|
||||
val file = chooser.showOpenDialog(primaryStage.scene.window)
|
||||
if (file != null) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath",
|
||||
file.parentFile.absolutePath)
|
||||
loadFile(file.toPath())
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
||||
error("Error", content = "Failed to laod file with message: ${ex.message}")
|
||||
@ -181,7 +215,7 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
|
||||
button("Watch directory") {
|
||||
action {
|
||||
val chooser = DirectoryChooser()
|
||||
chooser.title = "Select directory to view"
|
||||
chooser.title = "Select directory to watch"
|
||||
val homeDir = NumassProperties.getNumassProperty("numass.viewer.lastPath")
|
||||
try {
|
||||
if (homeDir == null) {
|
||||
@ -199,15 +233,7 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
|
||||
|
||||
if (dir != null) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", dir.absolutePath)
|
||||
app.context.launch {
|
||||
val path = dir.toPath()
|
||||
dataController.clear()
|
||||
runLater {
|
||||
pathProperty.set(path)
|
||||
contentView = directoryWatchView
|
||||
dataController.watchPathProperty.set(path)
|
||||
}
|
||||
}
|
||||
watchDirectory(dir.toPath())
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
||||
|
Loading…
Reference in New Issue
Block a user