From: PHO Date: Thu, 2 Oct 2014 10:28:43 +0000 (+0900) Subject: wip X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=f15de07f6b5b7439132def85ae2e86c38edc0289;p=task-reporter.git wip --- diff --git a/src/main/scala/jp/ymir/taskReporter/Main.scala b/src/main/scala/jp/ymir/taskReporter/Main.scala index 94bd3c7..a2ba207 100644 --- a/src/main/scala/jp/ymir/taskReporter/Main.scala +++ b/src/main/scala/jp/ymir/taskReporter/Main.scala @@ -11,6 +11,9 @@ object Main { } def main(args: Array[String]) { + // THINKME: Needed only on OpenJDK? + //scala.sys.props.update("awt.useSystemAAFontSettings", "lcd") + try { UIManager.setLookAndFeel(Preferences.lookAndFeel()) JFrame.setDefaultLookAndFeelDecorated(true) 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 + } }