--- a/FileBrowser.st Wed Oct 10 01:14:01 2001 +0200
+++ b/FileBrowser.st Wed Oct 10 11:08:57 2001 +0200
@@ -1830,6 +1830,38 @@
"Modified: / 4.8.1998 / 13:45:46 / cg"
!
+confirmAndRemove:fileNames
+ "remove fileNames with user confirmation.
+ TODO: Should be enhanced, to look for a ~/.trash directory
+ and move files there if it exists (without asking in this case)."
+
+ |q doRemove|
+
+ "/ do not ask, if shift is pressed
+ fileNames size > 1 ifTrue:[
+ q := resources string:'Remove %1 selected files ?' with:(fileNames size).
+ doRemove := Dialog
+ confirmWithCancel:q
+ labels:(resources array:#('Cancel' 'Confirm Each' 'Remove'))
+ values:#(false #confirm true)
+ default:3.
+ doRemove isNil ifTrue:[^ self].
+ doRemove == #confirm ifTrue:[
+ fileNames do:[:eachFileName |
+ self confirmAndRemove:(Array with:eachFileName).
+ ].
+ ^ self.
+ ].
+ ] ifFalse:[
+ q := resources string:'Remove ''%1'' ?' with:(fileNames first allBold).
+ doRemove := self ask:q yesButton:'Remove'.
+ ].
+
+ doRemove ifTrue:[
+ self doRemove:fileNames
+ ]
+!
+
detailsSettingChanged
"invoked, when detail (i.e. long / short) listing flag changed"
@@ -2703,29 +2735,58 @@
fileRemove
"remove the selected file(s).
- Query if user really wants to remove the file.
- - should be enhanced, to look for a ~/.trash directory
- and move files there if it exists (without asking in this case)."
-
- |sel q|
+ Query if user really wants to remove the file, except if
+ shift-key is pressed.
+ TODO: Should be enhanced, to look for a ~/.trash directory
+ and move files there if it exists (without asking in this case)."
+
+ |sel|
sel := fileListView selection.
sel size > 0 ifTrue:[
sel := sel collect:[:rawIndex | fileList at:rawIndex].
- sel size > 1 ifTrue:[
- q := resources string:'Remove %1 selected files ?' with:(sel size)
+ "/ do not ask, if shift is pressed
+ self sensor shiftDown ifTrue:[
+ self doRemove:sel
] ifFalse:[
- q := resources string:'Remove ''%1'' ?' with:(sel first allBold)
+ self confirmAndRemove:sel
].
- (self sensor shiftDown
- or:[self ask:q yesButton:'Remove']) ifTrue:[
- self withCursor:(Cursor wait) do:[
- self doRemove:sel
- ]
+ ]
+!
+
+fileRemove:fileNames
+ "remove fileNames.
+ Query if user really wants to remove the file, except if
+ shift-key is pressed.
+ TODO: Should be enhanced, to look for a ~/.trash directory
+ and move files there if it exists (without asking in this case)."
+
+ |q doRemove|
+
+ "/ do not ask, if shift is pressed
+ doRemove := self sensor shiftDown.
+ doRemove ifFalse:[
+ fileNames size > 1 ifTrue:[
+ q := resources string:'Remove %1 selected files ?' with:(fileNames size).
+ doRemove := Dialog
+ confirmWithCancel:q
+ labels:(resources array:#('Remove' 'Confirm Each' 'Cancel'))
+ values:#(true #confirm false)
+ default:true.
+ doRemove == #confirm ifTrue:[
+ self halt.
+ ].
+ ] ifFalse:[
+ q := resources string:'Remove ''%1'' ?' with:(fileNames first allBold).
+ doRemove := self ask:q yesButton:'Remove'.
+ ].
+ ].
+
+ doRemove ifTrue:[
+ self withWaitCursorDo:[
+ self doRemove:fileNames
]
]
-
- "Modified: / 16.12.1998 / 17:30:31 / cg"
!
fileRename
@@ -6008,92 +6069,94 @@
|msg needUpdate toRemove updateRunning yesToAll mTime|
- updateRunning := listUpdateProcess notNil.
- self stopUpdateProcess.
- toRemove := OrderedCollection new.
-
- "/
- "/ did the directory change in the meanwhile ?
- "/
- mTime := currentDirectory modificationTime.
- needUpdate := mTime notNil and:[mTime > timeOfLastCheck].
-
- yesToAll := false.
- lockUpdate := true.
- [
- filesToRemove keysAndValuesDo:[:idx :fileName |
- |f|
-
- f := currentDirectory construct:fileName.
- OperatingSystem accessDeniedErrorSignal handle:[:ex|
- "was not able to remove it"
- msg := (resources string:'cannot remove ''%1'' !!' with:fileName).
- self showAlert:msg with:(OperatingSystem lastErrorString)
- ] do:[
- |answer contents i|
-
- (f isSymbolicLink not and:[f isDirectory]) ifTrue:[
- contents := f directoryContents.
- contents isEmpty ifTrue:[
- f remove
- ] ifFalse:[
- yesToAll ifFalse:[
- idx == filesToRemove size ifTrue:[
- answer := Dialog
- confirmWithCancel:(resources string:'directory ''%1'' is not empty\remove anyway ?' with:fileName allBold) withCRs
- labels:(resources array:#('cancel' 'remove'))
- values:#(false true)
- default:2.
- ] ifFalse:[
- answer := Dialog
- confirmWithCancel:(resources string:'directory ''%1'' is not empty\remove anyway ?' with:fileName allBold) withCRs
- labels:(resources array:#('cancel' 'remove all' 'remove'))
- values:#(false #removeAll true)
- default:3.
- ].
- answer == false ifTrue:[
- ^ self
- ].
- answer == #removeAll ifTrue:[
- yesToAll := true
- ].
- ].
- f recursiveRemove
- ].
- ] ifFalse:[
- f removeFile.
- ].
-"
- self show:nil
-"
- i := fileList indexOf:fileName.
- i ~~ 0 ifTrue:[
- toRemove add:i.
- ]
- ].
- ].
- ] valueNowOrOnUnwindDo:[
- lockUpdate := false.
- fileListView setSelection:nil.
+ self withWaitCursorDo:[
+ updateRunning := listUpdateProcess notNil.
+ self stopUpdateProcess.
+ toRemove := OrderedCollection new.
"/
- "/ remove reverse - otherwise indices are wrong
+ "/ did the directory change in the meanwhile ?
"/
- toRemove sort.
- toRemove reverseDo:[:idx |
- fileList removeIndex:idx.
- fileListView removeIndex:idx.
- ].
-
- updateRunning ifTrue:[
- self updateCurrentDirectory
- ] ifFalse:[
- "
- install a new check after some time
- "
- needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now].
- Processor removeTimedBlock:checkBlock.
- Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
+ mTime := currentDirectory modificationTime.
+ needUpdate := mTime notNil and:[mTime > timeOfLastCheck].
+
+ yesToAll := false.
+ lockUpdate := true.
+ [
+ filesToRemove keysAndValuesDo:[:idx :fileName |
+ |f|
+
+ f := currentDirectory construct:fileName.
+ OperatingSystem accessDeniedErrorSignal handle:[:ex|
+ "was not able to remove it"
+ msg := (resources string:'cannot remove ''%1'' !!' with:fileName).
+ self showAlert:msg with:(OperatingSystem lastErrorString)
+ ] do:[
+ |answer contents i|
+
+ (f isSymbolicLink not and:[f isDirectory]) ifTrue:[
+ contents := f directoryContents.
+ contents isEmpty ifTrue:[
+ f remove
+ ] ifFalse:[
+ yesToAll ifFalse:[
+ idx == filesToRemove size ifTrue:[
+ answer := Dialog
+ confirmWithCancel:(resources string:'directory ''%1'' is not empty\remove anyway ?' with:fileName allBold) withCRs
+ labels:(resources array:#('cancel' 'remove'))
+ values:#(false true)
+ default:2.
+ ] ifFalse:[
+ answer := Dialog
+ confirmWithCancel:(resources string:'directory ''%1'' is not empty\remove anyway ?' with:fileName allBold) withCRs
+ labels:(resources array:#('cancel' 'remove all' 'remove'))
+ values:#(false #removeAll true)
+ default:3.
+ ].
+ answer == false ifTrue:[
+ ^ self
+ ].
+ answer == #removeAll ifTrue:[
+ yesToAll := true
+ ].
+ ].
+ f recursiveRemove
+ ].
+ ] ifFalse:[
+ f removeFile.
+ ].
+ "
+ self show:nil
+ "
+ i := fileList indexOf:fileName.
+ i ~~ 0 ifTrue:[
+ toRemove add:i.
+ ]
+ ].
+ ].
+ ] valueNowOrOnUnwindDo:[
+ lockUpdate := false.
+ fileListView setSelection:nil.
+
+ "/
+ "/ remove reverse - otherwise indices are wrong
+ "/
+ toRemove sort.
+ toRemove reverseDo:[:idx |
+ fileList removeIndex:idx.
+ fileListView removeIndex:idx.
+ ].
+
+ updateRunning ifTrue:[
+ self updateCurrentDirectory
+ ] ifFalse:[
+ "
+ install a new check after some time
+ "
+ needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now].
+ Processor removeTimedBlock:checkBlock.
+ Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
+ ]
]
]
@@ -7332,5 +7395,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.426 2001-10-09 23:14:01 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.427 2001-10-10 09:08:57 cg Exp $'
! !