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