TextureSync/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt

42 lines
1.4 KiB
Kotlin
Raw Normal View History

package org.hso.texturesyncclient.view.importView
import javafx.stage.FileChooser.ExtensionFilter
2019-06-03 17:33:23 +02:00
import org.hso.texturesyncclient.controller.RootController
import tornadofx.Controller
import tornadofx.FileChooserMode
import tornadofx.chooseFile
class ImportViewController : Controller() {
2019-06-03 17:33:23 +02:00
private val iv = find(ImportView::class)
private val rootc = find(RootController::class)
fun btnFileChooserAction() {
2019-06-03 17:33:23 +02:00
val list = listOf("*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG")
val arrayFilter = arrayOf(ExtensionFilter("Texturen vom Bildformat: PNG oder JPG", list))
val file = chooseFile("Textur auswählen", arrayFilter, FileChooserMode.Single, owner = null)
if (file.isNotEmpty()) {
iv.tfFilePath.text = file[0].absolutePath
iv.tfName.text = file[0].nameWithoutExtension
}
}
2019-05-05 23:45:13 +02:00
2019-06-03 17:33:23 +02:00
fun btnImportAction() {
rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips)
2019-06-05 16:23:45 +02:00
rootc.switchImportToMain()
2019-06-03 17:33:23 +02:00
}
2019-05-05 23:45:13 +02:00
2019-06-03 17:33:23 +02:00
fun validateImport() {
2019-06-07 13:25:33 +02:00
iv.btnImport.isVisible =
iv.tfFilePath.text.isNotEmpty() && iv.tfName.text.isNotEmpty() && iv.cvTags.chips.isNotEmpty() && iv.cvTags.chips.stream().allMatch { x -> x.length < 32 }
}
2019-06-07 13:25:33 +02:00
fun btnBackAction() {
rootc.switchImportToMain()
iv.tfFilePath.clear()
iv.tfName.clear()
iv.cvTags.chips.clear()
}
}