net.maizegenetics.gui.FileChooserUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tassel6 Show documentation
Show all versions of tassel6 Show documentation
TASSEL 6 is a software package to evaluate traits association. Feature Tables are at the heart of the package where, a feature is a range of positions or a single position. Row in the that table are taxon.
@file:JvmName("FileChooserUtils")
package net.maizegenetics.gui
import javafx.application.Platform
import javafx.concurrent.Task
import javafx.stage.FileChooser
import net.maizegenetics.prefs.TasselPrefs
import net.maizegenetics.tassel.TASSELGUI
import java.io.File
/**
* @author Terry Casstevens
* Created November 05, 2018
*/
private val open = FileChooser().also {
it.initialDirectory = File(TasselPrefs.getOpenDir())
}
fun singeFile(): File? {
val task = object : Task() {
override fun call(): File? {
return open.showOpenDialog(TASSELGUI.instance.primaryStage)
}
}
Platform.runLater(task)
val result = task.get()
if (result != null) {
TasselPrefs.putOpenDir(result.absolutePath.substringBeforeLast('/'))
}
return result
}
fun multipleFiles(): List? {
val task = object : Task?>() {
override fun call(): List? {
return open.showOpenMultipleDialog(TASSELGUI.instance.primaryStage)
}
}
Platform.runLater(task)
val result = task.get()
if (result != null) {
TasselPrefs.putOpenDir(result[0].absolutePath.substringBeforeLast('/'))
}
return result
}