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"
|
installerType = "deb"
|
||||||
installerOptions = installerOptions + listOf(
|
installerOptions = installerOptions + listOf(
|
||||||
"--linux-package-name", "numass-viewer",
|
"--linux-package-name", "numass-viewer",
|
||||||
"--linux-shortcut"
|
"--linux-shortcut",
|
||||||
)
|
|
||||||
imageOptions = listOf(
|
|
||||||
"--linux-deb-maintainer", "nozik.aa@mipt.ru",
|
"--linux-deb-maintainer", "nozik.aa@mipt.ru",
|
||||||
"--linux-menu-group", "Science",
|
"--linux-menu-group", "Science",
|
||||||
"--linux-shortcut"
|
"--linux-shortcut"
|
||||||
|
@ -173,8 +173,10 @@ class DataController : Controller(), ContextAware {
|
|||||||
sc.remove(id)
|
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) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun loadDirectory(path: Path){
|
||||||
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)
|
|
||||||
app.context.launch {
|
app.context.launch {
|
||||||
val path = rootDir.toPath()
|
|
||||||
dataController.clear()
|
dataController.clear()
|
||||||
runLater {
|
runLater {
|
||||||
pathProperty.set(path)
|
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private fun loadFile(path: Path){
|
||||||
val file = chooser.showOpenDialog(primaryStage.scene.window)
|
|
||||||
if (file != null) {
|
|
||||||
NumassProperties.setNumassProperty("numass.viewer.lastPath",
|
|
||||||
file.parentFile.absolutePath)
|
|
||||||
app.context.launch {
|
app.context.launch {
|
||||||
val path = file.toPath()
|
|
||||||
dataController.clear()
|
dataController.clear()
|
||||||
runLater {
|
runLater {
|
||||||
pathProperty.set(file.toPath())
|
pathProperty.set(path)
|
||||||
contentView = null
|
contentView = null
|
||||||
}
|
}
|
||||||
//Reading individual file
|
//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) {
|
} catch (ex: Exception) {
|
||||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
||||||
error("Error", content = "Failed to laod file with message: ${ex.message}")
|
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") {
|
button("Watch directory") {
|
||||||
action {
|
action {
|
||||||
val chooser = DirectoryChooser()
|
val chooser = DirectoryChooser()
|
||||||
chooser.title = "Select directory to view"
|
chooser.title = "Select directory to watch"
|
||||||
val homeDir = NumassProperties.getNumassProperty("numass.viewer.lastPath")
|
val homeDir = NumassProperties.getNumassProperty("numass.viewer.lastPath")
|
||||||
try {
|
try {
|
||||||
if (homeDir == null) {
|
if (homeDir == null) {
|
||||||
@ -199,15 +233,7 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
|
|||||||
|
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", dir.absolutePath)
|
NumassProperties.setNumassProperty("numass.viewer.lastPath", dir.absolutePath)
|
||||||
app.context.launch {
|
watchDirectory(dir.toPath())
|
||||||
val path = dir.toPath()
|
|
||||||
dataController.clear()
|
|
||||||
runLater {
|
|
||||||
pathProperty.set(path)
|
|
||||||
contentView = directoryWatchView
|
|
||||||
dataController.watchPathProperty.set(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
NumassProperties.setNumassProperty("numass.viewer.lastPath", null)
|
||||||
|
Loading…
Reference in New Issue
Block a user