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