From dbc1f8a35469fd6511badbbf86251494b84e0c5a Mon Sep 17 00:00:00 2001 From: Thomas BREIL Date: Thu, 7 Dec 2023 16:21:48 +0100 Subject: [PATCH] Allow Multiple files to parse --- src/main/kotlin/main/Main.kt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/main/Main.kt b/src/main/kotlin/main/Main.kt index 60c41b9..6114fce 100644 --- a/src/main/kotlin/main/Main.kt +++ b/src/main/kotlin/main/Main.kt @@ -233,24 +233,24 @@ fun app() { fun selectFile(extensions: Set, onFileSelected: (String) -> Unit) { val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD) - fileDialog.isMultipleMode = false // To enable selecting only one file + fileDialog.isMultipleMode = true // To enable selecting only one file fileDialog.file = "*." + extensions.joinToString(";*.") fileDialog.isVisible = true - val selectedFile = fileDialog.file - val selectedDirectory = fileDialog.directory + val selectedFiles = fileDialog.files - if (selectedFile != null) { - val filePath = "$selectedDirectory$selectedFile" - - // Vérifier si l'extension est autorisée - val fileExtension = File(filePath).extension.lowercase() - if (extensions.contains(fileExtension)) { - println("Opening: $filePath") - onFileSelected(filePath) - } else { - println("Invalid file extension.") + if (selectedFiles != null) { + for (file in selectedFiles) { + println("Selected file: $file") + // Vérifier si l'extension est autorisée + val fileExtension = File(file.absolutePath).extension.lowercase() + if (extensions.contains(fileExtension)) { + println("Opening: $file") + onFileSelected(file.absolutePath) + } else { + println("Invalid file extension.") + } } } else { println("Open command cancelled by user.")