<commit_before>package reshapes

import scala.collection.mutable.HashMap
import scala.events.behaviour.Var
import scala.swing.event.SelectionChanged
import scala.swing.Dimension
import scala.swing.Action
import scala.swing.BorderPanel
import scala.swing.Frame
import scala.swing.MainFrame
import scala.swing.Menu
import scala.swing.MenuBar
import scala.swing.MenuItem
import scala.swing.Separator
import scala.swing.SimpleSwingApplication
import scala.swing.TabbedPane
import reshapes.actions.LoadAction
import reshapes.actions.QuitAction
import reshapes.actions.SaveAction
import reshapes.actions.UndoAction
import reshapes.panels.CommandPanel
import reshapes.panels.DrawingPanel
import reshapes.panels.InfoPanel
import reshapes.panels.ShapePanel
import reshapes.panels.ShapeSelectionPanel
import reshapes.panels.StrokeInputPanel
import reshapes.Events
import sun.reflect.generics.reflectiveObjects.NotImplementedException
import org.omg.CORBA.Environment

object Reshapes extends SimpleSwingApplication {

  val tabbedPane = new TabbedPane()
  val currentTabIndex = new Var(0)
  // as event/Var
  var CurrentEvents: Events = new Events()
  val panelEvents = new HashMap[Int, Events]()

  // Panels
  var infoPanel = new InfoPanel(CurrentEvents)
  var shapePanel = new ShapePanel(CurrentEvents)
  var strokeInputPanel = new StrokeInputPanel(CurrentEvents)
  var shapeSelectionPanel = new ShapeSelectionPanel(CurrentEvents)
  var commandPanel = new CommandPanel(CurrentEvents)

  val ui = new BorderPanel {
    add(infoPanel, BorderPanel.Position.South)
    add(shapePanel, BorderPanel.Position.East)
    add(strokeInputPanel, BorderPanel.Position.North)
    add(shapeSelectionPanel, BorderPanel.Position.West)
    add(tabbedPane, BorderPanel.Position.Center)

    listenTo(tabbedPane.selection)

    reactions += {
      case SelectionChanged(`tabbedPane`) => {
        val currentEvents = panelEvents(tabbedPane.selection.index)
        infoPanel.events = currentEvents
        shapePanel.events = currentEvents
        strokeInputPanel.events = currentEvents
        shapeSelectionPanel.events = currentEvents
        commandPanel.events = currentEvents

        CurrentEvents = currentEvents
      }
    }
  }

  val menu = new MenuBar {
    val newTab = new MenuItem(Action("New tab") { addTab() })
    val closeTab = new MenuItem(Action("Remove selected tab") { removeTab() })
    val save = new MenuItem(new SaveAction())
    val load = new MenuItem(new LoadAction())
    val quit = new MenuItem(new QuitAction())
    val undo = new MenuItem(new UndoAction()) { enabled = false }
    val cmdWindow = new MenuItem(Action("show command window") { commandWindow.visible = true })

    CurrentEvents.Commands.changed += (commands => undo.enabled = !commands.isEmpty)

    contents += new Menu("File") {
      contents += newTab
      contents += closeTab
      contents += new Separator
      contents += save
      contents += load
      contents += new Separator
      contents += quit
    }
    contents += new Menu("Edit") {
      contents += undo
      contents += new Separator
      contents += cmdWindow
    }
  }

  def top = new MainFrame {
    title = "ReShapes"
    preferredSize = new Dimension(1000, 500)

    menuBar = menu
    contents = ui

    commandWindow.visible = true
  }

  def commandWindow = new Frame {
    title = "Command list"
    preferredSize = new Dimension(300, 500)
    contents = commandPanel
  }

  def addTab() {
    val event = new Events()
    panelEvents(tabbedPane.pages.size) = event
    val panel = new DrawingPanel(event)
    tabbedPane.pages += new TabbedPane.Page("newdrawing", panel)
  }

  def removeTab() {
    throw new NotImplementedException()
  }
}<commit_msg>set position to main window right to command window so both are visible at start<commit_after>package reshapes

import scala.collection.mutable.HashMap
import scala.events.behaviour.Var
import scala.swing.event.SelectionChanged
import scala.swing.Dimension
import scala.swing.Action
import scala.swing.BorderPanel
import scala.swing.Frame
import scala.swing.MainFrame
import scala.swing.Menu
import scala.swing.MenuBar
import scala.swing.MenuItem
import scala.swing.Separator
import scala.swing.SimpleSwingApplication
import scala.swing.TabbedPane
import reshapes.actions.LoadAction
import reshapes.actions.QuitAction
import reshapes.actions.SaveAction
import reshapes.actions.UndoAction
import reshapes.panels.CommandPanel
import reshapes.panels.DrawingPanel
import reshapes.panels.InfoPanel
import reshapes.panels.ShapePanel
import reshapes.panels.ShapeSelectionPanel
import reshapes.panels.StrokeInputPanel
import reshapes.Events
import sun.reflect.generics.reflectiveObjects.NotImplementedException
import org.omg.CORBA.Environment
import java.awt.Point

object Reshapes extends SimpleSwingApplication {

  val tabbedPane = new TabbedPane()
  val currentTabIndex = new Var(0)
  // as event/Var
  var CurrentEvents: Events = new Events()
  val panelEvents = new HashMap[Int, Events]()

  // Panels
  var infoPanel = new InfoPanel(CurrentEvents)
  var shapePanel = new ShapePanel(CurrentEvents)
  var strokeInputPanel = new StrokeInputPanel(CurrentEvents)
  var shapeSelectionPanel = new ShapeSelectionPanel(CurrentEvents)
  var commandPanel = new CommandPanel(CurrentEvents)

  val ui = new BorderPanel {
    add(infoPanel, BorderPanel.Position.South)
    add(shapePanel, BorderPanel.Position.East)
    add(strokeInputPanel, BorderPanel.Position.North)
    add(shapeSelectionPanel, BorderPanel.Position.West)
    add(tabbedPane, BorderPanel.Position.Center)

    listenTo(tabbedPane.selection)

    reactions += {
      case SelectionChanged(`tabbedPane`) => {
        val currentEvents = panelEvents(tabbedPane.selection.index)
        infoPanel.events = currentEvents
        shapePanel.events = currentEvents
        strokeInputPanel.events = currentEvents
        shapeSelectionPanel.events = currentEvents
        commandPanel.events = currentEvents

        CurrentEvents = currentEvents
      }
    }
  }

  val menu = new MenuBar {
    val newTab = new MenuItem(Action("New tab") { addTab() })
    val closeTab = new MenuItem(Action("Remove selected tab") { removeTab() })
    val save = new MenuItem(new SaveAction())
    val load = new MenuItem(new LoadAction())
    val quit = new MenuItem(new QuitAction())
    val undo = new MenuItem(new UndoAction()) { enabled = false }
    val cmdWindow = new MenuItem(Action("show command window") { commandWindow.visible = true })

    CurrentEvents.Commands.changed += (commands => undo.enabled = !commands.isEmpty)

    contents += new Menu("File") {
      contents += newTab
      contents += closeTab
      contents += new Separator
      contents += save
      contents += load
      contents += new Separator
      contents += quit
    }
    contents += new Menu("Edit") {
      contents += undo
      contents += new Separator
      contents += cmdWindow
    }
  }

  def top = new MainFrame {
    title = "ReShapes"
    preferredSize = new Dimension(1000, 500)
    this.location = new Point(commandWindow.location.x + commandWindow.size.width, commandWindow.location.y)

    menuBar = menu
    contents = ui

    commandWindow.visible = true
  }

  def commandWindow = new Frame {
    title = "Command list"
    preferredSize = new Dimension(300, 500)
    contents = commandPanel
  }

  def addTab() {
    val event = new Events()
    panelEvents(tabbedPane.pages.size) = event
    val panel = new DrawingPanel(event)
    tabbedPane.pages += new TabbedPane.Page("newdrawing", panel)
  }

  def removeTab() {
    throw new NotImplementedException()
  }
}
{'fraction_non_alphanumeric': 0.0859538784067086, 'fraction_numerical': 0.003668763102725367, 'mean_word_length': 3.852511125238398, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7576627', 'n_tokens_mistral': 2214, 'n_tokens_neox': 2130, 'n_words': 549}