--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FSelList.st Thu Dec 16 12:02:42 1993 +0100
@@ -0,0 +1,185 @@
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+SelectionInListView subclass:#FileSelectionList
+ instanceVariableNames:'pattern directory timeStamp directoryId
+ directoryContents directoryFileTypes
+ realAction'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Text'
+!
+
+FileSelectionList comment:'
+
+COPYRIGHT (c) 1993 by Claus Gittinger
+ All Rights Reserved
+
+$Header: /cvs/stx/stx/libwidg/Attic/FSelList.st,v 1.1 1993-12-16 11:02:42 claus Exp $
+written Dec 93 by claus
+'!
+
+!FileSelectionList class methodsFor:'documentation'!
+
+documentation
+"
+this class implements file selection lists - its basically a
+selection in list, but remembers the previous position when
+changing directories.
+Only files matching a pattern (plus directories) are shown.
+"
+! !
+
+!FileSelectionList methodsFor:'initialization'!
+
+initialize
+ directory := FileDirectory currentDirectory.
+ super initialize.
+
+ pattern := '*'.
+
+ "selections in list get forwarded to enterfield if not a directory;
+ otherwise directory is changed"
+
+ actionBlock := [:lineNr |
+ |entry|
+
+ (self selection isKindOf:Collection) ifFalse:[
+ entry := self selectionValue.
+ (entry endsWith:' ...') ifTrue:[
+ entry := entry copyTo:(entry size - 4).
+ ].
+ ((directory typeOf:entry) == #directory) ifTrue:[
+ (directory isReadable:entry) ifFalse:[
+ self warn:(resources string:'not allowed to read directory %1' with:entry)
+ ] ifTrue:[
+ (directory isExecutable:entry) ifFalse:[
+ self warn:(resources string:'not allowed to change to directory %1' with:entry)
+ ] ifTrue:[
+ self directory:(directory pathName , Filename separator asString , entry)
+ ]
+ ].
+ ] ifFalse:[
+ realAction notNil ifTrue:[
+ realAction value:lineNr
+ ]
+ ]
+ ]
+ ]
+
+ "FileSelectionList new realize"
+!
+
+reinitialize
+ directory := FileDirectory currentDirectory.
+ super reinitialize
+! !
+
+!FileSelectionList methodsFor:'accessing'!
+
+action:aBlock
+ "set the action to be performed on a selection"
+
+ realAction := aBlock
+!
+
+directory
+ "return the shown directory"
+
+ ^ directory
+!
+
+directory:nameOrDirectory
+ "set the lists contents to the filenames in the directory"
+
+ |oldPath name|
+
+ (nameOrDirectory isKindOf:String) ifTrue:[
+ name := nameOrDirectory
+ ] ifFalse:[
+ name := nameOrDirectory pathName
+ ].
+ oldPath := directory pathName.
+ directory pathName:name.
+ (directory pathName = oldPath) ifFalse:[
+ self updateList
+ ]
+!
+
+pattern:aPattern
+ "set the pattern - if it changes, update the list."
+
+ pattern ~= aPattern ifTrue:[
+ pattern := aPattern.
+ realized ifTrue:[
+ self updateList
+ ].
+ ].
+! !
+
+!FileSelectionList methodsFor:'private'!
+
+updateList
+ "set the lists contents to the filenames in the directory"
+
+ |oldCursor files newList index|
+
+ oldCursor := cursor.
+ self cursor:(Cursor read).
+
+ directoryId == directory id ifFalse:[
+ timeStamp := directory timeOfLastChange.
+ directoryId := directory id.
+ directoryContents := directory asText sort.
+ directoryFileTypes := OrderedCollection new.
+ directoryContents do:[:name | directoryFileTypes add:(directory typeOf:name)].
+ ].
+
+ files := directoryContents.
+ newList := OrderedCollection new.
+ index := 1.
+ files do:[:name |
+ (directoryFileTypes at:index) == #directory ifTrue:[
+ name = '..' ifTrue:[
+ newList add:name
+ ] ifFalse:[
+ name = '.' ifTrue:[
+ ] ifFalse:[
+ newList add:(name , ' ...')
+ ]
+ ]
+ ] ifFalse:[
+ (pattern isEmpty or:[pattern = '*' or:[pattern match:name]]) ifTrue:[
+ newList add:name
+ ]
+ ].
+ index := index + 1
+ ].
+ super list:newList.
+ self cursor:oldCursor.
+! !
+
+!FileSelectionList methodsFor:'realization'!
+
+realize
+ "make the view visible; redefined to check if directory is still
+ valid (using timestamp and inode numbers) - reread if not"
+
+ (timeStamp isNil
+ or:[(directory timeOfLastChange > timeStamp)
+ or:[(directoryId isNil)
+ or:[directoryId ~~ directory id]]]) ifTrue:[
+ directoryId := nil.
+ self updateList
+ ].
+ super realize
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FileSelectionList.st Thu Dec 16 12:02:42 1993 +0100
@@ -0,0 +1,185 @@
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+SelectionInListView subclass:#FileSelectionList
+ instanceVariableNames:'pattern directory timeStamp directoryId
+ directoryContents directoryFileTypes
+ realAction'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Text'
+!
+
+FileSelectionList comment:'
+
+COPYRIGHT (c) 1993 by Claus Gittinger
+ All Rights Reserved
+
+$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.1 1993-12-16 11:02:42 claus Exp $
+written Dec 93 by claus
+'!
+
+!FileSelectionList class methodsFor:'documentation'!
+
+documentation
+"
+this class implements file selection lists - its basically a
+selection in list, but remembers the previous position when
+changing directories.
+Only files matching a pattern (plus directories) are shown.
+"
+! !
+
+!FileSelectionList methodsFor:'initialization'!
+
+initialize
+ directory := FileDirectory currentDirectory.
+ super initialize.
+
+ pattern := '*'.
+
+ "selections in list get forwarded to enterfield if not a directory;
+ otherwise directory is changed"
+
+ actionBlock := [:lineNr |
+ |entry|
+
+ (self selection isKindOf:Collection) ifFalse:[
+ entry := self selectionValue.
+ (entry endsWith:' ...') ifTrue:[
+ entry := entry copyTo:(entry size - 4).
+ ].
+ ((directory typeOf:entry) == #directory) ifTrue:[
+ (directory isReadable:entry) ifFalse:[
+ self warn:(resources string:'not allowed to read directory %1' with:entry)
+ ] ifTrue:[
+ (directory isExecutable:entry) ifFalse:[
+ self warn:(resources string:'not allowed to change to directory %1' with:entry)
+ ] ifTrue:[
+ self directory:(directory pathName , Filename separator asString , entry)
+ ]
+ ].
+ ] ifFalse:[
+ realAction notNil ifTrue:[
+ realAction value:lineNr
+ ]
+ ]
+ ]
+ ]
+
+ "FileSelectionList new realize"
+!
+
+reinitialize
+ directory := FileDirectory currentDirectory.
+ super reinitialize
+! !
+
+!FileSelectionList methodsFor:'accessing'!
+
+action:aBlock
+ "set the action to be performed on a selection"
+
+ realAction := aBlock
+!
+
+directory
+ "return the shown directory"
+
+ ^ directory
+!
+
+directory:nameOrDirectory
+ "set the lists contents to the filenames in the directory"
+
+ |oldPath name|
+
+ (nameOrDirectory isKindOf:String) ifTrue:[
+ name := nameOrDirectory
+ ] ifFalse:[
+ name := nameOrDirectory pathName
+ ].
+ oldPath := directory pathName.
+ directory pathName:name.
+ (directory pathName = oldPath) ifFalse:[
+ self updateList
+ ]
+!
+
+pattern:aPattern
+ "set the pattern - if it changes, update the list."
+
+ pattern ~= aPattern ifTrue:[
+ pattern := aPattern.
+ realized ifTrue:[
+ self updateList
+ ].
+ ].
+! !
+
+!FileSelectionList methodsFor:'private'!
+
+updateList
+ "set the lists contents to the filenames in the directory"
+
+ |oldCursor files newList index|
+
+ oldCursor := cursor.
+ self cursor:(Cursor read).
+
+ directoryId == directory id ifFalse:[
+ timeStamp := directory timeOfLastChange.
+ directoryId := directory id.
+ directoryContents := directory asText sort.
+ directoryFileTypes := OrderedCollection new.
+ directoryContents do:[:name | directoryFileTypes add:(directory typeOf:name)].
+ ].
+
+ files := directoryContents.
+ newList := OrderedCollection new.
+ index := 1.
+ files do:[:name |
+ (directoryFileTypes at:index) == #directory ifTrue:[
+ name = '..' ifTrue:[
+ newList add:name
+ ] ifFalse:[
+ name = '.' ifTrue:[
+ ] ifFalse:[
+ newList add:(name , ' ...')
+ ]
+ ]
+ ] ifFalse:[
+ (pattern isEmpty or:[pattern = '*' or:[pattern match:name]]) ifTrue:[
+ newList add:name
+ ]
+ ].
+ index := index + 1
+ ].
+ super list:newList.
+ self cursor:oldCursor.
+! !
+
+!FileSelectionList methodsFor:'realization'!
+
+realize
+ "make the view visible; redefined to check if directory is still
+ valid (using timestamp and inode numbers) - reread if not"
+
+ (timeStamp isNil
+ or:[(directory timeOfLastChange > timeStamp)
+ or:[(directoryId isNil)
+ or:[directoryId ~~ directory id]]]) ifTrue:[
+ directoryId := nil.
+ self updateList
+ ].
+ super realize
+! !