The Trunk: Files-mtf.95.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Files-mtf.95.mcz

commits-2
Matthew Fulmer uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-mtf.95.mcz

==================== Summary ====================

Name: Files-mtf.95
Author: mtf
Time: 20 January 2011, 2:22:08.448 pm
UUID: f67b2051-b723-482a-9061-2081ad969129
Ancestors: Files-mtf.94

Actually, here's a better sollution. Added a debug menu item to the default action menu for FileDoesNotExistException

=============== Diff against Files-mtf.94 ===============

Item was changed:
  FileStreamException subclass: #FileDoesNotExistException
  instanceVariableNames: 'readOnly'
+ classVariableNames: ''
- classVariableNames: 'ShowDebugger'
  poolDictionaries: ''
  category: 'Files-Exceptions'!

Item was removed:
- ----- Method: FileDoesNotExistException class>>showDebugger (in category 'debugging') -----
- showDebugger
- <preference: 'Debug FileDoesNotExistException'
- category: 'debug'
- description: 'If enabled, FileDoesNotExistException pops up a debugger. If disabled, gives the user the option of changing the file name'
- type: #Boolean>
- ^ShowDebugger ifNil: [false]!

Item was removed:
- ----- Method: FileDoesNotExistException class>>showDebugger: (in category 'debugging') -----
- showDebugger: aBoolean
- ^ShowDebugger := aBoolean!

Item was changed:
  ----- Method: FileDoesNotExistException>>defaultAction (in category 'exceptionDescription') -----
  defaultAction
  "The default action taken if the exception is signaled."
 
- FileDoesNotExistException showDebugger ifTrue: [^ super defaultAction].
  ^self readOnly
+ ifTrue: [StandardFileStream readOnlyFileDoesNotExistUserHandling: self fileName
+ ifDebug: [super defaultAction]]
+ ifFalse: [StandardFileStream fileDoesNotExistUserHandling: self fileName
+ ifDebug: [super defaultAction]]
- ifTrue: [StandardFileStream readOnlyFileDoesNotExistUserHandling: self fileName]
- ifFalse: [StandardFileStream fileDoesNotExistUserHandling: self fileName]
  !

Item was changed:
  ----- Method: FileExistsException>>defaultAction (in category 'exceptionDescription') -----
  defaultAction
  "The default action taken if the exception is signaled."
 
+ ^ self fileClass fileExistsUserHandling: self fileName ifDebug: [super defaultAction]
- FileDoesNotExistException showDebugger ifTrue: [^ super defaultAction].
- ^ self fileClass fileExistsUserHandling: self fileName
  !

Item was removed:
- ----- Method: StandardFileStream class>>fileDoesNotExistUserHandling: (in category 'error handling') -----
- fileDoesNotExistUserHandling: fullFileName
-
- | selection newName |
- selection := UIManager default chooseFrom: {
- 'create a new file' translated.
- 'choose another name' translated.
- 'cancel' translated
- } title: (FileDirectory localNameFor: fullFileName) , '
- does not exist.'.
- selection = 1 ifTrue:
- [^ self new open: fullFileName forWrite: true].
- selection = 2 ifTrue:
- [ newName := UIManager default request: 'Enter a new file name'
- initialAnswer:  fullFileName.
- ^ self oldFileNamed:
- (self fullName: newName)].
- self halt!

Item was added:
+ ----- Method: StandardFileStream class>>fileDoesNotExistUserHandling:ifDebug: (in category 'error handling') -----
+ fileDoesNotExistUserHandling: fullFileName ifDebug: debugBlock
+
+ | selection newName |
+ selection := UIManager default chooseFrom: {
+ 'create a new file' translated.
+ 'choose another name' translated.
+ 'debug' translated.
+ 'cancel' translated
+ } title: (FileDirectory localNameFor: fullFileName) , '
+ does not exist.'.
+ selection = 1 ifTrue:
+ [^ self new open: fullFileName forWrite: true].
+ selection = 2 ifTrue:
+ [ newName := UIManager default request: 'Enter a new file name'
+ initialAnswer:  fullFileName.
+ ^ self oldFileNamed:
+ (self fullName: newName)].
+ selection = 3 ifTrue: [^ debugBlock value].
+ self halt!

Item was removed:
- ----- Method: StandardFileStream class>>fileExistsUserHandling: (in category 'error handling') -----
- fileExistsUserHandling: fullFileName
- | dir localName choice newName newFullFileName |
- dir := FileDirectory forFileName: fullFileName.
- localName := FileDirectory localNameFor: fullFileName.
- choice := (UIManager default
- chooseFrom: #('overwrite that file' 'append (risky!!!!)' 'choose another name' 'cancel')
- title: localName, ' already exists.').
-
- choice = 1 ifTrue: [
- dir deleteFileNamed: localName
- ifAbsent: [self error: 'Could not delete the old version of that file'].
- ^ self new open: fullFileName forWrite: true].
-
- choice = 2 ifTrue: [
- ^ (self new open: fullFileName forWrite: true) setToEnd].
-
- choice = 3 ifTrue: [
- newName := UIManager default request: 'Enter a new file name' initialAnswer: fullFileName.
- newFullFileName := self fullName: newName.
- ^ self newFileNamed: newFullFileName].
-
- self error: 'Please close this to abort file opening'!

Item was added:
+ ----- Method: StandardFileStream class>>fileExistsUserHandling:ifDebug: (in category 'error handling') -----
+ fileExistsUserHandling: fullFileName ifDebug: debugBlock
+ | dir localName choice newName newFullFileName |
+ dir := FileDirectory forFileName: fullFileName.
+ localName := FileDirectory localNameFor: fullFileName.
+ choice := (UIManager default
+ chooseFrom: #('overwrite that file' 'append (risky!!!!)' 'choose another name' 'debug' 'cancel')
+ title: localName, ' already exists.').
+
+ choice = 1 ifTrue: [
+ dir deleteFileNamed: localName
+ ifAbsent: [self error: 'Could not delete the old version of that file'].
+ ^ self new open: fullFileName forWrite: true].
+
+ choice = 2 ifTrue: [
+ ^ (self new open: fullFileName forWrite: true) setToEnd].
+
+ choice = 3 ifTrue: [
+ newName := UIManager default request: 'Enter a new file name' initialAnswer: fullFileName.
+ newFullFileName := self fullName: newName.
+ ^ self newFileNamed: newFullFileName].
+
+ choice = 4 ifTrue: [^ debugBlock value].
+
+ self error: 'Please close this to abort file opening'!

Item was removed:
- ----- Method: StandardFileStream class>>readOnlyFileDoesNotExistUserHandling: (in category 'error handling') -----
- readOnlyFileDoesNotExistUserHandling: fullFileName
-
- | dir files choices selection newName fileName |
- dir := FileDirectory forFileName: fullFileName.
- files := dir fileNames.
- fileName := FileDirectory localNameFor: fullFileName.
- choices := fileName correctAgainst: files.
- choices add: 'Choose another name'.
- choices add: 'Cancel'.
- selection := UIManager default chooseFrom: choices lines: (Array with: 5)
- title: (FileDirectory localNameFor: fullFileName), '
- does not exist.'.
- selection = choices size ifTrue:["cancel" ^ nil "should we raise another exception here?"].
- selection < (choices size - 1) ifTrue: [
- newName := (dir pathName , FileDirectory slash , (choices at: selection))].
- selection = (choices size - 1) ifTrue: [
- newName := UIManager default
- request: 'Enter a new file name'
- initialAnswer: fileName].
- newName = '' ifFalse: [^ self readOnlyFileNamed: (self fullName: newName)].
- ^ self error: 'Could not open a file'!

Item was added:
+ ----- Method: StandardFileStream class>>readOnlyFileDoesNotExistUserHandling:ifDebug: (in category 'error handling') -----
+ readOnlyFileDoesNotExistUserHandling: fullFileName ifDebug: debugBlock
+
+ | dir files choices selection newName fileName |
+ dir := FileDirectory forFileName: fullFileName.
+ files := dir fileNames.
+ fileName := FileDirectory localNameFor: fullFileName.
+ choices := fileName correctAgainst: files.
+ choices add: 'Choose another name'.
+ choices add: 'Debug'.
+ choices add: 'Cancel'.
+ selection := UIManager default chooseFrom: choices lines: (Array with: 5)
+ title: (FileDirectory localNameFor: fullFileName), '
+ does not exist.'.
+ selection = choices size ifTrue:["cancel" ^ nil "should we raise another exception here?"].
+ selection < (choices size - 1) ifTrue: [
+ newName := (dir pathName , FileDirectory slash , (choices at: selection))].
+ selection = (choices size - 2) ifTrue: [
+ newName := UIManager default
+ request: 'Enter a new file name'
+ initialAnswer: fileName].
+ selection = (choices size - 1) ifTrue: [^ debugBlock value].
+ newName = '' ifFalse: [^ self readOnlyFileNamed: (self fullName: newName)].
+ ^ self error: 'Could not open a file'!