@@ -40,7 +40,6 @@ import scala.util.Using
4040 * @author Adam Retter <[email protected] > 4141 */
4242object CsvValidatorUi extends SimpleSwingApplication {
43-
4443 override def startup (args : Array [String ]) : Unit = {
4544 try {
4645 UIManager .setLookAndFeel(UIManager .getSystemLookAndFeelClassName)
@@ -51,11 +50,12 @@ object CsvValidatorUi extends SimpleSwingApplication {
5150 super .startup(args)
5251 }
5352
54- def top = new SJXFrame {
53+ def top : SJXFrame = new SJXFrame {
54+
5555 title = " CSV Validator"
5656 peer.setDefaultCloseOperation(WindowConstants .EXIT_ON_CLOSE )
5757 contents = {
58- val settings = new SettingsPanel
58+ val settings = new SettingsPanel ( this )
5959
6060 // handle resizing the main window, when resizing the settings panel
6161 settings.settingsGroup.reactions += SJXTaskPane .onViewStateChanged {
@@ -64,22 +64,21 @@ object CsvValidatorUi extends SimpleSwingApplication {
6464 } else {
6565 new Dimension (this .size.getWidth.toInt, (this .size.getHeight + settings.size.getHeight).toInt)
6666 }
67- this .size = newSize
67+ this .preferredSize = newSize
6868 this .pack()
6969 }
70-
7170 new ContentPanel (settings)
7271 }
7372 }
7473
75- private def getShortVersion () : String = {
74+ private def getShortVersion : String = {
7675 extractFromManifest {
7776 attributes =>
7877 attributes.getValue(" Implementation-Version" )
7978 }.getOrElse(" UNKNOWN" )
8079 }
8180
82- private def getLongVersion () : Seq [(String , String )] = {
81+ private def getLongVersion : Seq [(String , String )] = {
8382 extractFromManifest {
8483 attributes =>
8584 Seq (
@@ -129,7 +128,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
129128
130129 private def validate (csvFilePath : String , csvEncoding : Charset , csvSchemaFilePath : String , csvSchemaEncoding : Charset , failOnFirstError : Boolean , pathSubstitutions : List [(String , String )], enforceCaseSensitivePathChecks : Boolean , progress : Option [ProgressCallback ], validateEncoding : Boolean )(output : String => Unit ) : Unit = {
131130
132- def toConsole (msg : String ) = Swing .onEDT {
131+ def toConsole (msg : String ): Unit = Swing .onEDT {
133132 output(msg)
134133 }
135134
@@ -159,7 +158,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
159158 failOnFirstError,
160159 pathSubstitutions,
161160 enforceCaseSensitivePathChecks,
162- false ,
161+ trace = false ,
163162 progress,
164163 rowCallback
165164 )._2 match {
@@ -173,8 +172,8 @@ object CsvValidatorUi extends SimpleSwingApplication {
173172 /**
174173 * Saves a String to a File
175174 *
176- * @param s
177- * @param f
175+ * @param s String to save to the file
176+ * @param f File to which the associated string is saved
178177 */
179178 private def saveToFile (s : String , f : Path ) : Option [IOException ] = {
180179 val data : Array [Byte ] = s.getBytes(UTF_8 )
@@ -189,7 +188,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
189188 case class Settings (lastCsvPath : Path , lastCsvSchemaPath : Path , lastReportPath : Path )
190189
191190 lazy val settingsFile : Path = Paths .get(System .getProperty(" user.home" )).resolve(" .csv-validator" ).resolve(" csv-validator.properties" )
192- lazy val userDir = Paths .get(System .getProperty(" user.dir" ))
191+ lazy val userDir : Path = Paths .get(System .getProperty(" user.dir" ))
193192
194193 private def loadSettings : Option [Settings ] = {
195194 if (Files .exists(settingsFile)) {
@@ -299,7 +298,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
299298
300299 override def update (total : Int , processed : Int ) : Unit = {
301300 Swing .onEDT {
302- progressBar.max = total.toInt
301+ progressBar.max = total
303302 progressBar.value = processed
304303 progressBar.label = s " Line ${processed} of ${total}"
305304 }
@@ -367,11 +366,11 @@ object CsvValidatorUi extends SimpleSwingApplication {
367366 })
368367 }
369368
370- private val lblVersion = new Label (s " Version: ${getShortVersion() }" )
369+ private val lblVersion = new Label (s " Version: ${getShortVersion}" )
371370 lblVersion.listenTo(lblVersion.mouse.clicks)
372371 lblVersion.font = lblVersion.font.deriveFont(9 )
373372 lblVersion.reactions += onClick {
374- Dialog .showMessage(this , getLongVersion() .map(x => s " ${x._1}: ${x._2}" ).mkString(System .getProperty(" line.separator" )), " Version Details" )
373+ Dialog .showMessage(this , getLongVersion.map(x => s " ${x._1}: ${x._2}" ).mkString(System .getProperty(" line.separator" )), " Version Details" )
375374 }
376375
377376 layout.row.grid(lblCsvFile).add(txtCsvFile, 5 ).add(btnChooseCsvFile)
@@ -408,7 +407,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
408407 * us to break up the code easily, hopefully
409408 * making it more understandable.
410409 */
411- private class SettingsPanel extends SJXTaskPaneContainer {
410+ private class SettingsPanel ( parentFrame : SJXFrame ) extends SJXTaskPaneContainer {
412411
413412 private lazy val CHARACTER_ENCODINGS =
414413 if (Charset .defaultCharset.name == " UTF-8" ) {
@@ -455,7 +454,7 @@ object CsvValidatorUi extends SimpleSwingApplication {
455454
456455 private val spTblPathSubstitutions = new ScrollPane (tblPathSubstitutions)
457456 private val btnAddPathSubstitution = new Button (" Add Path Substitution..." )
458- btnAddPathSubstitution.reactions += onClick(addToTableDialog(top , " Add Path Substitution..." , tblPathSubstitutions, tblPathSubstitutions.addRow))
457+ btnAddPathSubstitution.reactions += onClick(addToTableDialog(parentFrame , " Add Path Substitution..." , tblPathSubstitutions, tblPathSubstitutions.addRow))
459458
460459 private val settingsGroupLayout = new GridBagPanel {
461460 private val c = new Constraints
0 commit comments