]> gitweb @ CieloNegro.org - task-reporter.git/blobdiff - src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala
wip
[task-reporter.git] / src / main / scala / jp / ymir / taskReporter / ui / MainFrame.scala
index 3759437c664d32886a537faa6705fe0b79fdae03..4e7edbf578613c230a31676af9b46b7f9e110493 100644 (file)
@@ -28,59 +28,6 @@ class MainFrame(reportFile: Option[File]) extends Frame {
     }
   })
 
-  override def closeOperation {
-    if (dirty) {
-      val r = JOptionPane.showConfirmDialog(
-        peer,
-        "The report file \"" + reportSet.file.get.getName + "\" has been modified.\n" +
-          "Do you want to save it before closing?",
-        "Confirmation",
-        JOptionPane.YES_NO_CANCEL_OPTION);
-
-      r match {
-        case JOptionPane.YES_OPTION => save; dispose
-        case JOptionPane.NO_OPTION  => dispose
-        case _ =>
-      }
-    }
-    else {
-      dispose
-    }
-  }
-
-  def dirty : Boolean = {
-    return reportSet.dirty
-  }
-
-  def save {
-    if (reportSet.file.isEmpty) {
-      val chooser = new FileChooser(Preferences.lastChosenDir())
-      val r = chooser.showSaveDialog(null)
-      if (r != FileChooser.Result.Approve) {
-        return
-      }
-
-      if (chooser.selectedFile.exists) {
-        val r = JOptionPane.showConfirmDialog(
-          peer,
-          "The chosen file or directory \"" + chooser.selectedFile.getName + "\" already exists.\n" +
-            "Do you want to overwrite it?",
-          "Confirmation",
-          JOptionPane.YES_NO_OPTION)
-
-        r match {
-          case JOptionPane.YES_OPTION =>
-          case JOptionPane.NO_OPTION  => return
-        }
-      }
-
-      Preferences.lastChosenDir() = chooser.selectedFile.getParentFile
-      reportSet.file = Some(chooser.selectedFile)
-    }
-
-    reportSet.save
-  }
-
   menuBar = new MenuBar {
     contents += new Menu("File") {
       mnemonic = Key.F
@@ -155,4 +102,57 @@ class MainFrame(reportFile: Option[File]) extends Frame {
   }
 
   visible = true
+
+  override def closeOperation {
+    if (dirty) {
+      val r = JOptionPane.showConfirmDialog(
+        peer,
+        "The report file \"" + reportSet.file.get.getName + "\" has been modified.\n" +
+          "Do you want to save it before closing?",
+        "Confirmation",
+        JOptionPane.YES_NO_CANCEL_OPTION);
+
+      r match {
+        case JOptionPane.YES_OPTION => save; dispose
+        case JOptionPane.NO_OPTION  => dispose
+        case _ =>
+      }
+    }
+    else {
+      dispose
+    }
+  }
+
+  def dirty : Boolean = {
+    return reportSet.dirty
+  }
+
+  def save {
+    if (reportSet.file.isEmpty) {
+      val chooser = new FileChooser(Preferences.lastChosenDir())
+      val r = chooser.showSaveDialog(null)
+      if (r != FileChooser.Result.Approve) {
+        return
+      }
+
+      if (chooser.selectedFile.exists) {
+        val r = JOptionPane.showConfirmDialog(
+          peer,
+          "The chosen file or directory \"" + chooser.selectedFile.getName + "\" already exists.\n" +
+            "Do you want to overwrite it?",
+          "Confirmation",
+          JOptionPane.YES_NO_OPTION)
+
+        r match {
+          case JOptionPane.YES_OPTION =>
+          case JOptionPane.NO_OPTION  => return
+        }
+      }
+
+      Preferences.lastChosenDir() = chooser.selectedFile.getParentFile
+      reportSet.file = Some(chooser.selectedFile)
+    }
+
+    reportSet.save
+  }
 }