groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kee...@apache.org
Subject incubator-groovy git commit: GROOVY-7241: Add save prompts for buffers without a file (closes #71)
Date Thu, 30 Jul 2015 19:35:51 GMT
Repository: incubator-groovy
Updated Branches:
  refs/heads/master b573d5ce4 -> c3a802fe1


GROOVY-7241: Add save prompts for buffers without a file (closes #71)


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/c3a802fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/c3a802fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/c3a802fe

Branch: refs/heads/master
Commit: c3a802fe13a6fc7267130db805940bd2be41b4f8
Parents: b573d5c
Author: Keegan Witt <keeganwitt@gmail.com>
Authored: Mon Jul 20 21:10:27 2015 -0400
Committer: Keegan Witt <keeganwitt@gmail.com>
Committed: Thu Jul 30 15:35:13 2015 -0400

----------------------------------------------------------------------
 .../src/main/groovy/groovy/ui/Console.groovy            | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/c3a802fe/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
index 7dbba16..df4e845 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
@@ -497,11 +497,11 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
 
     // Return false if use elected to cancel
     boolean askToSaveFile() {
-        if (scriptFile == null || !dirty) {
+        if (!dirty) {
             return true
         }
         switch (JOptionPane.showConfirmDialog(frame,
-            'Save changes to ' + scriptFile.name + '?',
+            'Save changes' + (scriptFile != null ? " to ${scriptFile.name}" : '') + '?',
             'GroovyConsole', JOptionPane.YES_NO_CANCEL_OPTION))
         {
             case JOptionPane.YES_OPTION:
@@ -668,9 +668,11 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
     }
 
     void fileOpen(EventObject evt = null) {
-        def scriptName = selectFilename()
-        if (scriptName != null) {
-            loadScriptFile(scriptName)
+        if (askToSaveFile()) {
+            def scriptName = selectFilename()
+            if (scriptName != null) {
+                loadScriptFile(scriptName)
+            }
         }
     }
 


Mime
View raw message