'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 5 October 2005 at 12:06:35 am'! StringHolder subclass: #FileList instanceVariableNames: 'fileName directory volList volListIndex list listIndex pattern sortMode brevityState labelString ' classVariableNames: 'FileReaderRegistry RecentDirs ' poolDictionaries: '' category: 'Tools-FileList'! !FileList methodsFor: 'initialization' stamp: 'sumim 10/4/2005 23:56'! labelString ^ labelString ifNil: [directory pathName contractTo: 50]! ! !FileList methodsFor: 'initialization' stamp: 'sumim 10/4/2005 23:54'! labelString: aString labelString _ aString! ! !FileList methodsFor: 'private' stamp: 'sumim 10/5/2005 00:03'! put: aText "Private - put the supplied text onto the file" | ff type index ending | brevityState == #fullFile ifTrue: [ff _ directory newFileNamed: self fullName. Cursor write showWhile: [ff nextPutAll: aText asString; close]. fileName = ff localName ifTrue: [contents := aText asString] ifFalse: "user renamed the file" [self updateFileList. directory pathParts = ff directory pathParts ifTrue: [fileName := ff localName. contents := aText asString. index := list indexOf: fileName. index = 0 ifTrue: [ending := ') ',fileName. index := list findFirst: [:line | line endsWith: ending]]. listIndex := index. self labelString: ff fullName. self changed: #fileListIndex; changed: #relabel]]. ^ true "accepted"]. listIndex = 0 ifTrue: [self inform: 'No fileName is selected' translated. ^ false "failed"]. type _ 'These'. brevityState = #briefFile ifTrue: [type _ 'Abbreviated']. brevityState = #briefHex ifTrue: [type _ 'Abbreviated']. brevityState = #fullHex ifTrue: [type _ 'Hexadecimal']. brevityState = #FileList ifTrue: [type _ 'Directory']. self inform: ('{1} contents cannot meaningfully be saved at present.' translated format:{type translated}). ^ false "failed" ! ! !FileList class methodsFor: 'instance creation' stamp: 'sumim 10/4/2005 23:58'! openEditorOn: aFileStream editString: editString "Open an editor on the given FileStream." | fileModel topView fileContentsView | Smalltalk isMorphic ifTrue: [^ (self openMorphOn: aFileStream editString: editString) openInWorld]. fileModel _ FileList new setFileStream: aFileStream. "closes the stream" fileModel labelString: aFileStream fullName. topView _ StandardSystemView new. topView model: fileModel; label: fileModel labelString; minimumSize: 180@120. topView borderWidth: 1. fileContentsView _ PluggableTextView on: fileModel text: #contents accept: #put: readSelection: #contentsSelection menu: #fileContentsMenu:shifted:. fileContentsView window: (0@0 extent: 180@120). topView addSubView: fileContentsView. editString ifNotNil: [fileContentsView editString: editString. fileContentsView hasUnacceptedEdits: true]. topView controller open. ! ! !FileList class methodsFor: 'instance creation' stamp: 'sumim 10/5/2005 00:05'! openMorphOn: aFileStream editString: editString "Open a morphic view of a FileList on the given file." | fileModel window fileContentsView | fileModel _ FileList new setFileStream: aFileStream. "closes the stream" fileModel labelString: aFileStream fullName. window _ (SystemWindow labelled: fileModel labelString) model: fileModel. window addMorph: (fileContentsView _ PluggableTextMorph on: fileModel text: #contents accept: #put: readSelection: #contentsSelection menu: #fileContentsMenu:shifted:) frame: (0@0 corner: 1@1). editString ifNotNil: [fileContentsView editString: editString. fileContentsView hasUnacceptedEdits: true]. ^ window! !