FileBrowser.st
changeset 1156 f3df28086973
parent 1154 c02ebe91ba11
child 1157 667a57034e40
equal deleted inserted replaced
1155:c37cb25bed62 1156:f3df28086973
   347 
   347 
   348 changeDisplayMode
   348 changeDisplayMode
   349     "toggle from long to short listing (and vice-versa)"
   349     "toggle from long to short listing (and vice-versa)"
   350 
   350 
   351     showLongList := showLongList not.
   351     showLongList := showLongList not.
   352     showLongList ifTrue:[
   352     self showOrHideTabView.
   353         false "self is3D" ifTrue:[
       
   354             scrollView topInset:(tabRulerView superView height).
       
   355             tabRulerView superView leftInset:(fileListView originRelativeTo:scrollView) x.
       
   356         ] ifFalse:[
       
   357             scrollView topInset:(tabRulerView height).
       
   358             tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x.
       
   359         ].
       
   360         tabRulerView hiddenTabs:#(1).
       
   361         tabRulerView fixedTabs:#(1).
       
   362     ] ifFalse:[
       
   363         scrollView topInset:0
       
   364     ].
       
   365     tabSpec := nil.
       
   366     self updateCurrentDirectory
   353     self updateCurrentDirectory
   367 
   354 
   368     "Modified: 28.3.1997 / 17:07:56 / cg"
   355     "Modified: 19.4.1997 / 09:50:14 / cg"
   369 !
   356 !
   370 
   357 
   371 changeDotFileVisibility
   358 changeDotFileVisibility
   372     "turn on/off visibility of files whose name starts with '.'"
   359     "turn on/off visibility of files whose name starts with '.'"
   373 
   360 
   987             aToolClass openOn:(currentDirectory pathName , '/' , fileName).
   974             aToolClass openOn:(currentDirectory pathName , '/' , fileName).
   988         ]
   975         ]
   989     ].
   976     ].
   990 
   977 
   991     "Modified: 14.11.1996 / 16:01:32 / cg"
   978     "Modified: 14.11.1996 / 16:01:32 / cg"
       
   979 !
       
   980 
       
   981 showOrHideTabView
       
   982     "depending on the showLongList setting, show or hde the tabSpec view"
       
   983 
       
   984     showLongList ifTrue:[
       
   985         false "self is3D" ifTrue:[
       
   986             scrollView topInset:(tabRulerView superView height).
       
   987             tabRulerView superView leftInset:(fileListView originRelativeTo:scrollView) x.
       
   988         ] ifFalse:[
       
   989             scrollView topInset:(tabRulerView height).
       
   990             tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x.
       
   991         ].
       
   992         tabRulerView hiddenTabs:#(1).
       
   993         tabRulerView fixedTabs:#(1).
       
   994     ] ifFalse:[
       
   995         scrollView topInset:0
       
   996     ].
       
   997     tabSpec := nil.
       
   998 
       
   999     "Created: 19.4.1997 / 09:50:02 / cg"
   992 ! !
  1000 ! !
   993 
  1001 
   994 !FileBrowser methodsFor:'help '!
  1002 !FileBrowser methodsFor:'help '!
   995 
  1003 
   996 helpTextFor:aComponent
  1004 helpTextFor:aComponent
  1189                                               self fileGet:true].
  1197                                               self fileGet:true].
  1190     fileListView multipleSelectOk:true.
  1198     fileListView multipleSelectOk:true.
  1191     fileListView delegate:self.
  1199     fileListView delegate:self.
  1192     fileListView menuHolder:self; menuPerformer:self; menuMessage:#fileListMenu.
  1200     fileListView menuHolder:self; menuPerformer:self; menuMessage:#fileListMenu.
  1193     fileListView allowDrag:true.
  1201     fileListView allowDrag:true.
  1194     fileListView dragObjectConverter:[:obj | |str o dir nm path idx|
  1202     fileListView dragObjectConverter:[:obj | 
       
  1203                                         |dir nm path idx|
       
  1204 obj printCR.
  1195                                         nm := obj theObject asString.
  1205                                         nm := obj theObject asString.
  1196                                         idx := fileListView list indexOf:nm.
  1206                                         idx := fileListView list indexOf:nm.
       
  1207 idx printCR.
  1197                                         idx == 0 ifTrue:[
  1208                                         idx == 0 ifTrue:[
  1198                                             "/ cannot happen ...
  1209                                             "/ cannot happen ...
  1199                                             nil
  1210                                             nil
  1200                                         ] ifFalse:[
  1211                                         ] ifFalse:[
  1201                                             nm := fileList at:idx.
  1212                                             nm := fileList at:idx.
       
  1213 nm printCR.
  1202                                             dir := currentDirectory pathName asFilename.
  1214                                             dir := currentDirectory pathName asFilename.
  1203                                             path := dir constructString:nm.
  1215                                             path := dir constructString:nm.
       
  1216 path printCR.
  1204                                             DropObject newFile:path.
  1217                                             DropObject newFile:path.
  1205                                         ]
  1218                                         ]
  1206                                      ].
  1219                                      ].
  1207     tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x.
  1220     tabRulerView leftInset:(fileListView originRelativeTo:scrollView) x.
       
  1221     self showOrHideTabView.
  1208 
  1222 
  1209     v := self initializeSubViewIn:frame.
  1223     v := self initializeSubViewIn:frame.
  1210 
  1224 
  1211     v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0).
  1225     v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0).
  1212     subView := v scrolledView.
  1226     subView := v scrolledView.
  1216 
  1230 
  1217     ObjectMemory addDependent:self.
  1231     ObjectMemory addDependent:self.
  1218 
  1232 
  1219     "Modified: 6.9.1995 / 20:26:06 / claus"
  1233     "Modified: 6.9.1995 / 20:26:06 / claus"
  1220     "Modified: 27.3.1997 / 11:04:31 / stefan"
  1234     "Modified: 27.3.1997 / 11:04:31 / stefan"
  1221     "Modified: 18.4.1997 / 18:18:26 / cg"
  1235     "Modified: 19.4.1997 / 09:56:06 / cg"
  1222 !
  1236 !
  1223 
  1237 
  1224 initializeCommandViewIn:frame
  1238 initializeCommandViewIn:frame
  1225     "set up the command view - can be redefined in subclasses as empty,
  1239     "set up the command view - can be redefined in subclasses as empty,
  1226      if no commandView is wanted"
  1240      if no commandView is wanted"
  1316 
  1330 
  1317 destroy
  1331 destroy
  1318     "destroy view and boxes"
  1332     "destroy view and boxes"
  1319 
  1333 
  1320     ObjectMemory removeDependent:self.
  1334     ObjectMemory removeDependent:self.
  1321     Processor removeTimedBlock:checkBlock.
  1335     self stopUpdateProcess.
  1322     listUpdateProcess notNil ifTrue:[
       
  1323         listUpdateProcess terminate.
       
  1324         listUpdateProcess := nil.
       
  1325     ].
       
  1326     checkBlock := nil.
  1336     checkBlock := nil.
  1327     super destroy
  1337     super destroy
  1328 
  1338 
  1329     "Modified: 18.4.1997 / 13:05:14 / cg"
  1339     "Modified: 19.4.1997 / 13:51:48 / cg"
  1330 !
  1340 !
  1331 
  1341 
  1332 filterPatternChanged
  1342 filterPatternChanged
  1333     fileListView scrollToTop. 
  1343     fileListView scrollToTop. 
  1334     self updateCurrentDirectory
  1344     self updateCurrentDirectory
  1976 !
  1986 !
  1977 
  1987 
  1978 doRemove
  1988 doRemove
  1979     "remove the selected file(s) - no questions asked"
  1989     "remove the selected file(s) - no questions asked"
  1980 
  1990 
  1981     |ok msg dir|
  1991     |ok msg dir idx needUpdate toRemove updateRunning|
       
  1992 
       
  1993     updateRunning := listUpdateProcess notNil.
       
  1994     self stopUpdateProcess.
       
  1995     toRemove := OrderedCollection new.
       
  1996 
       
  1997     "/
       
  1998     "/ did the directory change in the meanwhile ?
       
  1999     "/
       
  2000     needUpdate := (currentDirectory timeOfLastChange > timeOfLastCheck).
  1982 
  2001 
  1983     lockUpdate := true.
  2002     lockUpdate := true.
  1984     [
  2003     [
  1985         self selectedFilesDo:[:fileName |
  2004         self selectedFilesDo:[:fileName |
  1986             ok := false.
  2005             ok := false.
  2006                 self showAlert:msg with:(OperatingSystem lastErrorString)
  2025                 self showAlert:msg with:(OperatingSystem lastErrorString)
  2007             ] ifTrue:[
  2026             ] ifTrue:[
  2008 "
  2027 "
  2009                 self show:nil
  2028                 self show:nil
  2010 "
  2029 "
       
  2030                 idx := fileList indexOf:fileName.
       
  2031                 idx ~~ 0 ifTrue:[
       
  2032                     toRemove add:idx.
       
  2033                 ]
  2011             ]
  2034             ]
  2012         ].
  2035         ].
  2013     ] valueNowOrOnUnwindDo:[
  2036     ] valueNowOrOnUnwindDo:[
  2014         lockUpdate := false.
  2037         lockUpdate := false.
  2015         fileListView setSelection:nil.
  2038         fileListView setSelection:nil.
  2016         self updateCurrentDirectory.
  2039 
       
  2040         "/
       
  2041         "/ remove reverse - otherwise indices are wrong
       
  2042         "/
       
  2043         toRemove sort.
       
  2044         toRemove reverseDo:[:idx |
       
  2045             fileList removeIndex:idx.
       
  2046             fileListView removeIndex:idx.
       
  2047         ].
       
  2048 
       
  2049         updateRunning ifTrue:[
       
  2050             self updateCurrentDirectory
       
  2051         ] ifFalse:[
       
  2052             "
       
  2053              install a new check after some time
       
  2054             "
       
  2055             needUpdate ifFalse:[timeOfLastCheck := AbsoluteTime now].
       
  2056             Processor addTimedBlock:checkBlock afterSeconds:checkDelta
       
  2057         ]
  2017     ]
  2058     ]
  2018 
  2059 
  2019     "Modified: 17.1.1997 / 16:19:29 / cg"
  2060     "Modified: 19.4.1997 / 14:03:55 / cg"
  2020 !
  2061 !
  2021 
  2062 
  2022 doRename:oldName to:newName
  2063 doRename:oldName to:newName
  2023     (oldName notNil and:[newName notNil]) ifTrue:[
  2064     (oldName notNil and:[newName notNil]) ifTrue:[
  2024         (oldName isBlank or:[newName isBlank]) ifFalse:[
  2065         (oldName isBlank or:[newName isBlank]) ifFalse:[
  2749     ^ i
  2790     ^ i
  2750 
  2791 
  2751     "Modified: 18.4.1997 / 15:18:38 / cg"
  2792     "Modified: 18.4.1997 / 15:18:38 / cg"
  2752 !
  2793 !
  2753 
  2794 
       
  2795 stopUpdateProcess
       
  2796     Processor removeTimedBlock:checkBlock.
       
  2797     listUpdateProcess notNil ifTrue:[
       
  2798         listUpdateProcess terminate.
       
  2799         listUpdateProcess := nil.
       
  2800     ].
       
  2801 
       
  2802     "Created: 19.4.1997 / 13:51:34 / cg"
       
  2803 !
       
  2804 
  2754 updateCurrentDirectory
  2805 updateCurrentDirectory
  2755     "update listView with directory contents"
  2806     "update listView with directory contents"
  2756 
  2807 
  2757     "the code below may look somewhat complex -
  2808     "the code below may look somewhat complex -
  2758      it reads the directory first for the names,
  2809      it reads the directory first for the names,
  2769     "
  2820     "
  2770 
  2821 
  2771     self withReadCursorDo:[
  2822     self withReadCursorDo:[
  2772         |files matchPattern|
  2823         |files matchPattern|
  2773 
  2824 
  2774         Processor removeTimedBlock:checkBlock.
  2825         self stopUpdateProcess.
  2775         listUpdateProcess notNil ifTrue:[
       
  2776             listUpdateProcess terminate.
       
  2777             listUpdateProcess := nil.
       
  2778         ].
       
  2779 
  2826 
  2780         timeOfLastCheck := AbsoluteTime now.
  2827         timeOfLastCheck := AbsoluteTime now.
  2781 
  2828 
  2782         files := currentDirectory asOrderedCollection.
  2829         files := currentDirectory asOrderedCollection.
  2783 
  2830 
  2812         listUpdateProcess := [
  2859         listUpdateProcess := [
  2813             |prevUid prevGid fileNameString nameString groupString 
  2860             |prevUid prevGid fileNameString nameString groupString 
  2814              modeString info line len list
  2861              modeString info line len list
  2815              anyImages passDone lineIndex aFileName
  2862              anyImages passDone lineIndex aFileName
  2816              entry typ f p typeString done endIndex 
  2863              entry typ f p typeString done endIndex 
  2817              state stopAtEnd nextState img prevFirstLine prevLastLine|
  2864              state stopAtEnd nextState img prevFirstLine prevLastLine
       
  2865              numVisible|
  2818 
  2866 
  2819             tabSpec isNil ifTrue:[
  2867             tabSpec isNil ifTrue:[
  2820                 showLongList ifTrue:[
  2868                 showLongList ifTrue:[
  2821                     self defineTabulatorsForLongList
  2869                     self defineTabulatorsForLongList
  2822                 ] ifFalse:[
  2870                 ] ifFalse:[
  2844             "/ (since we have to stat each file, this may take a while longer)
  2892             "/ (since we have to stat each file, this may take a while longer)
  2845             "/ Visible items are always filled first.
  2893             "/ Visible items are always filled first.
  2846 
  2894 
  2847             "/
  2895             "/
  2848             "/ the state machine
  2896             "/ the state machine
  2849             "/   #visibleIcons 
       
  2850             "/   #visibleAttributes 
       
  2851             "/   #visibleTypes
       
  2852             "/   #visibleImages
       
  2853             "/   #remainingIcons 
       
  2854             "/   #remainingAttributes
       
  2855             "/   #remainingTypes
       
  2856             "/   #remainingImages
       
  2857             "/
  2897             "/
  2858             nextState := IdentityDictionary new.
  2898             nextState := IdentityDictionary new.
  2859             showLongList ifTrue:[
  2899             showLongList ifTrue:[
  2860                 nextState add:(#visibleIcons -> #visibleAttributes).
  2900                 nextState add:(#visibleIcons -> #visibleAttributes).
  2861                 nextState add:(#visibleAttributes -> #visibleTypes).
  2901                 nextState add:(#visibleAttributes -> #visibleTypes).
  2862                 nextState add:(#visibleTypes -> #visibleImages).
  2902                 nextState add:(#visibleTypes -> #visibleImages).
  2863                 nextState add:(#visibleImages -> #remainingIcons).
  2903                 nextState add:(#visibleImages -> #nextPageIcons).
       
  2904 
       
  2905                 nextState add:(#nextPageIcons -> #nextPageAttributes).
       
  2906                 nextState add:(#nextPageAttributes -> #nextPageTypes).
       
  2907                 nextState add:(#nextPageTypes -> #nextPageImages).
       
  2908                 nextState add:(#nextPageImages -> #previousPageIcons).
       
  2909 
       
  2910                 nextState add:(#previousPageIcons -> #previousPageAttributes).
       
  2911                 nextState add:(#previousPageAttributes -> #previousPageTypes).
       
  2912                 nextState add:(#previousPageTypes -> #previousPageImages).
       
  2913                 nextState add:(#previousPageImages -> #remainingIcons).
       
  2914 
  2864                 nextState add:(#remainingIcons -> #remainingAttributes).
  2915                 nextState add:(#remainingIcons -> #remainingAttributes).
  2865                 nextState add:(#remainingAttributes -> #remainingTypes).
  2916                 nextState add:(#remainingAttributes -> #remainingTypes).
  2866                 nextState add:(#remainingTypes -> #remainingImages).
  2917                 nextState add:(#remainingTypes -> #remainingImages).
  2867                 nextState add:(#remainingImages -> nil).
  2918                 nextState add:(#remainingImages -> nil).
  2868             ] ifFalse:[
  2919             ] ifFalse:[
  2869                 nextState add:(#visibleIcons -> #remainingIcons).
  2920                 nextState add:(#visibleIcons -> #nextPageIcons).
       
  2921                 nextState add:(#nextPageIcons -> #previousPageIcons).
       
  2922                 nextState add:(#previousPageIcons -> #remainingIcons).
  2870                 nextState add:(#remainingIcons -> nil).
  2923                 nextState add:(#remainingIcons -> nil).
  2871             ].
  2924             ].
  2872 
  2925 
  2873             anyImages := false.
  2926             anyImages := false.
  2874 
  2927 
  2900                     endIndex := prevLastLine := fileListView lastLineShown.
  2953                     endIndex := prevLastLine := fileListView lastLineShown.
  2901                     endIndex := endIndex min:(files size).
  2954                     endIndex := endIndex min:(files size).
  2902                     state := #visibleIcons.
  2955                     state := #visibleIcons.
  2903                 ].
  2956                 ].
  2904 
  2957 
  2905                 "/
  2958                 (lineIndex between:1 and:(files size)) ifTrue:[
  2906                 "/ expand the next entry ...
  2959 
  2907                 "/
       
  2908                 aFileName := files at:lineIndex.
       
  2909                 entry := fileListView at:lineIndex.
       
  2910 
       
  2911                 ((state == #visibleIcons)
       
  2912                 or:[state == #remainingIcons]) ifTrue:[
       
  2913                     "/
  2960                     "/
  2914                     "/ pass 1 - icons
  2961                     "/ expand the next entry ...
  2915                     "/
  2962                     "/
  2916                     (passDone at:lineIndex) < 1 ifTrue:[
  2963                     aFileName := files at:lineIndex.
  2917                         ((currentDirectory isDirectory:aFileName) and:[
  2964                     entry := fileListView at:lineIndex.
  2918                         (aFileName ~= '..') and:[aFileName ~= '.']]) ifTrue:[
  2965 
  2919                             fileNameString := aFileName , ' ...'
  2966                     (state endsWith:'Icons') ifTrue:[
  2920                         ] ifFalse:[
  2967                         "/
  2921                             fileNameString := aFileName
  2968                         "/ pass 1 - icons
       
  2969                         "/
       
  2970                         (passDone at:lineIndex) < 1 ifTrue:[
       
  2971                             ((currentDirectory isDirectory:aFileName) and:[
       
  2972                             (aFileName ~= '..') and:[aFileName ~= '.']]) ifTrue:[
       
  2973                                 fileNameString := aFileName , ' ...'
       
  2974                             ] ifFalse:[
       
  2975                                 fileNameString := aFileName
       
  2976                             ].
       
  2977 
       
  2978                             showLongList ifTrue:[
       
  2979                                 len := fileNameString size.
       
  2980                                 (len > 20) ifTrue:[
       
  2981                                     fileNameString := (fileNameString contractTo:20)
       
  2982                                 ].
       
  2983                             ].
       
  2984 
       
  2985                             entry colAt:1 put:(self iconForFile:aFileName).
       
  2986                             entry colAt:2 put:fileNameString.
       
  2987 
       
  2988                             fileListView at:lineIndex put:entry.
       
  2989 
       
  2990                             anyImages ifFalse:[
       
  2991                                 (Image isImageFileSuffix:(aFileName asFilename suffix))
       
  2992                                 ifTrue:[
       
  2993                                     anyImages := true
       
  2994                                 ]
       
  2995                             ].
       
  2996                             passDone at:lineIndex put:1
       
  2997                         ]
       
  2998                     ].
       
  2999 
       
  3000                     (state endsWith:'Attributes') ifTrue:[
       
  3001                         "/
       
  3002                         "/ pass 2 - everything except fileType (which takes very long)
       
  3003                         "/
       
  3004                         (passDone at:lineIndex) < 2 ifTrue:[
       
  3005 
       
  3006                             info := currentDirectory infoOf:aFileName.
       
  3007                             info isNil ifTrue:[
       
  3008                                 "not accessable - usually a symlink,
       
  3009                                  to a nonexisting/nonreadable file
       
  3010                                 "
       
  3011                                 entry colAt:7 put:'(bad symbolic link ?)'.
       
  3012                             ] ifFalse:[
       
  3013                                 typ := (info type).
       
  3014 
       
  3015                                 modeString := self getModeString:(info at:#mode)
       
  3016                                                             with:#( '' $r $w $x 
       
  3017                                                                     '  ' $r $w $x 
       
  3018                                                                     '  ' $r $w $x ).
       
  3019                                 entry colAt:3 put:modeString.
       
  3020 
       
  3021                                 ((info uid) ~~ prevUid) ifTrue:[
       
  3022                                     prevUid := (info uid).
       
  3023                                     nameString := OperatingSystem getUserNameFromID:prevUid.
       
  3024                                     nameString := nameString , (String new:(10 - nameString size))
       
  3025                                 ].
       
  3026                                 entry colAt:4 put:nameString withoutSpaces.
       
  3027 
       
  3028                                 ((info gid) ~~ prevGid) ifTrue:[
       
  3029                                     prevGid := (info gid).
       
  3030                                     groupString := OperatingSystem getGroupNameFromID:prevGid.
       
  3031                                     groupString := groupString , (String new:(10 - groupString size))
       
  3032                                 ].
       
  3033                                 entry colAt:5 put:groupString withoutSpaces.
       
  3034 
       
  3035                                 (typ == #regular) ifTrue:[
       
  3036                                     entry colAt:6 put:(self sizePrintString:(info size)).
       
  3037                                 ].
       
  3038 
       
  3039                                 f := currentDirectory asFilename:aFileName.
       
  3040                                 f isSymbolicLink ifTrue:[
       
  3041                                     p := f linkInfo path.    
       
  3042                                     typeString := 'symbolic link to ' , p
       
  3043                                 ] ifFalse:[
       
  3044                                     typeString := typ asString
       
  3045                                 ].
       
  3046                                 entry colAt:7 put:typeString
       
  3047                             ].
       
  3048                             fileListView at:lineIndex put:entry.
       
  3049                             passDone at:lineIndex put:2.
  2922                         ].
  3050                         ].
  2923 
  3051                     ].
  2924                         showLongList ifTrue:[
  3052 
  2925                             len := fileNameString size.
  3053                     (state endsWith:'Types') ifTrue:[
  2926                             (len > 20) ifTrue:[
  3054                         "/
  2927                                 fileNameString := (fileNameString contractTo:20)
  3055                         "/ pass 3: add fileType
       
  3056                         "/
       
  3057                         (passDone at:lineIndex) < 3 ifTrue:[
       
  3058                             info := currentDirectory infoOf:aFileName.
       
  3059                             info notNil ifTrue:[
       
  3060                                 f := currentDirectory asFilename:aFileName.
       
  3061                                 f isSymbolicLink ifFalse:[
       
  3062                                     typ := info type.
       
  3063                                     typ ~~ #directory ifTrue:[
       
  3064                                         (Image isImageFileSuffix:(f suffix)) ifFalse:[
       
  3065                                             typeString := f fileType.
       
  3066 
       
  3067                                             entry colAt:7 put:typeString.
       
  3068                                             fileListView at:lineIndex put:entry
       
  3069                                         ]
       
  3070                                     ].
       
  3071                                 ].
  2928                             ].
  3072                             ].
       
  3073 
       
  3074                             passDone at:lineIndex put:3
  2929                         ].
  3075                         ].
  2930 
       
  2931                         entry colAt:1 put:(self iconForFile:aFileName).
       
  2932                         entry colAt:2 put:fileNameString.
       
  2933 
       
  2934                         fileListView at:lineIndex put:entry.
       
  2935 
       
  2936                         anyImages ifFalse:[
       
  2937                             (Image isImageFileSuffix:(aFileName asFilename suffix))
       
  2938                             ifTrue:[
       
  2939                                 anyImages := true
       
  2940                             ]
       
  2941                         ].
       
  2942                         passDone at:lineIndex put:1
       
  2943                     ]
       
  2944                 ].
       
  2945 
       
  2946                 ((state == #visibleAttributes)
       
  2947                 or:[state == #remainingAttributes]) ifTrue:[
       
  2948                     "/
       
  2949                     "/ pass 2 - everything except fileType (which takes very long)
       
  2950                     "/
       
  2951                     (passDone at:lineIndex) < 2 ifTrue:[
       
  2952 
       
  2953                         info := currentDirectory infoOf:aFileName.
       
  2954                         info isNil ifTrue:[
       
  2955                             "not accessable - usually a symlink,
       
  2956                              to a nonexisting/nonreadable file
       
  2957                             "
       
  2958                             entry colAt:7 put:'(bad symbolic link ?)'.
       
  2959                         ] ifFalse:[
       
  2960                             typ := (info type).
       
  2961 
       
  2962                             modeString := self getModeString:(info at:#mode)
       
  2963                                                         with:#( '' $r $w $x 
       
  2964                                                                 '  ' $r $w $x 
       
  2965                                                                 '  ' $r $w $x ).
       
  2966                             entry colAt:3 put:modeString.
       
  2967 
       
  2968                             ((info uid) ~~ prevUid) ifTrue:[
       
  2969                                 prevUid := (info uid).
       
  2970                                 nameString := OperatingSystem getUserNameFromID:prevUid.
       
  2971                                 nameString := nameString , (String new:(10 - nameString size))
       
  2972                             ].
       
  2973                             entry colAt:4 put:nameString withoutSpaces.
       
  2974 
       
  2975                             ((info gid) ~~ prevGid) ifTrue:[
       
  2976                                 prevGid := (info gid).
       
  2977                                 groupString := OperatingSystem getGroupNameFromID:prevGid.
       
  2978                                 groupString := groupString , (String new:(10 - groupString size))
       
  2979                             ].
       
  2980                             entry colAt:5 put:groupString withoutSpaces.
       
  2981 
       
  2982                             (typ == #regular) ifTrue:[
       
  2983                                 entry colAt:6 put:(self sizePrintString:(info size)).
       
  2984                             ].
       
  2985 
       
  2986                             f := currentDirectory asFilename:aFileName.
       
  2987                             f isSymbolicLink ifTrue:[
       
  2988                                 p := f linkInfo path.    
       
  2989                                 typeString := 'symbolic link to ' , p
       
  2990                             ] ifFalse:[
       
  2991                                 typeString := typ asString
       
  2992                             ].
       
  2993                             entry colAt:7 put:typeString
       
  2994                         ].
       
  2995                         fileListView at:lineIndex put:entry.
       
  2996                         passDone at:lineIndex put:2.
       
  2997                     ].
  3076                     ].
  2998                 ].
  3077 
  2999 
  3078                     (state endsWith:'Images') ifTrue:[
  3000                 ((state == #visibleTypes)
  3079                         "/
  3001                 or:[state == #remainingTypes]) ifTrue:[
  3080                         "/ pass 4: read images
  3002                     "/
  3081                         "/
  3003                     "/ pass 3: add fileType
  3082                         (passDone at:lineIndex) < 4 ifTrue:[
  3004                     "/
  3083                             f := currentDirectory asFilename construct:aFileName.
  3005                     (passDone at:lineIndex) < 3 ifTrue:[
  3084                             (Image isImageFileSuffix:(f suffix)) ifTrue:[
  3006                         info := currentDirectory infoOf:aFileName.
  3085                                 f isDirectory ifFalse:[
  3007                         info notNil ifTrue:[
  3086                                     img := Image fromFile:(f pathName).
  3008                             f := currentDirectory asFilename:aFileName.
  3087                                     img notNil ifTrue:[
  3009                             f isSymbolicLink ifFalse:[
  3088                                         img := img magnifiedTo:16@16.
  3010                                 typ := info type.
  3089                                         img := img on:self device.
  3011                                 typ ~~ #directory ifTrue:[
  3090                                         entry colAt:7 put:img.
  3012                                     (Image isImageFileSuffix:(f suffix)) ifFalse:[
       
  3013                                         typeString := f fileType.
       
  3014 
       
  3015                                         entry colAt:7 put:typeString.
       
  3016                                         fileListView at:lineIndex put:entry
  3091                                         fileListView at:lineIndex put:entry
  3017                                     ]
  3092                                     ]
  3018                                 ].
  3093                                 ]
  3019                             ].
  3094                             ].
       
  3095                             passDone at:lineIndex put:4
  3020                         ].
  3096                         ].
  3021 
       
  3022                         passDone at:lineIndex put:3
       
  3023                     ].
       
  3024                 ].
       
  3025 
       
  3026                 ((state == #visibleImages)
       
  3027                 or:[state == #remainingImages]) ifTrue:[
       
  3028                     "/
       
  3029                     "/ pass 4: read images
       
  3030                     "/
       
  3031                     (passDone at:lineIndex) < 4 ifTrue:[
       
  3032                         f := currentDirectory asFilename construct:aFileName.
       
  3033                         (Image isImageFileSuffix:(f suffix)) ifTrue:[
       
  3034                             f isDirectory ifFalse:[
       
  3035                                 img := Image fromFile:(f pathName).
       
  3036                                 img notNil ifTrue:[
       
  3037                                     img := img magnifiedTo:16@16.
       
  3038                                     img := img on:self device.
       
  3039                                     entry colAt:7 put:img.
       
  3040                                     fileListView at:lineIndex put:entry
       
  3041                                 ]
       
  3042                             ]
       
  3043                         ].
       
  3044                         passDone at:lineIndex put:4
       
  3045                     ].
  3097                     ].
  3046                 ].
  3098                 ].
  3047 
  3099 
  3048                 "/
  3100                 "/
  3049                 "/ advance to the next line
  3101                 "/ advance to the next line
  3050                 "/
  3102                 "/
  3051                 lineIndex := lineIndex + 1.
  3103                 lineIndex := lineIndex + 1.
  3052                 lineIndex > endIndex ifTrue:[
  3104                 lineIndex > endIndex ifTrue:[
  3053                     "/ finished this round ...
  3105                     "/ finished this round ...
       
  3106                     "/ see what we are going for ...
       
  3107                     numVisible := (fileListView lastLineShown - fileListView firstLineShown + 1).
  3054 
  3108 
  3055                     state := nextState at:state ifAbsent:nil.
  3109                     state := nextState at:state ifAbsent:nil.
       
  3110 
  3056                     state isNil ifTrue:[
  3111                     state isNil ifTrue:[
  3057                         done := true
  3112                         done := true
  3058                     ] ifFalse:[
  3113                     ] ifFalse:[
  3059                         (state startsWith:'visible') ifTrue:[
  3114                         (state startsWith:'visible') ifTrue:[
  3060                             lineIndex := fileListView firstLineShown.
  3115                             lineIndex := fileListView firstLineShown.
  3061                             endIndex := fileListView lastLineShown.
  3116                             endIndex := fileListView lastLineShown.
  3062                             endIndex := endIndex min:(files size).
  3117                             endIndex := endIndex min:(files size).
  3063                         ] ifFalse:[
  3118                         ] ifFalse:[
  3064                             lineIndex := 1.
  3119                             (state startsWith:'nextPage') ifTrue:[
  3065                             endIndex := files size.
  3120                                 lineIndex := fileListView lastLineShown + 1.
       
  3121                                 endIndex := lineIndex + numVisible.
       
  3122                                 endIndex := endIndex min:(files size).
       
  3123                                 lineIndex := lineIndex min:(files size).
       
  3124                             ] ifFalse:[
       
  3125                                 (state startsWith:'previousPage') ifTrue:[
       
  3126                                     endIndex := fileListView firstLineShown - 1.
       
  3127                                     lineIndex := endIndex - numVisible.
       
  3128                                     lineIndex := lineIndex max:1.
       
  3129                                     endIndex := endIndex min:(files size).
       
  3130                                     endIndex := endIndex max:1.
       
  3131                                 ] ifFalse:[ 
       
  3132                                     "/ remaining
       
  3133                                     lineIndex := 1.
       
  3134                                     endIndex := files size.
       
  3135                                 ]
       
  3136                             ]
  3066                         ]
  3137                         ]
  3067                     ]
  3138                     ]
  3068                 ]
  3139                 ]
  3069             ].
  3140             ].
  3070 
  3141 
  3077         "
  3148         "
  3078         Processor addTimedBlock:checkBlock afterSeconds:checkDelta
  3149         Processor addTimedBlock:checkBlock afterSeconds:checkDelta
  3079     ]
  3150     ]
  3080 
  3151 
  3081     "Modified: 21.9.1995 / 11:40:23 / claus"
  3152     "Modified: 21.9.1995 / 11:40:23 / claus"
  3082     "Modified: 19.4.1997 / 09:24:37 / cg"
  3153     "Modified: 19.4.1997 / 14:35:43 / cg"
  3083 ! !
  3154 ! !
  3084 
  3155 
  3085 !FileBrowser methodsFor:'private-file-I/O'!
  3156 !FileBrowser methodsFor:'private-file-I/O'!
  3086 
  3157 
  3087 readFile:fileName
  3158 readFile:fileName
  3347 ! !
  3418 ! !
  3348 
  3419 
  3349 !FileBrowser class methodsFor:'documentation'!
  3420 !FileBrowser class methodsFor:'documentation'!
  3350 
  3421 
  3351 version
  3422 version
  3352     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.146 1997-04-19 07:25:11 cg Exp $'
  3423     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.147 1997-04-19 13:23:34 cg Exp $'
  3353 ! !
  3424 ! !
  3354 FileBrowser initialize!
  3425 FileBrowser initialize!