DialogBox.st
changeset 4181 da91606eb79c
parent 4164 11aa3c5f93e5
child 4182 46fec1281cbc
--- a/DialogBox.st	Mon Oct 25 12:02:22 2010 +0200
+++ b/DialogBox.st	Wed Oct 27 11:35:24 2010 +0200
@@ -2182,20 +2182,23 @@
      or an empty string (if cancel was pressed)."
 
     ^ self 
-	requestFileName:titleString 
-	default:defaultName 
-	version:nil 
-	ifFail:''
-	fromDirectory:aDirectoryPath
+        requestFileName:titleString 
+        default:defaultName 
+        version:nil 
+        ifFail:''
+        pattern:nil 
+        fromDirectory:aDirectoryPath
+        forSave:false
+        whenBoxCreatedEvaluate:nil
 
     "
      Dialog 
-	requestFileName:'enter a fileName:' 
-	default:'Makefile.bak'
-	fromDirectory:'..'      
-    "
-
-    "Modified: 19.4.1996 / 14:27:31 / cg"
+        requestFileName:'enter a fileName:' 
+        default:'Makefile.bak'
+        fromDirectory:'..'      
+    "
+
+    "Modified: / 27-10-2010 / 10:40:42 / cg"
 !
 
 requestFileName:titleString default:defaultName ifFail:cancelBlockOrValue
@@ -2302,7 +2305,28 @@
         whenBoxCreatedEvaluate:nil
 !
 
-requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback
+requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil forSave:forSave
+    "launch a Dialog, which allows user to enter a filename.
+     The files presented initially are those in aDirectoryPathOrNil, or the
+     last fileBox directory (default: current directory) (if a nil path is given).
+     The box will show okText in its okButton, abortText in the abortButton.
+     The matchPattern is set to pattern initially.
+     Return the string, or nil if cancel was pressed."
+
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        ok:okText 
+        abort:abortText 
+        pattern:pattern 
+        fromDirectory:aDirectoryPathOrNil
+        forSave:forSave
+        whenBoxCreatedEvaluate:nil
+
+    "Created: / 27-10-2010 / 11:22:58 / cg"
+!
+
+requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil forSave:forSave whenBoxCreatedEvaluate:boxCreatedCallback
     "launch a Dialog, which allows user to enter a filename.
      The files presented initially are those in aDirectoryPathOrNil, or the
      last fileBox directory (default: current directory) (if a nil path is given).
@@ -2316,7 +2340,7 @@
         OperatingSystem isMSWINDOWSlike ifTrue:[
             ^ Win32FileDialog    
                 fileDialogFor:nil 
-                save:false 
+                save:forSave 
                 title:titleString 
                 inDirectory:aDirectoryPathOrNil
                 initialAnswer:defaultName
@@ -2385,8 +2409,40 @@
         fromDirectory:'/etc'  
     "
 
-    "Modified: / 23-10-1997 / 19:59:01 / cg"
     "Modified: / 24-08-2010 / 17:28:57 / sr"
+    "Created: / 27-10-2010 / 11:21:05 / cg"
+!
+
+requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback
+    "launch a Dialog, which allows user to enter a filename.
+     The files presented initially are those in aDirectoryPathOrNil, or the
+     last fileBox directory (default: current directory) (if a nil path is given).
+     The box will show okText in its okButton, abortText in the abortButton.
+     The matchPattern is set to pattern initially.
+     Return the string, or nil if cancel was pressed."
+
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        ok:okText 
+        abort:abortText 
+        pattern:pattern 
+        fromDirectory:aDirectoryPathOrNil 
+        forSave:false 
+        whenBoxCreatedEvaluate:boxCreatedCallback
+
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        ok:'yeah' 
+        abort:'oh, no' 
+        pattern:'rc*'
+        fromDirectory:'/etc'  
+    "
+
+    "Modified: / 24-08-2010 / 17:28:57 / sr"
+    "Modified: / 27-10-2010 / 11:21:44 / cg"
 !
 
 requestFileName:titleString default:defaultName ok:okText abort:abortText version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:aBoolean
@@ -2633,7 +2689,7 @@
         whenBoxCreatedEvaluate:nil
 !
 
-requestFileName:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback
+requestFileName:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath forSave:forSave whenBoxCreatedEvaluate:boxCreatedCallback
     "launch a Dialog, which allows user to enter a filename.
      Return the string or the value of failBlock if cancel was pressed.
      The version argument allows validation of the files existance;
@@ -2651,7 +2707,7 @@
         OperatingSystem isMSWINDOWSlike ifTrue:[
             ^ Win32FileDialog    
                 fileDialogFor:nil 
-                save:false 
+                save:forSave 
                 title:titleString 
                 inDirectory:aDirectoryPath
                 initialAnswer:defaultName
@@ -2747,9 +2803,63 @@
         fromDirectory:'/etc'
     "
 
+    "Modified: / 24-08-2010 / 17:29:04 / sr"
+    "Created: / 27-10-2010 / 10:38:10 / cg"
+!
+
+requestFileName:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback
+    "launch a Dialog, which allows user to enter a filename.
+     Return the string or the value of failBlock if cancel was pressed.
+     The version argument allows validation of the files existance;
+     it may be any of:
+        #mustBeNew      - fail (return empty string) if the file exists
+        #new            - confirm if the file exists
+        #mustBeOld      - fail if the file does not exist
+        #old            - confirm if the file does not exist
+        #any (other)    - no validation
+    "
+
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        version:versionSymbol 
+        ifFail:failBlock 
+        pattern:pattern 
+        fromDirectory:aDirectoryPath 
+        forSave:false
+        whenBoxCreatedEvaluate:boxCreatedCallback
+
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:nil
+        ifFail:['none']
+        pattern:'*.conf'
+        fromDirectory:'/etc'
+    "
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:#old 
+        ifFail:['none']   
+        pattern:'*.conf'
+        fromDirectory:'/etc'
+    "
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:#mustBeNew 
+        ifFail:['none']   
+        pattern:'*.conf'
+        fromDirectory:'/etc'
+    "
+
     "Created: / 21-02-1997 / 14:23:44 / stefan"
-    "Modified: / 16-06-1998 / 13:34:23 / cg"
     "Modified: / 24-08-2010 / 17:29:04 / sr"
+    "Modified: / 27-10-2010 / 10:38:53 / cg"
 !
 
 requestFileName:titleString fromDirectory:aDirectory
@@ -2839,6 +2949,261 @@
     "
 !
 
+requestFileNameForSave:titleString
+    "launch a Dialog, which allows user to enter a filename.
+     Return the pathname string consisting of the full pathname of the filename,
+     or an empty string (if cancel was pressed)."
+
+    ^ self 
+        requestFileNameForSave:titleString 
+        default:'file.ext' 
+
+    "
+     Dialog requestFileName:'enter a fileName:' 
+     Dialog requestFileName:'enter a fileName:' 
+    "
+
+    "Created: / 27-10-2010 / 11:31:52 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName
+    "launch a Dialog, which allows user to enter a filename.
+     The box will not allow pressing 'ok' without an entered string.
+     Return the pathname string consisting of the full pathname of the filename,
+     or an empty string (if cancel was pressed)."
+
+    ^ self 
+        requestFileName:titleString 
+        default:defaultName 
+        version:nil 
+        ifFail:''
+
+    "
+     Dialog requestFileName:'enter a fileName:' default:''  
+     Dialog requestFileName:'enter a fileName:' default:'Makefile.bak'  
+    "
+
+    "Created: / 27-10-2010 / 11:32:06 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName fromDirectory:aDirectoryPath
+    "launch a Dialog, which allows user to enter a filename.
+     The box will not allow pressing 'ok' without an entered string.
+     Return the pathname string consisting of the full pathname of the filename,
+     or an empty string (if cancel was pressed)."
+
+    ^ self 
+        requestFileName:titleString 
+        default:defaultName 
+        version:nil 
+        ifFail:''
+        pattern:nil 
+        fromDirectory:aDirectoryPath
+        forSave:true
+        whenBoxCreatedEvaluate:nil
+
+    "
+     Dialog 
+        requestFileName:'enter a fileName:' 
+        default:'Makefile.bak'
+        fromDirectory:'..'      
+    "
+
+    "Created: / 27-10-2010 / 10:41:04 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName ok:okText abort:abortText pattern:pattern
+    "launch a Dialog, which allows user to enter a filename.
+     The files presented initially are those from the current directory.
+     The box will show okText in its okButton, abortText in the abortButton.
+     The matchPattern is set to pattern initially.
+     Return the string or nil if cancel was pressed."
+
+    ^ self 
+        requestFileNameForSave:titleString 
+        default:defaultName
+        ok:okText 
+        abort:abortText 
+        pattern:pattern
+        fromDirectory:nil
+
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        ok:'yeah' 
+        abort:'oh, no' 
+        pattern:'*.st'   
+    "
+
+    "Created: / 27-10-2010 / 11:29:20 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil
+    "launch a Dialog, which allows user to enter a filename.
+     The files presented initially are those in aDirectoryPathOrNil, or the
+     last fileBox directory (default: current directory) (if a nil path is given).
+     The box will show okText in its okButton, abortText in the abortButton.
+     The matchPattern is set to pattern initially.
+     Return the string, or nil if cancel was pressed."
+
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        ok:okText 
+        abort:abortText 
+        pattern:pattern 
+        fromDirectory:aDirectoryPathOrNil
+        forSave:true
+        whenBoxCreatedEvaluate:nil
+
+    "Created: / 27-10-2010 / 11:24:37 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback
+    "launch a Dialog, which allows user to enter a filename.
+     The files presented initially are those in aDirectoryPathOrNil, or the
+     last fileBox directory (default: current directory) (if a nil path is given).
+     The box will show okText in its okButton, abortText in the abortButton.
+     The matchPattern is set to pattern initially.
+     Return the string, or nil if cancel was pressed."
+
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        ok:okText 
+        abort:abortText 
+        pattern:pattern 
+        fromDirectory:aDirectoryPathOrNil 
+        forSave:true 
+        whenBoxCreatedEvaluate:boxCreatedCallback
+
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        ok:'yeah' 
+        abort:'oh, no' 
+        pattern:'rc*'
+        fromDirectory:'/etc'  
+    "
+
+    "Modified: / 24-08-2010 / 17:28:57 / sr"
+    "Created: / 27-10-2010 / 11:23:40 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName version:versionSymbol ifFail:failBlock
+    "launch a Dialog, which allows user to enter a filename.
+     The box will not allow pressing 'ok' without an entered string.
+     Return the string or the value of failBlock if cancel was pressed.
+     The version argument allows validation of the files existance;
+     it may be any of:
+        #mustBeNew      - fail (return empty string) if the file exists
+        #new            - confirm if the file exists
+        #mustBeOld      - fail if the file does not exist
+        #old            - confirm if the file does not exist
+        #any (other)    - no validation
+    "
+
+    ^ self
+        requestFileNameForSave:titleString 
+        default:defaultName 
+        version:versionSymbol 
+        ifFail:failBlock
+        fromDirectory:nil
+
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:nil
+        ifFail:['none']   
+    "
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:#old 
+        ifFail:['none']   
+    "
+
+    "Created: / 27-10-2010 / 11:32:03 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName version:versionSymbol ifFail:failBlock fromDirectory:aDirectoryPath
+    "launch a Dialog, which allows user to enter a filename.
+     Return the string or the value of failBlock if cancel was pressed.
+     The version argument allows validation of the files existance;
+     it may be any of:
+        #mustBeNew      - fail (return empty string) if the file exists
+        #new            - confirm if the file exists
+        #mustBeOld      - fail if the file does not exist
+        #old            - confirm if the file does not exist
+        #any (other)    - no validation
+    "
+
+    ^ self 
+        requestFileNameForSave:titleString 
+        default:defaultName 
+        version:versionSymbol 
+        ifFail:failBlock 
+        pattern:nil 
+        fromDirectory:aDirectoryPath
+        
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:nil
+        ifFail:['none']
+        fromDirectory:'/etc'
+    "
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:#old 
+        ifFail:['none']   
+        fromDirectory:'/etc'
+    "
+    "
+     Dialog 
+        requestFileName:'enter a fileName:'
+        default:''
+        version:#mustBeNew 
+        ifFail:['none']   
+        fromDirectory:'/etc'
+    "
+
+    "Modified: / 21-02-1997 / 14:27:27 / stefan"
+    "Created: / 27-10-2010 / 11:32:22 / cg"
+!
+
+requestFileNameForSave:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath
+    "launch a Dialog, which allows user to enter a filename.
+     Return the string or the value of failBlock if cancel was pressed.
+     The version argument allows validation of the files existance;
+     it may be any of:
+        #mustBeNew      - fail (return empty string) if the file exists
+        #new            - confirm if the file exists
+        #mustBeOld      - fail if the file does not exist
+        #old            - confirm if the file does not exist
+        #any (other)    - no validation
+    "
+
+    ^ self
+        requestFileName:titleString 
+        default:defaultName 
+        version:versionSymbol 
+        ifFail:failBlock 
+        pattern:pattern 
+        fromDirectory:aDirectoryPath
+        forSave:true
+        whenBoxCreatedEvaluate:nil
+
+    "Created: / 27-10-2010 / 11:32:55 / cg"
+!
+
 requestFileNames:titleString default:defaultName ok:okText abort:abortText ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:asLoadDialog
     "launch a Dialog, which allows user to enter a filename.
      The files presented initially are those in aDirectoryPathOrNil, or the
@@ -9122,11 +9487,11 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.300 2010-08-24 15:39:39 sr Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.301 2010-10-27 09:35:24 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.300 2010-08-24 15:39:39 sr Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.301 2010-10-27 09:35:24 cg Exp $'
 ! !
 
 DialogBox initialize!