All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.maizegenetics.gui.FileChooserUtils.kt Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 6.0.1
Show newest version
@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

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy