<commit_before>package rpgboss.editor

import scala.swing._
import scala.swing.event._
import com.typesafe.scalalogging.slf4j.LazyLogging
import java.lang.Thread.UncaughtExceptionHandler
import javax.swing.UIManager
import javax.imageio.ImageIO
import rpgboss.editor.Internationalized._

object RpgDesktop
  extends SwingApplication
  with LazyLogging
  with UncaughtExceptionHandler {

  def top() = new MainFrame {
    minimumSize = new Dimension(600, 400)
    resizable = false
    centerOnScreen()
    title = getMessage("rpgboss")

    import javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE
    peer.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE)

    val mainPanel = new MainPanel(this)

    contents = mainPanel

    override def closeOperation() = {
      if (mainPanel.askSaveUnchanged()) {
        super.closeOperation()
      }
      if(VisibleConnection.currentSession!=null) {
        VisibleConnection.currentSession.close()
      }
    }
  }

  def uncaughtException(thread: Thread, ex: Throwable) = {
    logger.error("Uncaught exception")
    ex.printStackTrace()
  }

  def handle(ex: Throwable) = {
    uncaughtException(Thread.currentThread(), ex)
  }

  override def startup(args: Array[String]) = {
    UIManager.setLookAndFeel(
      UIManager.getSystemLookAndFeelClassName());
    
    val icon = rpgboss.lib.Utils.readClasspathImage("icon.png")
    
    System.setProperty("sun.awt.exception.handler", "rpgboss.editor.EDTErrorHandler");
    Thread.setDefaultUncaughtExceptionHandler(this);

    // code adapted from SimpleSwingApplication.scala
    val t = top()
    t.peer.setIconImage(icon)
    if (t.size == new Dimension(0, 0)) t.pack()
    t.visible = true
  }
  
  override def main(args: Array[String]) {
    if (args.size >= 2 && args.head == "--player") {
      rpgboss.player.LwjglPlayer.main(args.tail)
    } else {
      super.main(args)
    }
  }
}

class EDTErrorHandler {
  /**
   * This method is invoked by the AWT event dispatch mechanism when an
   * unexpected exception or error is thrown during event dispatching.
   */
  def handle(t: Throwable) {
    t.printStackTrace()
  }
}
<commit_msg>Allow overriding of look and feel. Fixes #420<commit_after>package rpgboss.editor

import scala.swing._
import scala.swing.event._
import com.typesafe.scalalogging.slf4j.LazyLogging
import java.lang.Thread.UncaughtExceptionHandler
import javax.swing.UIManager
import javax.imageio.ImageIO
import rpgboss.editor.Internationalized._

object RpgDesktop
  extends SwingApplication
  with LazyLogging
  with UncaughtExceptionHandler {

  def top() = new MainFrame {
    minimumSize = new Dimension(600, 400)
    resizable = false
    centerOnScreen()
    title = getMessage("rpgboss")

    import javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE
    peer.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE)

    val mainPanel = new MainPanel(this)

    contents = mainPanel

    override def closeOperation() = {
      if (mainPanel.askSaveUnchanged()) {
        super.closeOperation()
      }
      if(VisibleConnection.currentSession!=null) {
        VisibleConnection.currentSession.close()
      }
    }
  }

  def uncaughtException(thread: Thread, ex: Throwable) = {
    logger.error("Uncaught exception")
    ex.printStackTrace()
  }

  def handle(ex: Throwable) = {
    uncaughtException(Thread.currentThread(), ex)
  }

  override def startup(args: Array[String]) = {
    if (System.getProperty("swing.defaultlaf") == null) {
      UIManager.setLookAndFeel(
        UIManager.getSystemLookAndFeelClassName());
    }

    val icon = rpgboss.lib.Utils.readClasspathImage("icon.png")

    System.setProperty("sun.awt.exception.handler", "rpgboss.editor.EDTErrorHandler");
    Thread.setDefaultUncaughtExceptionHandler(this);

    // code adapted from SimpleSwingApplication.scala
    val t = top()
    t.peer.setIconImage(icon)
    if (t.size == new Dimension(0, 0)) t.pack()
    t.visible = true
  }

  override def main(args: Array[String]) {
    if (args.size >= 2 && args.head == "--player") {
      rpgboss.player.LwjglPlayer.main(args.tail)
    } else {
      super.main(args)
    }
  }
}

class EDTErrorHandler {
  /**
   * This method is invoked by the AWT event dispatch mechanism when an
   * unexpected exception or error is thrown during event dispatching.
   */
  def handle(t: Throwable) {
    t.printStackTrace()
  }
}
{'fraction_non_alphanumeric': 0.10543204217281688, 'fraction_numerical': 0.005271602108640843, 'mean_word_length': 3.4989690721649485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3745531', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1375, 'n_words': 278}