FileSelectionList.st
changeset 2832 23ad57a4ad76
parent 2817 7c82a9535b96
child 2833 1544bb56f6bf
equal deleted inserted replaced
2831:d2b64aae97e3 2832:23ad57a4ad76
   685 
   685 
   686     "then draw marks"
   686     "then draw marks"
   687     startVisLineNr to:endVisLineNr do:[:visLineNr |
   687     startVisLineNr to:endVisLineNr do:[:visLineNr |
   688         l := self visibleLineToListLine:visLineNr.
   688         l := self visibleLineToListLine:visLineNr.
   689         l notNil ifTrue:[
   689         l notNil ifTrue:[
   690             (directoryFileTypes at:l) == true ifTrue:[
   690             (directoryFileTypes at:l) ifTrue:[
   691                 self drawRightArrowInVisibleLine:visLineNr
   691                 self drawRightArrowInVisibleLine:visLineNr
   692             ]
   692             ]
   693         ]
   693         ]
   694     ]
   694     ]
   695 
   695 
   704     super redrawVisibleLine:visLineNr.
   704     super redrawVisibleLine:visLineNr.
   705     markDirectories ifFalse:[^ self].
   705     markDirectories ifFalse:[^ self].
   706 
   706 
   707     l := self visibleLineToListLine:visLineNr.
   707     l := self visibleLineToListLine:visLineNr.
   708     l notNil ifTrue:[
   708     l notNil ifTrue:[
   709         (directoryFileTypes at:l) == true ifTrue:[
   709         (directoryFileTypes at:l) ifTrue:[
   710             self drawRightArrowInVisibleLine:visLineNr
   710             self drawRightArrowInVisibleLine:visLineNr
   711         ]
   711         ]
   712     ]
   712     ]
   713 
   713 
   714     "Modified: / 22.9.1998 / 12:32:34 / cg"
   714     "Modified: / 22.9.1998 / 12:32:34 / cg"
   939 !
   939 !
   940 
   940 
   941 updateList
   941 updateList
   942     "set the lists contents to the filenames in the directory"
   942     "set the lists contents to the filenames in the directory"
   943 
   943 
   944     |oldCursor files newList index obsolete 
   944     |newList newTypes index obsolete 
   945      matching patternList dir ignoreCase|
   945      matching dir ignoreCase|
   946 
   946 
   947     directory isNil ifTrue:[
   947     directory isNil ifTrue:[
   948         super list:nil.
   948         self list:nil.
   949         files :=  newList := nil.
       
   950         ^ self
   949         ^ self
   951     ].
   950     ].
   952 
   951 
   953     oldCursor := cursor.
   952     self withCursor:(Cursor read) do:[
   954     self cursor:(Cursor read).
   953         "
   955 
   954          if the directory-id changed, MUST update.
   956     "
   955          (can happen after a restart, when a file is no longer
   957      if the directory-id changed, MUST update.
   956           there, has moved or is NFS-mounted differently)
   958      (can happen after a restart, when a file is no longer
   957         "
   959       there, has moved or is NFS-mounted differently)
   958         obsolete := directoryId ~~ directory id
   960     "
   959                     or:[directoryName ~= directory pathName
   961     obsolete := directoryId ~~ directory id
   960                     or:[timeStamp notNil
   962                 or:[directoryName ~= directory pathName
   961                         and:[directory modificationTime > timeStamp]]].
   963                 or:[timeStamp notNil
   962 
   964                     and:[directory modificationTime > timeStamp]]].
   963         obsolete ifTrue:[
   965 
   964             timeStamp := directory modificationTime.
   966     obsolete ifTrue:[
   965             directoryId := directory id.
   967         timeStamp := directory modificationTime.
   966             directoryName := directory pathName.
   968         directoryId := directory id.
   967             directoryContents := (directory fullDirectoryContents ? #()) sort.
   969         directoryName := directory pathName.
       
   970         directoryContents := (directory fullDirectoryContents ? #()) sort.
       
   971         directoryFileTypes := OrderedCollection new.
       
   972         directoryContents do:[:name | 
       
   973             |f|
       
   974 
       
   975             f := directory construct:name.
       
   976             directoryFileTypes add:(f isDirectory)
       
   977         ].
   968         ].
   978     ].
   969 
   979 
   970         newList := OrderedCollection new.
   980     files := directoryContents.
   971         newTypes := OrderedCollection new.
   981     newList := OrderedCollection new.
   972         index := 1.
   982     index := 1.
   973 
   983 
   974         ignoreCase := ignoreCaseInPattern ? (Filename isCaseSensitive not).
   984     ignoreCase := ignoreCaseInPattern ? (Filename isCaseSensitive not).
   975 
   985 
   976         dir := directory pathName asFilename.
   986     dir := directory pathName asFilename.
   977         directoryContents do:[:name |
   987     files do:[:name |
   978             |type fn fullName isDirectory ignore|
   988         |type fullName|
   979 
   989 
   980             fn := dir construct:name.
   990         fullName := dir constructString:name.
   981             fullName := dir constructString:name.
   991         (matchBlock isNil or:[matchBlock value:fullName]) ifTrue:[
   982             isDirectory := fn isDirectory.
   992             (directoryFileTypes at:index) == true ifTrue:[
   983             ignore := true.
   993                 ignoreDirectories ifFalse:[
   984 
   994                     name = '..' ifTrue:[
   985             (matchBlock isNil or:[matchBlock value:fullName]) ifTrue:[
   995                         ignoreParentDirectory ifFalse:[
   986                 isDirectory ifTrue:[
   996                             newList add:name.
   987                     ignoreDirectories ifFalse:[
   997                         ]
   988                         name = '..' ifTrue:[
   998                     ] ifFalse:[
   989                             ignoreParentDirectory ifFalse:[
   999                         name = '.' ifTrue:[
   990                                 ignore := false.
  1000                             "ignore"
   991                             ]
  1001                         ] ifFalse:[
   992                         ] ifFalse:[
  1002                             newList add:(name ", ' ...'").
   993                             name = '.' ifTrue:[
       
   994                                 "ignore"
       
   995                             ] ifFalse:[
       
   996                                 ignore := false.
       
   997                             ]
  1003                         ]
   998                         ]
  1004                     ]
   999                     ]
  1005                 ]
  1000                 ] ifFalse:[
  1006             ] ifFalse:[
  1001                     ignoreFiles ifFalse:[
  1007                 ignoreFiles ifFalse:[
  1002                         matching := true.
  1008                     matching := true.
  1003 
  1009 
  1004                         (pattern size > 0) ifTrue:[ 
  1010                     (pattern size > 0) ifTrue:[ 
  1005                             pattern ~= '*' ifTrue:[
  1011                         pattern ~= '*' ifTrue:[
  1006                                 matching := pattern compoundMatch:name ignoreCase:ignoreCase
  1012                             matching := pattern compoundMatch:name ignoreCase:ignoreCase
  1007                             ]
       
  1008                         ].
       
  1009                                         
       
  1010                         matching ifTrue:[
       
  1011                             ignore := false.
  1013                         ]
  1012                         ]
  1014                     ].
       
  1015                                     
       
  1016                     matching ifTrue:[
       
  1017                         newList add:name.
       
  1018                     ]
  1013                     ]
  1019                 ]
  1014                 ].
  1020             ].
  1015             ].
       
  1016             ignore ifFalse:[
       
  1017                 newList add:name.
       
  1018                 newTypes add:isDirectory.
       
  1019             ].
       
  1020             index := index + 1
  1021         ].
  1021         ].
  1022         index := index + 1
  1022         directoryFileTypes := newTypes.
  1023     ].
  1023         self list:newList.
  1024     super list:newList.
  1024     ].
  1025 
       
  1026     self cursor:oldCursor.
       
  1027 
  1025 
  1028     "Modified: / 18.9.1997 / 23:43:52 / stefan"
  1026     "Modified: / 18.9.1997 / 23:43:52 / stefan"
  1029     "Modified: / 16.12.1999 / 01:23:41 / cg"
  1027     "Modified: / 16.12.1999 / 01:23:41 / cg"
  1030 !
  1028 !
  1031 
  1029 
  1043 visibleLineNeedsSpecialCare:visLineNr
  1041 visibleLineNeedsSpecialCare:visLineNr
  1044     |l|
  1042     |l|
  1045 
  1043 
  1046     l := self visibleLineToListLine:visLineNr.
  1044     l := self visibleLineToListLine:visLineNr.
  1047     l notNil ifTrue:[
  1045     l notNil ifTrue:[
  1048         (directoryFileTypes at:l) == true ifTrue:[^ true].
  1046         (directoryFileTypes at:l) ifTrue:[^ true].
  1049         ^ super visibleLineNeedsSpecialCare:visLineNr
  1047         ^ super visibleLineNeedsSpecialCare:visLineNr
  1050     ].
  1048     ].
  1051     ^ false
  1049     ^ false
  1052 
  1050 
  1053     "Modified: / 22.9.1998 / 12:32:48 / cg"
  1051     "Modified: / 22.9.1998 / 12:32:48 / cg"
  1081 ! !
  1079 ! !
  1082 
  1080 
  1083 !FileSelectionList class methodsFor:'documentation'!
  1081 !FileSelectionList class methodsFor:'documentation'!
  1084 
  1082 
  1085 version
  1083 version
  1086     ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.50 2003-10-08 15:34:10 cg Exp $'
  1084     ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.51 2004-01-07 15:40:53 cg Exp $'
  1087 ! !
  1085 ! !