Changed file loader (now using OS's file loader)
parent
3791cb99ef
commit
45f9385bc8
|
@ -12,11 +12,8 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Check
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import javax.swing.JFileChooser
|
import java.awt.FileDialog
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter
|
import java.awt.Frame
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -69,12 +66,19 @@ fun App() {
|
||||||
glossairePage(
|
glossairePage(
|
||||||
onAjouterMotClick = { currentPage.value = "formulaire" },
|
onAjouterMotClick = { currentPage.value = "formulaire" },
|
||||||
onImporterClick = {
|
onImporterClick = {
|
||||||
val fileChooser = JFileChooser()
|
val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD)
|
||||||
fileChooser.fileFilter = FileNameExtensionFilter("CSV Files", "csv")
|
fileDialog.file = "Untitled.csv" // Initial file name
|
||||||
val returnVal = fileChooser.showOpenDialog(null)
|
fileDialog.isMultipleMode = false // To enable selecting only one file
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
|
||||||
val file = fileChooser.selectedFile
|
fileDialog.setFile("*.csv")
|
||||||
println("Opening: " + file.name + ".")
|
fileDialog.isVisible = true
|
||||||
|
|
||||||
|
val selectedFile = fileDialog.file
|
||||||
|
val selectedDirectory = fileDialog.directory
|
||||||
|
|
||||||
|
if (selectedFile != null) {
|
||||||
|
val filePath = selectedDirectory + selectedFile
|
||||||
|
println("Opening: $filePath")
|
||||||
} else {
|
} else {
|
||||||
println("Open command cancelled by user.")
|
println("Open command cancelled by user.")
|
||||||
}
|
}
|
||||||
|
@ -90,34 +94,52 @@ fun App() {
|
||||||
ChoixLangagePage(
|
ChoixLangagePage(
|
||||||
onRetourClick = { currentPage.value = "accueil" },
|
onRetourClick = { currentPage.value = "accueil" },
|
||||||
onPythonClick = {
|
onPythonClick = {
|
||||||
val fileChooser = JFileChooser()
|
val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD)
|
||||||
fileChooser.fileFilter = FileNameExtensionFilter("Python Files", "py")
|
fileDialog.file = "Untitled.py" // Initial file name
|
||||||
val returnVal = fileChooser.showOpenDialog(null)
|
fileDialog.isMultipleMode = false // To enable selecting only one file
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
fileDialog.setFile("*.py")
|
||||||
val file = fileChooser.selectedFile
|
fileDialog.isVisible = true
|
||||||
println("Opening: " + file.name + ".")
|
|
||||||
|
val selectedFile = fileDialog.file
|
||||||
|
val selectedDirectory = fileDialog.directory
|
||||||
|
|
||||||
|
if (selectedFile != null) {
|
||||||
|
val filePath = selectedDirectory + selectedFile
|
||||||
|
println("Opening: $filePath")
|
||||||
} else {
|
} else {
|
||||||
println("Open command cancelled by user.")
|
println("Open command cancelled by user.")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onJavaClick = {
|
onJavaClick = {
|
||||||
val fileChooser = JFileChooser()
|
val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD)
|
||||||
fileChooser.fileFilter = FileNameExtensionFilter("Java Files", "java")
|
fileDialog.file = "Untitled.java" // Initial file name
|
||||||
val returnVal = fileChooser.showOpenDialog(null)
|
fileDialog.isMultipleMode = false // To enable selecting only one file
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
fileDialog.setFile("*.java")
|
||||||
val file = fileChooser.selectedFile
|
fileDialog.isVisible = true
|
||||||
println("Opening: " + file.name + ".")
|
|
||||||
|
val selectedFile = fileDialog.file
|
||||||
|
val selectedDirectory = fileDialog.directory
|
||||||
|
|
||||||
|
if (selectedFile != null) {
|
||||||
|
val filePath = selectedDirectory + selectedFile
|
||||||
|
println("Opening: $filePath")
|
||||||
} else {
|
} else {
|
||||||
println("Open command cancelled by user.")
|
println("Open command cancelled by user.")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onJavaScriptClick = {
|
onJavaScriptClick = {
|
||||||
val fileChooser = JFileChooser()
|
val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD)
|
||||||
fileChooser.fileFilter = FileNameExtensionFilter("JavaScript Files", "js")
|
fileDialog.file = "Untitled.js" // Initial file name
|
||||||
val returnVal = fileChooser.showOpenDialog(null)
|
fileDialog.isMultipleMode = false // To enable selecting only one file
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
fileDialog.setFile("*.js")
|
||||||
val file = fileChooser.selectedFile
|
fileDialog.isVisible = true
|
||||||
println("Opening: " + file.name + ".")
|
|
||||||
|
val selectedFile = fileDialog.file
|
||||||
|
val selectedDirectory = fileDialog.directory
|
||||||
|
|
||||||
|
if (selectedFile != null) {
|
||||||
|
val filePath = selectedDirectory + selectedFile
|
||||||
|
println("Opening: $filePath")
|
||||||
} else {
|
} else {
|
||||||
println("Open command cancelled by user.")
|
println("Open command cancelled by user.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue