<commit_before>/*
 * Copyright (c) 2013, The National Archives <EMAIL>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package uk.gov.tna.dri.ui

import scala.swing._
import javax.swing._
import net.java.dev.designgridlayout._
import java.io.{File, PrintWriter}
import table.DefaultTableModel
import uk.gov.tna.dri.validator.MetaDataValidatorCommandLineApp
import swing.GridBagPanel.Anchor
import uk.gov.tna.dri.ui.DesignGridImplicits._
import scala.swing.PopupMenuImplicits._
import ScalaSwingHelpers._

/**
 * Simple GUI for the CSV Validator
 */
object CsvValidatorUi extends SimpleSwingApplication {

  override def startup(args: Array[String]) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName)
    } catch {
      case ue : UnsupportedLookAndFeelException =>
        JOptionPane.showMessageDialog(this.top.peer, "Unable to set native look and feel: " + ue.getMessage, "Look and Feel Warning", JOptionPane.WARNING_MESSAGE)
    }
    super.startup(args)
  }

  def top = new MainFrame {
    title = "CSV Validator"
    contents = new ContentPanel(new SettingsPanel)
  }

  private def validate(csvFilePath: String, csvSchemaFilePath: String, failOnFirstError: Boolean, pathSubstitutions: List[(String, String)], output: TextComponent) {
    output.text = MetaDataValidatorCommandLineApp.processMetaData(csvFilePath, csvSchemaFilePath, failOnFirstError, pathSubstitutions)._1
  }
<commit_msg>[bugfix] Make sure to clear previous output to indicate that processing is occuring [bugfix] Make sure to catch exceptions and display at least an error in the output window, otherwise if the user is not running the app from a terminal they may not see any error - just blank output!<commit_after>/*
 * Copyright (c) 2013, The National Archives <EMAIL>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package uk.gov.tna.dri.ui

import scala.swing._
import javax.swing._
import net.java.dev.designgridlayout._
import java.io.{File, PrintWriter}
import table.DefaultTableModel
import uk.gov.tna.dri.validator.MetaDataValidatorCommandLineApp
import swing.GridBagPanel.Anchor
import uk.gov.tna.dri.ui.DesignGridImplicits._
import scala.swing.PopupMenuImplicits._
import ScalaSwingHelpers._

/**
 * Simple GUI for the CSV Validator
 */
object CsvValidatorUi extends SimpleSwingApplication {

  override def startup(args: Array[String]) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName)
    } catch {
      case ue : UnsupportedLookAndFeelException =>
        JOptionPane.showMessageDialog(this.top.peer, "Unable to set native look and feel: " + ue.getMessage, "Look and Feel Warning", JOptionPane.WARNING_MESSAGE)
    }
    super.startup(args)
  }

  def top = new MainFrame {
    title = "CSV Validator"
    contents = new ContentPanel(new SettingsPanel)
  }

  private def validate(csvFilePath: String, csvSchemaFilePath: String, failOnFirstError: Boolean, pathSubstitutions: List[(String, String)], output: TextComponent) {
    output.text = ""
    try {
      output.text = MetaDataValidatorCommandLineApp.processMetaData(csvFilePath, csvSchemaFilePath, failOnFirstError, pathSubstitutions)._1
    } catch {
      case e: Throwable =>
        output.text = e.toString
        e.printStackTrace()
    }
  }

{'fraction_non_alphanumeric': 0.08804680969629423, 'fraction_numerical': 0.005015324602953469, 'mean_word_length': 4.21044992743106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2016329', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1064, 'n_words': 316}