X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=task-reporter.git;a=blobdiff_plain;f=src%2Fmain%2Fscala%2Fjp%2Fymir%2FtaskReporter%2Fui%2FMainFrame.scala;fp=src%2Fmain%2Fscala%2Fjp%2Fymir%2FtaskReporter%2Fui%2FMainFrame.scala;h=4e7edbf578613c230a31676af9b46b7f9e110493;hp=3759437c664d32886a537faa6705fe0b79fdae03;hb=f15de07f6b5b7439132def85ae2e86c38edc0289;hpb=f35a6ee198f3f2dba8dc60ae969c4ce1c5c8c22b diff --git a/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala b/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala index 3759437..4e7edbf 100644 --- a/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala +++ b/src/main/scala/jp/ymir/taskReporter/ui/MainFrame.scala @@ -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 + } }