1 package jp.ymir.taskReporter.ui
2 import java.awt.Dimension
4 import javax.swing.JOptionPane
5 import javax.swing.KeyStroke
6 import javax.swing.event.MenuListener
7 import javax.swing.event.MenuEvent
8 import jp.ymir.taskReporter._
9 import jp.ymir.taskReporter.core._
11 import scala.swing.event._
13 class MainFrame(reportFile: Option[File]) extends Frame {
14 private val reportSet: ReportSet = new ReportSet(reportFile)
16 title = "Task Reporter" + Main.getVersion
18 // FIXME: Provide a way to configure this.
19 size = new Dimension(640, 480)
22 override def closeOperation {
24 val r = JOptionPane.showConfirmDialog(
26 "The report file \"" + reportSet.file.get.getName + "\" has been modified.\n" +
27 "Do you want to save it before closing?",
29 JOptionPane.YES_NO_CANCEL_OPTION);
32 case JOptionPane.YES_OPTION =>
35 case JOptionPane.NO_OPTION =>
45 def dirty : Boolean = {
46 return reportSet.dirty
49 menuBar = new MenuBar {
50 contents += new Menu("File") {
53 contents += new MenuItem(new Action("Open...") {
54 accelerator = Some(KeyStroke.getKeyStroke("control O"))
60 val save = new MenuItem(new Action("Save") {
61 accelerator = Some(KeyStroke.getKeyStroke("control S"));
67 peer.addMenuListener(new MenuListener {
68 def menuSelected(e: MenuEvent) {
71 if (reportSet.file.isEmpty)
76 def menuDeselected(e: MenuEvent) {}
77 def menuCanceled(e: MenuEvent) {}