last import dir is now stored and used for next import
This commit is contained in:
		@ -3,28 +3,42 @@ package org.hso.texturesyncclient.view.importView
 | 
			
		||||
import javafx.stage.FileChooser.ExtensionFilter
 | 
			
		||||
import org.hso.texturesyncclient.controller.RootController
 | 
			
		||||
import tornadofx.Controller
 | 
			
		||||
import tornadofx.FileChooserMode
 | 
			
		||||
import tornadofx.chooseFile
 | 
			
		||||
import javafx.stage.FileChooser
 | 
			
		||||
import java.io.File
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ImportViewController : Controller() {
 | 
			
		||||
 | 
			
		||||
    private val iv = find(ImportView::class)
 | 
			
		||||
    private val rootc = find(RootController::class)
 | 
			
		||||
 | 
			
		||||
    fun btnFileChooserAction() {
 | 
			
		||||
        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)
 | 
			
		||||
    private var lastImportDir: String = System.getProperty("user.home")
 | 
			
		||||
 | 
			
		||||
        if (file.isNotEmpty()) {
 | 
			
		||||
            iv.tfFilePath.text = file[0].absolutePath
 | 
			
		||||
            iv.tfName.text = file[0].nameWithoutExtension
 | 
			
		||||
    fun btnFileChooserAction() {
 | 
			
		||||
        val fileChooser = FileChooser()
 | 
			
		||||
        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() {
 | 
			
		||||
        rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips)
 | 
			
		||||
        rootc.switchImportToMain()
 | 
			
		||||
        iv.tfFilePath.clear()
 | 
			
		||||
        iv.tfName.clear()
 | 
			
		||||
        iv.cvTags.chips.clear()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun validateImport() {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user