Skip to content

Commit

Permalink
Merge pull request #530 from digital-preservation/DR2-2052-File-open-…
Browse files Browse the repository at this point in the history
…dialog-for-CSV-and-CSVS-files-have-become-multiselect-when-run-on-java-21

Dr2 2052 file open dialog for csv and csvs files have become multiselect when run on java 21
  • Loading branch information
sparkhi authored Jan 31, 2025
2 parents 72fdc31 + 9a4a563 commit 3b390ab
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ object CsvValidatorUi extends SimpleSwingApplication {
}

private def extractFromManifest[T](extractor: Attributes => T): Option[T] = {
val clazz = getClass()
val clazz = getClass
val className = clazz.getSimpleName + ".class"
val classPath = clazz.getResource(className).toString()
val classPath = clazz.getResource(className).toString
if (!classPath.startsWith("jar")) {
None // Class not from JAR
} else {
Expand Down Expand Up @@ -301,6 +301,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
}

private val csvFileChooser = new FileChooser(lastCsvPath)
csvFileChooser.multiSelectionEnabled = false
csvFileChooser.title = "Select a .csv file"
csvFileChooser.fileFilter = new FileNameExtensionFilter("CSV file (*.csv)", "csv")
private val btnChooseCsvFile = new Button("...")
Expand All @@ -317,6 +318,7 @@ object CsvValidatorUi extends SimpleSwingApplication {

txtCsvSchemaFile.setTransferHandler(fileHandler)
private val csvSchemaFileChooser = new FileChooser(lastCsvPath)
csvSchemaFileChooser.multiSelectionEnabled = false
csvSchemaFileChooser.title = "Select a .csvs file"
csvSchemaFileChooser.fileFilter = new FileNameExtensionFilter("CSV Schema file (*.csvs)", "csvs" +
"")
Expand Down Expand Up @@ -414,6 +416,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
btnClose.reactions += onClick(quit())

private val reportFileChooser = new FileChooser(lastCsvPath)
reportFileChooser.multiSelectionEnabled = false
val dateFormat = new SimpleDateFormat("dd-mm-yy_HH-mm-ss")
reportFileChooser.selectedFile = new File(s"csv_validator_report_${dateFormat.format(new Date())}.txt")

Expand Down Expand Up @@ -517,6 +520,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
val fromFolderName = Path.of(fromPathField.text).getFileName
val helpText = s"Select the ${fromFolderName} folder"
val fileChooser = new FileChooser(startingDir)
fileChooser.multiSelectionEnabled = false
fileChooser.title = helpText
fileChooser.fileSelectionMode = SelectionMode.DirectoriesOnly
chooseFileOrDir(fileChooser, f => updateFileText(f), fileButton, helpText)
Expand All @@ -542,7 +546,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
}

def pathSubstitutions : List[(String, String)] = {
for(rowIdx <- (0 to model.getRowCount - 1)) yield (model.getValueAt(rowIdx, 0).asInstanceOf[String], model.getValueAt(rowIdx, 1).asInstanceOf[String])
for(rowIdx <- 0 to model.getRowCount - 1) yield (model.getValueAt(rowIdx, 0).asInstanceOf[String], model.getValueAt(rowIdx, 1).asInstanceOf[String])
}.toList
}

Expand Down

0 comments on commit 3b390ab

Please sign in to comment.