INNER CODE UNIT · Kotlin
setDownloadDirectoryAction
Shabinder/SpotiFlyer · desktop/src/jvmMain/kotlin/Main.kt:134
override fun setDownloadDirectoryAction(callBack: (String) -> Unit) {
val fileChooser = JFileChooser().apply {
fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
}
when (fileChooser.showOpenDialog(appWindow)) {
APPROVE_OPTION -> {
val directory = fileChooser.selectedFile
if (directory.canWrite()) {
preferenceManager.setDownloadDirectory(directory.absolutePath)
callBack(directory.absolutePath)
showPopUpMessage("${Strings.setDownloadDirectory()} \n${fileManager.defaultDir()}")
} else {
showPopUpMessage(Strings.noWriteAccess("\n${directory.absolutePath} "))
}
}
else -> {
showPopUpMessage("No Directory Selected")
}