#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Fri, 17 Nov 2017 12:54:44 +0100
changeset 17758 1d8d76301e8d
parent 17757 b2c42e031c55
child 17759 36c73d14b656
#UI_ENHANCEMENT by cg class: FileOperation changed: #fileExistsDialogForNewFile:oldFile:withCancel:withRemoveIfSame:withAllAction: more info in dialog
FileOperation.st
--- a/FileOperation.st	Wed Nov 15 11:14:28 2017 +0100
+++ b/FileOperation.st	Fri Nov 17 12:54:44 2017 +0100
@@ -238,8 +238,10 @@
         #removeSource and #removeDestination.
     "
 
-    |msg oldSize newSize sameContents resources sourceType destType labels values default olderOrNewer
-     forAllHolder answer oldFileIsDirectory newFileIsDirectory oldFileTime newFileTime|
+    |msg oldSize newSize sameContents resources sourceType destType labels values default 
+     forAllHolder answer oldFileIsDirectory newFileIsDirectory 
+     oldFileTime newFileTime olderOrNewer 
+     newFileSize oldFileSize smallerOrLarger|
 
     newFile exists ifFalse:[ ^ true ].
     oldSize := oldFile fileSize.
@@ -273,14 +275,24 @@
     sameContents ifTrue:[
         msg := 'Overwrite existing destination %7:\\  %1\    size: %3 of %2\\with %8 source (same contents):\\  %4\    size: %6 of %5'.
     ] ifFalse:[
-        msg := 'Overwrite existing destination %7:\\  %1\    size: %3 of %2\\with %8 source:\\  %4\    size: %6 of %5'.
+        msg := 'Overwrite existing destination %7:\\  %1\    size: %3 of %2\\with %8 source (%9):\\  %4\    size: %6 of %5'.
     ].
+
     newFileTime := newFile modificationTime ? Timestamp now.
     oldFileTime := oldFile modificationTime ? Timestamp now.
-
     olderOrNewer := newFileTime < oldFileTime    
                     ifTrue:[ 'newer' ]
                     ifFalse:[ 'older' ].
+
+    newFileSize := newFile fileSize.
+    oldFileSize := oldFile fileSize.
+    smallerOrLarger := newFileSize < oldFileSize    
+                    ifTrue:[ 'smaller' ]
+                    ifFalse:[ 
+                        newFileSize = oldFileSize 
+                            ifTrue:['same size']
+                            ifFalse:['larger' ]].
+                    
     msg := resources
             stringWithCRs:msg
             withArgs:(Array
@@ -291,7 +303,8 @@
                 with:(oldFileTime printStringFormat:'%(Day)-%(mon)-%(year) %h:%m:%s')
                 with:oldSize
                 with:destType
-                with:(resources string:olderOrNewer) ).
+                with:(resources string:olderOrNewer)
+                with:(resources string:smallerOrLarger) ).
 
     (sameContents and:[withRemoveIfSame]) ifTrue:[
         labels := #( 'No' 'Remove Destination' 'Remove Source'  'Yes').
@@ -323,7 +336,7 @@
     ] do:[
         answer := OptionBox
               request:msg
-              label:(resources string:'Overwrite existing file')
+              label:(resources string:'Confirm overwrite existing file')
               image:(YesNoBox iconBitmap)
               buttonLabels:(resources array:labels)
               values:values
@@ -336,6 +349,7 @@
     ^ answer
 
     "Created: / 20-03-2012 / 11:44:34 / cg"
+    "Modified: / 17-11-2017 / 12:54:34 / cg"
 ! !
 
 !FileOperation methodsFor:'queries'!