From 10f84a69f2194ab7e4a3037734ed7e633c193cdd Mon Sep 17 00:00:00 2001 From: sparkhi <4743002+sparkhi@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:38:41 +0000 Subject: [PATCH 1/4] made all filechooser dialogs to be explicitly single select to cope with Java21 on linux --- .../nationalarchives/csv/validator/ui/CsvValidatorUi.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala index caf9c26d..572d6462 100644 --- a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala +++ b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala @@ -290,6 +290,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("...") @@ -306,6 +307,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" + "") @@ -402,6 +404,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") @@ -503,6 +506,7 @@ object CsvValidatorUi extends SimpleSwingApplication { val startingDir = if(fileTextField.text.isEmpty) userDir.toFile else Path.of(fileTextField.text).toFile val helpText = s"Select the ${fromPath.split("/").last} folder" val fileChooser = new FileChooser(startingDir) + fileChooser.multiSelectionEnabled = false fileChooser.title = helpText fileChooser.fileSelectionMode = SelectionMode.FilesAndDirectories chooseFile(fileChooser, f => updateFileText(f), fileButton, helpText) From 55ed63393b8f58ccad3d116c88a7d94d8fc04cad Mon Sep 17 00:00:00 2001 From: sparkhi <4743002+sparkhi@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:42:36 +0000 Subject: [PATCH 2/4] Cleanup of a few warnings --- .../csv/validator/ui/CsvValidatorUi.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala index 572d6462..1053f401 100644 --- a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala +++ b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala @@ -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 { @@ -346,7 +346,7 @@ object CsvValidatorUi extends SimpleSwingApplication { Swing.onEDT { progressBar.max = total progressBar.value = processed - progressBar.label = s"Line ${processed} of ${total}" + progressBar.label = s"Line $processed of $total" } } } @@ -417,11 +417,11 @@ object CsvValidatorUi extends SimpleSwingApplication { updateLastPath(reportFileChooser, path => Settings(path, path, path)) } - private val lblVersion = new Label(s"Version: ${getShortVersion}") + private val lblVersion = new Label(s"Version: $getShortVersion") lblVersion.listenTo(lblVersion.mouse.clicks) lblVersion.font = lblVersion.font.deriveFont(9) lblVersion.reactions += onClick { - Dialog.showMessage(this, getLongVersion.map(x => s"${x._1}: ${x._2}").mkString(System.getProperty("line.separator")), "Version Details") + Dialog.showMessage(this, getLongVersion.map(x => s"${x._1}: ${x._2}").mkString(java.lang.System.lineSeparator()), "Version Details") } layout.row.grid(lblCsvFile).add(txtCsvFile, 5).add(btnChooseCsvFile) @@ -519,7 +519,7 @@ object CsvValidatorUi extends SimpleSwingApplication { addToTableDialog(parentFrame, "Add Path Substitution...", rows, tblPathSubstitutions.addRow) } - private val tblPathSubstitutions = new Table(0, 2) { + private val tblPathSubstitutions: Table = new Table(0, 2) { preferredViewportSize = new Dimension(500, 70) model = new DefaultTableModel(Array[Object]("From", "To"), 0) @@ -532,7 +532,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 } From 766bf9a931c83628c5a7f4317218ad5e41213778 Mon Sep 17 00:00:00 2001 From: sparkhi <4743002+sparkhi@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:43:18 +0000 Subject: [PATCH 3/4] Cleanup of a few warnings --- .../gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala index 1053f401..ad611d70 100644 --- a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala +++ b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala @@ -519,7 +519,7 @@ object CsvValidatorUi extends SimpleSwingApplication { addToTableDialog(parentFrame, "Add Path Substitution...", rows, tblPathSubstitutions.addRow) } - private val tblPathSubstitutions: Table = new Table(0, 2) { + private val tblPathSubstitutions = new Table(0, 2) { preferredViewportSize = new Dimension(500, 70) model = new DefaultTableModel(Array[Object]("From", "To"), 0) From 9a4a56355caa4103618c6494c531fc9296c284e8 Mon Sep 17 00:00:00 2001 From: sparkhi <4743002+sparkhi@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:38:50 +0000 Subject: [PATCH 4/4] merged master into branch --- .../nationalarchives/csv/validator/ui/CsvValidatorUi.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala index 962be7d2..e6496f21 100644 --- a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala +++ b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala @@ -429,11 +429,11 @@ object CsvValidatorUi extends SimpleSwingApplication { updateLastPath(reportFileChooser, path => Settings(path, path, path)) } - private val lblVersion = new Label(s"Version: $getShortVersion") + private val lblVersion = new Label(s"Version: ${getShortVersion}") lblVersion.listenTo(lblVersion.mouse.clicks) lblVersion.font = lblVersion.font.deriveFont(9) lblVersion.reactions += onClick { - Dialog.showMessage(this, getLongVersion.map(x => s"${x._1}: ${x._2}").mkString(java.lang.System.lineSeparator()), "Version Details") + Dialog.showMessage(this, getLongVersion.map(x => s"${x._1}: ${x._2}").mkString(System.getProperty("line.separator")), "Version Details") } layout.row.grid(lblCsvFile).add(txtCsvFile, 5).add(btnChooseCsvFile)