last import dir is now stored and used for next import
This commit is contained in:
parent
ed344cbd49
commit
f45d807536
@ -3,28 +3,42 @@ package org.hso.texturesyncclient.view.importView
|
|||||||
import javafx.stage.FileChooser.ExtensionFilter
|
import javafx.stage.FileChooser.ExtensionFilter
|
||||||
import org.hso.texturesyncclient.controller.RootController
|
import org.hso.texturesyncclient.controller.RootController
|
||||||
import tornadofx.Controller
|
import tornadofx.Controller
|
||||||
import tornadofx.FileChooserMode
|
import javafx.stage.FileChooser
|
||||||
import tornadofx.chooseFile
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class ImportViewController : Controller() {
|
class ImportViewController : Controller() {
|
||||||
|
|
||||||
private val iv = find(ImportView::class)
|
private val iv = find(ImportView::class)
|
||||||
private val rootc = find(RootController::class)
|
private val rootc = find(RootController::class)
|
||||||
|
|
||||||
fun btnFileChooserAction() {
|
private var lastImportDir: String = System.getProperty("user.home")
|
||||||
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()) {
|
fun btnFileChooserAction() {
|
||||||
iv.tfFilePath.text = file[0].absolutePath
|
val fileChooser = FileChooser()
|
||||||
iv.tfName.text = file[0].nameWithoutExtension
|
val fileExtensions = FileChooser.ExtensionFilter(
|
||||||
|
"Texturen vom Bildformat: PNG oder JPEG", "*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG"
|
||||||
|
)
|
||||||
|
|
||||||
|
fileChooser.extensionFilters.addAll(fileExtensions)
|
||||||
|
fileChooser.initialDirectory = File(lastImportDir)
|
||||||
|
fileChooser.title = "Textur auswählen"
|
||||||
|
|
||||||
|
val file = fileChooser.showOpenDialog(null)
|
||||||
|
|
||||||
|
if (file != null) {
|
||||||
|
iv.tfFilePath.text = file.absolutePath
|
||||||
|
iv.tfName.text = file.nameWithoutExtension
|
||||||
|
lastImportDir = file.parent.toString() //store last user chosen dir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun btnImportAction() {
|
fun btnImportAction() {
|
||||||
rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips)
|
rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips)
|
||||||
rootc.switchImportToMain()
|
rootc.switchImportToMain()
|
||||||
|
iv.tfFilePath.clear()
|
||||||
|
iv.tfName.clear()
|
||||||
|
iv.cvTags.chips.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun validateImport() {
|
fun validateImport() {
|
||||||
|
Loading…
Reference in New Issue
Block a user