added copyAs in drag and drop
authorClaus Gittinger <cg@exept.de>
Mon, 09 Dec 2002 11:10:27 +0100
changeset 4354 0a1239cd339d
parent 4353 fe7b65eee458
child 4355 63dc8ed2e56c
added copyAs in drag and drop
AbstractFileBrowser.st
--- a/AbstractFileBrowser.st	Fri Dec 06 12:48:59 2002 +0100
+++ b/AbstractFileBrowser.st	Mon Dec 09 11:10:27 2002 +0100
@@ -2773,39 +2773,59 @@
     stream := WriteStream on:''.
     stream nextPutAll:'copy or move file'.
     size == 1 ifFalse:[
-	stream nextPutAll:'s'.
+        stream nextPutAll:'s'.
     ].
     stream nextPutAll:': '.
     stream nextPutAll:aCol first baseName asString.
     size == 1 ifFalse:[
-	stream nextPutAll:' ... '.
-	stream nextPutAll:aCol last baseName asString.
+        stream nextPutAll:' ... '.
+        stream nextPutAll:aCol last baseName asString.
     ].
 
     dialog := OptionBox 
-		  request:stream contents 
-		  label:'move or copy'
-		  form:(WarningBox iconBitmap)
-		  buttonLabels:#('cancel' 'move' 'copy')
-		  values:#(#cancel #move #copy)
-		  default:#copy.
+                  request:stream contents 
+                  label:'Move or Copy'
+                  form:(WarningBox iconBitmap)
+                  buttonLabels:#('Cancel' 'Move' 'Copy' 'Copy As...')
+                  values:#(#cancel #move #copy #copyAs)
+                  default:#copy.
     dialog isNil ifTrue:[dialog := #cancel].
     ^ dialog.
 !
 
-copyOrMoveFiles:aColOfSourceFiles to:aDirectory 
+copyOrMoveFiles:aColOfSourceFiles to:aDestinationDirectory 
    "copy aColOfSourceFiles to aDirectory
    "
-    |dialog|
+    |dialog lastOld lastNew|
 
     dialog := self copyOrMoveDialog:aColOfSourceFiles.
+    dialog == #copyAs ifTrue:[
+        aColOfSourceFiles do:[:eachSourceFile |
+            |initial destFile srcBase dstBase|
+
+            srcBase := eachSourceFile asFilename baseName.
+            lastOld isNil ifTrue:[
+                initial := srcBase
+            ] ifFalse:[
+                initial := DoWhatIMeanSupport
+                            goodRenameDefaultForFile:srcBase lastOld:lastOld lastNew:lastNew.
+            ].
+            dstBase := Dialog request:('Copy %1 as:' bindWith:srcBase) initialAnswer:initial.
+            dstBase isNil ifTrue:[^ self].
+            self copyFile:eachSourceFile to:(aDestinationDirectory construct:dstBase).
+            lastOld := srcBase.
+            lastNew := dstBase.
+        ].
+
+        ^ self.
+    ].
     dialog == #copy ifTrue:[
-	self copyFiles:aColOfSourceFiles to:aDirectory.
-	^ self.
+        self copyFiles:aColOfSourceFiles to:aDestinationDirectory.
+        ^ self.
     ].
     dialog == #move ifTrue:[
-	self moveFiles:aColOfSourceFiles to:aDirectory.
-	^ self.
+        self moveFiles:aColOfSourceFiles to:aDestinationDirectory.
+        ^ self.
     ].
 !
 
@@ -5291,5 +5311,5 @@
 !AbstractFileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.66 2002-12-04 17:05:18 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.67 2002-12-09 10:10:27 cg Exp $'
 ! !