BugFix double click on file dialog
parent
71bd09e88f
commit
6e3486ef98
|
@ -1,11 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.*
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material.Button
|
import androidx.compose.material.Button
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
|
@ -66,8 +65,9 @@ fun commonWordsTable(
|
||||||
.height(500.dp)
|
.height(500.dp)
|
||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
) {
|
) {
|
||||||
|
val scrollState = rememberLazyListState()
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
|
state = scrollState,
|
||||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||||
content = {
|
content = {
|
||||||
stickyHeader {
|
stickyHeader {
|
||||||
|
@ -83,6 +83,10 @@ fun commonWordsTable(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
VerticalScrollbar(
|
||||||
|
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||||
|
adapter = rememberScrollbarAdapter(scrollState)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,15 @@ import org.apache.poi.ss.usermodel.Workbook
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||||
import java.awt.FileDialog
|
import java.awt.FileDialog
|
||||||
import java.awt.Frame
|
import java.awt.Frame
|
||||||
import java.io.File
|
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
data class Glossary(val name: String, val jsonFilePath: String)
|
data class Glossary(val name: String, val jsonFilePath: String)
|
||||||
|
|
||||||
|
val frame = Frame()
|
||||||
@OptIn(ExperimentalMaterialApi::class)
|
@OptIn(ExperimentalMaterialApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun glossaryPage(
|
fun glossaryPage(
|
||||||
|
@ -81,7 +82,10 @@ fun glossaryPage(
|
||||||
text = { Text("Le fichier a été importé avec succès") },
|
text = { Text("Le fichier a été importé avec succès") },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
Button(
|
Button(
|
||||||
onClick = { importedSuccessfully.value = false },
|
onClick = {
|
||||||
|
importedSuccessfully.value = false
|
||||||
|
frame.dispose()
|
||||||
|
},
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
backgroundColor = customRedColor,
|
backgroundColor = customRedColor,
|
||||||
contentColor = Color.White
|
contentColor = Color.White
|
||||||
|
@ -157,12 +161,12 @@ fun glossaryPage(
|
||||||
var importedSuccessfully = mutableStateOf(false)
|
var importedSuccessfully = mutableStateOf(false)
|
||||||
var exportedSuccessfully = mutableStateOf(false)
|
var exportedSuccessfully = mutableStateOf(false)
|
||||||
fun selectFile(extensions: Set<String>, onFileSelected: (String) -> Unit) {
|
fun selectFile(extensions: Set<String>, onFileSelected: (String) -> Unit) {
|
||||||
val fileDialog = FileDialog(Frame(), "Select a file", FileDialog.LOAD)
|
|
||||||
|
val fileDialog = FileDialog(frame, "Select a file", FileDialog.LOAD)
|
||||||
fileDialog.isMultipleMode = true // To enable selecting only one file
|
fileDialog.isMultipleMode = true // To enable selecting only one file
|
||||||
fileDialog.file = "*." + extensions.joinToString(";*.")
|
fileDialog.file = "*." + extensions.joinToString(";*.")
|
||||||
fileDialog.isVisible = true
|
fileDialog.isVisible = true
|
||||||
|
|
||||||
|
|
||||||
val selectedFiles = fileDialog.files
|
val selectedFiles = fileDialog.files
|
||||||
|
|
||||||
if (selectedFiles != null) {
|
if (selectedFiles != null) {
|
||||||
|
@ -180,6 +184,7 @@ fun selectFile(extensions: Set<String>, onFileSelected: (String) -> Unit) {
|
||||||
} else {
|
} else {
|
||||||
println("Open command cancelled by user.")
|
println("Open command cancelled by user.")
|
||||||
}
|
}
|
||||||
|
frame.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exportToCSV(glossary: Glossary, csvFilePath: String) {
|
fun exportToCSV(glossary: Glossary, csvFilePath: String) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.*
|
||||||
import androidx.compose.foundation.clickable
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
@ -156,8 +156,10 @@ fun GlossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
|
||||||
.height(500.dp)
|
.height(500.dp)
|
||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
) {
|
) {
|
||||||
|
val scrollState = rememberLazyListState()
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.padding(10.dp),
|
state = scrollState,
|
||||||
|
modifier = Modifier.padding(10.dp).border(1.dp, Color.Black),
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
) {
|
) {
|
||||||
items(glossaries) { glossary ->
|
items(glossaries) { glossary ->
|
||||||
|
@ -169,6 +171,9 @@ fun GlossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
|
||||||
onClick = {
|
onClick = {
|
||||||
onGlossarySelected(glossary)
|
onGlossarySelected(glossary)
|
||||||
},
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.width(150.dp)
|
||||||
|
.padding(10.dp, 0.dp, 0.dp, 0.dp),
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
backgroundColor = customRedColor,
|
backgroundColor = customRedColor,
|
||||||
contentColor = Color.White
|
contentColor = Color.White
|
||||||
|
@ -179,8 +184,11 @@ fun GlossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
VerticalScrollbar(
|
||||||
|
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||||
|
adapter = rememberScrollbarAdapter(scrollState)
|
||||||
|
)
|
||||||
Spacer(modifier = Modifier.height(6.dp))
|
Spacer(modifier = Modifier.height(6.dp))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import androidx.compose.desktop.ui.tooling.preview.Preview
|
import androidx.compose.desktop.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.foundation.VerticalScrollbar
|
||||||
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
import androidx.compose.foundation.rememberScrollbarAdapter
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Delete
|
import androidx.compose.material.icons.filled.Delete
|
||||||
|
@ -70,8 +74,11 @@ fun app() {
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(300.dp)
|
.height(300.dp)
|
||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
|
.border(1.dp, Color.Black)
|
||||||
) {
|
) {
|
||||||
|
val scrollState = rememberLazyListState()
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
|
state = scrollState,
|
||||||
modifier = Modifier.padding(10.dp),
|
modifier = Modifier.padding(10.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
) {
|
) {
|
||||||
|
@ -108,6 +115,10 @@ fun app() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
VerticalScrollbar(
|
||||||
|
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||||
|
adapter = rememberScrollbarAdapter(scrollState)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
Loading…
Reference in New Issue