author | Claus Gittinger <cg@exept.de> |
Tue, 08 Apr 2003 15:38:08 +0200 | |
changeset 2475 | 1f90c55c4f78 |
parent 2457 | d1505cba8e39 |
child 2479 | 82e797682bf9 |
permissions | -rw-r--r-- |
1431 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
1780 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1390 | 16 |
HierarchicalList subclass:#HierarchicalFileList |
2298
22e95baad346
showCursor and mountPoints instance variables removed
penk
parents:
2297
diff
changeset
|
17 |
instanceVariableNames:'matchBlock indicatorList indicatorTask sortBlock' |
2138 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Support' |
|
1390 | 21 |
! |
22 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
23 |
HierarchicalItem subclass:#HierarchicalFileItem |
2297 | 24 |
instanceVariableNames:'icon contentsItem' |
2293 | 25 |
classVariableNames:'LastUIDToUserNameMapping LastGIDToGroupNameMapping' |
2138 | 26 |
poolDictionaries:'' |
27 |
privateIn:HierarchicalFileList |
|
1390 | 28 |
! |
29 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
30 |
HierarchicalFileList::HierarchicalFileItem subclass:#File |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
31 |
instanceVariableNames:'' |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
32 |
classVariableNames:'' |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
33 |
poolDictionaries:'' |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
34 |
privateIn:HierarchicalFileList |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
35 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
36 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
37 |
HierarchicalFileList::HierarchicalFileItem subclass:#Directory |
2475 | 38 |
instanceVariableNames:'modificationTime makeIconGray quickChildrenInfo' |
39 |
classVariableNames:'StateUnknown StateHasChildren StateHasNoChildren StateFetching' |
|
2138 | 40 |
poolDictionaries:'' |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
41 |
privateIn:HierarchicalFileList |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
42 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
43 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
44 |
HierarchicalFileList::Directory subclass:#RemoteDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
45 |
instanceVariableNames:'' |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
46 |
classVariableNames:'' |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
47 |
poolDictionaries:'' |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
48 |
privateIn:HierarchicalFileList |
1390 | 49 |
! |
50 |
||
1431 | 51 |
!HierarchicalFileList class methodsFor:'documentation'! |
52 |
||
53 |
copyright |
|
54 |
" |
|
55 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
56 |
All Rights Reserved |
|
57 |
||
58 |
This software is furnished under a license and may be used |
|
59 |
only in accordance with the terms of that license and with the |
|
60 |
inclusion of the above copyright notice. This software may not |
|
61 |
be provided or otherwise made available to, or used by, any |
|
62 |
other person. No title to or ownership of the software is |
|
63 |
hereby transferred. |
|
64 |
" |
|
65 |
||
66 |
! ! |
|
1390 | 67 |
|
68 |
!HierarchicalFileList class methodsFor:'examples'! |
|
69 |
||
2180 | 70 |
examples |
2130 | 71 |
" |
2306 | 72 |
open filebrowser without monitoring cycle |
73 |
||
2180 | 74 |
[exBegin] |
2306 | 75 |
|top sel list directory| |
1390 | 76 |
|
77 |
list := HierarchicalFileList new. |
|
78 |
list showRoot:false. |
|
2130 | 79 |
list matchBlock:[:fn :isDir| true ]. |
1390 | 80 |
|
2306 | 81 |
directory := Filename currentDirectory. |
82 |
directory := Filename homeDirectory. |
|
83 |
||
84 |
list directory:(directory asAbsoluteFilename). |
|
85 |
||
1390 | 86 |
top := StandardSystemView new; extent:300@300. |
87 |
sel := ScrollableView for:HierarchicalListView miniScroller:true |
|
88 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
89 |
||
90 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
91 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
|
92 |
||
2296 | 93 |
sel hasConstantHeight:true. |
2259 | 94 |
sel list:list. |
95 |
||
1390 | 96 |
top open. |
2259 | 97 |
[exEnd] |
2306 | 98 |
|
99 |
||
100 |
open filebrowser and monitore contents |
|
101 |
[exBegin] |
|
102 |
|top sel list directory| |
|
103 |
||
104 |
list := HierarchicalFileList new. |
|
105 |
list showRoot:false. |
|
106 |
list matchBlock:[:fn :isDir| true ]. |
|
107 |
||
108 |
directory := Filename currentDirectory. |
|
109 |
directory := Filename homeDirectory. |
|
110 |
||
111 |
list directory:(directory asAbsoluteFilename). |
|
112 |
||
113 |
top := StandardSystemView new; extent:300@300. |
|
114 |
sel := ScrollableView for:HierarchicalListView miniScroller:true |
|
115 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
116 |
||
117 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
118 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
|
119 |
||
120 |
sel hasConstantHeight:true. |
|
121 |
sel list:list. |
|
122 |
list monitoringTaskDelay:0.5. |
|
123 |
top open. |
|
124 |
[exEnd] |
|
125 |
||
2180 | 126 |
" |
1390 | 127 |
! ! |
128 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
129 |
!HierarchicalFileList class methodsFor:'helpers'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
130 |
|
2293 | 131 |
forInfoItem:aItem |
132 |
"instance creation helper |
|
133 |
" |
|
134 |
| info fileType retItem| |
|
135 |
||
136 |
info := aItem info. |
|
137 |
fileType := aItem type. |
|
138 |
retItem := self itemFor:aItem fileName fileType:fileType. |
|
139 |
retItem fileInfo:info. |
|
140 |
^ retItem |
|
141 |
! |
|
142 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
143 |
itemFor:aFileOrDirectoryName fileType:fileType |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
144 |
"instance creation helper |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
145 |
" |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
146 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
147 |
fileType == #directory ifTrue:[ |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
148 |
^ Directory fileName:aFileOrDirectoryName. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
149 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
150 |
fileType == #remoteDirectory ifTrue:[ |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
151 |
^ RemoteDirectory fileName:aFileOrDirectoryName. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
152 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
153 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
154 |
^ File fileName:aFileOrDirectoryName. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
155 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
156 |
|
1390 | 157 |
!HierarchicalFileList methodsFor:'accessing'! |
158 |
||
159 |
directory |
|
160 |
"returns the root directory or nil |
|
161 |
" |
|
162 |
^ root notNil ifTrue:[root fileName] ifFalse:[nil] |
|
163 |
||
164 |
! |
|
165 |
||
166 |
directory:aDirectory |
|
167 |
"set the root directory or nil |
|
168 |
" |
|
2272 | 169 |
self directory:aDirectory expand:true |
170 |
! |
|
171 |
||
172 |
directory:aDirectory expand:doExpand |
|
2388 | 173 |
"set the root directory or nil; reuse old |
174 |
items if existant |
|
2272 | 175 |
" |
2388 | 176 |
|oldDir newDir oldRoot newRoot index changeToParent children| |
2294 | 177 |
|
2388 | 178 |
( aDirectory isNil |
179 |
or:[(newDir := aDirectory asFilename) exists not] |
|
180 |
) ifTrue:[ |
|
2294 | 181 |
self root:nil. |
2388 | 182 |
^ self |
1390 | 183 |
]. |
2299 | 184 |
|
2388 | 185 |
newDir isDirectory ifFalse:[ |
186 |
newDir := newDir directory |
|
187 |
]. |
|
188 |
newDir := newDir asCanonicalizedFilename. |
|
189 |
oldDir := self directory. |
|
190 |
||
191 |
oldDir = newDir ifTrue:[^ self]. |
|
192 |
oldRoot := root. |
|
193 |
||
194 |
changeToParent := false. |
|
195 |
||
196 |
oldDir notNil ifTrue:[ |
|
197 |
oldDir directory = newDir ifTrue:[ |
|
198 |
changeToParent := true. |
|
199 |
] ifFalse:[ |
|
200 |
"search for existing item |
|
201 |
" |
|
202 |
self do:[:el| |
|
203 |
el fileName = newDir ifTrue:[ |
|
204 |
el parent:nil. |
|
205 |
self root:el. |
|
206 |
doExpand ifTrue:[ el expand ]. |
|
207 |
^ self |
|
208 |
]. |
|
209 |
]. |
|
210 |
]. |
|
211 |
]. |
|
212 |
newRoot := HierarchicalFileItem fileName:newDir. |
|
213 |
newRoot setExpanded:false. "/ to supress change notifications |
|
214 |
self root:newRoot. |
|
215 |
||
216 |
children := newRoot children ? #(). |
|
217 |
||
218 |
"/ disable <cd ..> handling |
|
219 |
changeToParent := false. |
|
220 |
||
221 |
changeToParent ifTrue:[ |
|
222 |
index := children findFirst:[:el| el fileName = oldDir ]. |
|
223 |
index ~~ 0 ifTrue:[ newRoot at:index put:oldRoot ]. |
|
224 |
]. |
|
2475 | 225 |
doExpand ifTrue:[ newRoot enforcedExpand ]. |
2259 | 226 |
! |
227 |
||
228 |
root:aRoot |
|
229 |
"stop update-task |
|
230 |
" |
|
231 |
self criticalDo:[ |
|
2306 | 232 |
indicatorList notNil ifTrue:[ |
2259 | 233 |
indicatorList do:[:el| el resetFetchIndicator ]. |
234 |
indicatorList removeAll. |
|
235 |
] |
|
236 |
]. |
|
2306 | 237 |
aRoot notNil ifTrue:[ |
2267 | 238 |
self showRoot ifFalse:[aRoot setExpanded:true ] |
2259 | 239 |
]. |
240 |
^ super root:aRoot |
|
1390 | 241 |
! ! |
242 |
||
243 |
!HierarchicalFileList methodsFor:'actions'! |
|
244 |
||
245 |
matchBlock |
|
246 |
"set the matchBlock - if non-nil, it controls which files are visible. |
|
247 |
" |
|
248 |
^ matchBlock |
|
249 |
||
250 |
! |
|
251 |
||
252 |
matchBlock:aBlock |
|
253 |
"set the matchBlock - if non-nil, it controls which files are visible. |
|
254 |
" |
|
255 |
matchBlock := aBlock. |
|
1866 | 256 |
|
257 |
root notNil ifTrue:[ |
|
1867 | 258 |
self recursionLock critical:[ |
259 |
self stopMonitoringTask. |
|
260 |
root matchBlockChanged. |
|
261 |
]. |
|
262 |
self startMonitoringTask. |
|
1866 | 263 |
]. |
1867 | 264 |
|
2293 | 265 |
! |
266 |
||
267 |
sortBlock |
|
268 |
"set the matchBlock - if non-nil, it controls which files are visible. |
|
269 |
" |
|
2296 | 270 |
sortBlock notNil ifTrue:[ ^ sortBlock ]. |
271 |
||
272 |
sortBlock := [:a :b| |aIsDir| |
|
273 |
aIsDir := a isDirectory. |
|
274 |
aIsDir == b isDirectory ifTrue:[a fileName name <= b fileName name] |
|
275 |
ifFalse:[aIsDir]. |
|
2293 | 276 |
]. |
277 |
^ sortBlock |
|
278 |
! |
|
279 |
||
280 |
sortBlock:aBlock |
|
281 |
"set the matchBlock - if non-nil, it controls which files are visible. |
|
282 |
" |
|
283 |
sortBlock := aBlock. |
|
284 |
||
285 |
root notNil ifTrue:[ |
|
286 |
self recursionLock critical:[ |
|
287 |
self stopMonitoringTask. |
|
2294 | 288 |
root recursiveSort:aBlock. |
2293 | 289 |
]. |
290 |
self startMonitoringTask. |
|
291 |
]. |
|
1390 | 292 |
! ! |
293 |
||
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
294 |
!HierarchicalFileList methodsFor:'private monitoring task'! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
295 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
296 |
monitoringCycle |
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
297 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
298 |
self monitoringCycle:false |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
299 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
300 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
301 |
monitoringCycle:update |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
302 |
"the block evaluated by the monitoring task; test whether directory is expanded |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
303 |
otherwise we have not to evaluate the directory contents. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
304 |
think about remote file-systems |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
305 |
" |
2380 | 306 |
|index item| |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
307 |
|
2429 | 308 |
item := root. |
309 |
item isNil ifTrue:[^ self]. |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
310 |
|
2429 | 311 |
self showRoot ifTrue:[ index := 2 ] "/ root is part of list (discard first entry) |
312 |
ifFalse:[ index := 1 ]. "/ root not part of list |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
313 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
314 |
[item notNil] whileTrue:[ |
2380 | 315 |
dependents size == 0 ifTrue:[ ^ self ]. |
316 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
317 |
item isDirectory ifTrue:[ |
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
318 |
update ifTrue:[ |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
319 |
item modificationTime:nil. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
320 |
]. |
2267 | 321 |
item monitoringCycle |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
322 |
]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
323 |
Processor yield. |
2429 | 324 |
item := self at:index ifAbsent:nil. |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
325 |
index := index + 1. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
326 |
]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
327 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
328 |
|
1390 | 329 |
!HierarchicalFileList methodsFor:'protocol'! |
330 |
||
331 |
childrenFor:anItem |
|
332 |
"returns all visible children derived from the physical |
|
333 |
directory contents. |
|
334 |
" |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
335 |
|contents list matchBlock| |
1390 | 336 |
|
2130 | 337 |
anItem isDirectory ifFalse:[^ #()]. |
1390 | 338 |
|
2248 | 339 |
contents := DirectoryContents directoryNamed:anItem fileName. |
2306 | 340 |
contents isNil ifTrue:[ ^ #() ]. |
1390 | 341 |
|
2248 | 342 |
list := OrderedCollection new. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
343 |
matchBlock := self matchBlockFor:anItem. |
2130 | 344 |
|
2297 | 345 |
contents itemsDo:[:anItem| |
346 |
(matchBlock isNil or:[matchBlock value:(anItem fileName) value:(anItem isDirectory)]) ifTrue:[ |
|
347 |
list add:(HierarchicalFileItem forContentsItem:anItem). |
|
1390 | 348 |
] |
349 |
]. |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
350 |
|
2130 | 351 |
list isEmpty ifTrue:[^ #()]. |
2293 | 352 |
list sort:self sortBlock. |
2248 | 353 |
^ list |
1390 | 354 |
! |
355 |
||
356 |
hasChildrenFor:anItem |
|
357 |
"returns true if the physical directory contains at least |
|
358 |
one visible item otherwise false. |
|
359 |
" |
|
360 |
|block| |
|
361 |
||
362 |
anItem isDirectory ifFalse:[ |
|
363 |
^ false |
|
364 |
]. |
|
365 |
||
366 |
(block := self matchBlockFor:anItem) isNil ifTrue:[ |
|
367 |
block := [:aFilename :isDirectory| true ] |
|
368 |
]. |
|
369 |
^ DirectoryContents directoryNamed:(anItem fileName) detect:block |
|
370 |
! |
|
371 |
||
372 |
matchBlockFor:anItem |
|
373 |
"get the matchBlock - if non-nil, it controls which files are |
|
374 |
visible within the physical directory |
|
375 |
" |
|
376 |
^ matchBlock |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
377 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
378 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
379 |
updateList |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
380 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
381 |
self monitoringCycle:true |
1390 | 382 |
! ! |
383 |
||
1581 | 384 |
!HierarchicalFileList methodsFor:'searching'! |
385 |
||
2272 | 386 |
findLastForFile:aPathOrFile |
387 |
"find last item which matches the path or file |
|
388 |
returns the item or nil if not contained in self |
|
1581 | 389 |
" |
2272 | 390 |
|file searchItem rootDir rootComponents searchComponents| |
1581 | 391 |
|
2272 | 392 |
(aPathOrFile isNil or:[root isNil]) ifTrue:[ |
1582 | 393 |
^ nil |
1581 | 394 |
]. |
395 |
||
2272 | 396 |
file := aPathOrFile asFilename. |
397 |
file exists ifFalse:[ ^ nil ]. |
|
1581 | 398 |
|
2272 | 399 |
rootDir := root fileName asAbsoluteFilename. |
2290
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
400 |
"/ file := file asAbsoluteFilename. |
2272 | 401 |
|
1581 | 402 |
|
2290
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
403 |
"/ (file pathName startsWith:(rootDir pathName)) ifFalse:[ |
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
404 |
(file asString startsWith:(rootDir pathName)) ifFalse:[ |
2272 | 405 |
"not included" |
406 |
^ nil |
|
1581 | 407 |
]. |
2272 | 408 |
rootComponents := rootDir components. |
2299 | 409 |
searchComponents := file asCanonicalizedFilename components. |
2272 | 410 |
searchItem := root. |
1581 | 411 |
|
2272 | 412 |
searchComponents from:(rootComponents size + 1) do:[:aName| |child| |
413 |
child := searchItem detect:[:el| el baseName = aName ] ifNone:nil. |
|
414 |
||
415 |
child isNil ifTrue:[ ^ searchItem ]. |
|
416 |
searchItem := child. |
|
1581 | 417 |
]. |
2272 | 418 |
^ searchItem |
1581 | 419 |
! ! |
420 |
||
2259 | 421 |
!HierarchicalFileList methodsFor:'update'! |
422 |
||
423 |
startIndicatorValidationFor:anItem |
|
424 |
"an item will be registered for an indication update |
|
425 |
" |
|
426 |
|prio| |
|
427 |
||
428 |
self criticalDo:[ |
|
429 |
indicatorList size == 0 ifTrue:[ |
|
430 |
indicatorList := OrderedCollection new. |
|
431 |
] ifFalse:[ |
|
432 |
indicatorList removeIdentical:anItem ifAbsent:nil. |
|
433 |
]. |
|
434 |
"/ indicatorList addFirst:anItem. |
|
435 |
indicatorList add:anItem. |
|
436 |
||
2306 | 437 |
indicatorTask isNil ifTrue:[ |
2259 | 438 |
prio := Processor activePriority. |
439 |
indicatorTask := [ self updateIndicatorCycle. ] forkAt:(prio - 1). |
|
440 |
indicatorTask priorityRange:(prio-1 to:prio). |
|
441 |
] |
|
442 |
]. |
|
443 |
! |
|
444 |
||
445 |
stopIndicatorValidationFor:anItem |
|
446 |
"stop the indicator validation for an item |
|
447 |
" |
|
448 |
self criticalDo:[ |
|
2306 | 449 |
indicatorList notNil ifTrue:[ |
2259 | 450 |
indicatorList removeIdentical:anItem ifAbsent:nil. |
451 |
anItem resetFetchIndicator. |
|
452 |
] |
|
453 |
]. |
|
454 |
! |
|
455 |
||
456 |
updateIndicatorCycle |
|
457 |
"run fetching indicator task cycle. |
|
458 |
This is done in the background to avoid long startup |
|
459 |
delays, in case the indicator information takes long to |
|
460 |
gather (i.e. when reading directories) |
|
461 |
" |
|
462 |
|repeat task item| |
|
463 |
||
464 |
repeat := true. |
|
465 |
task := indicatorTask. |
|
466 |
||
467 |
[ [ task notNil ] whileTrue:[ |
|
468 |
self criticalDo:[ |
|
469 |
( dependents size ~~ 0 "/ no dependencies (stop task) |
|
470 |
and:[indicatorList size ~~ 0] "/ nothing to do |
|
471 |
) ifTrue:[ |
|
472 |
item := indicatorList removeFirst. |
|
473 |
||
474 |
(self includesIdentical:item) ifFalse:[ |
|
2475 | 475 |
"/ item is no longer visible |
2259 | 476 |
item resetFetchIndicator. |
477 |
item := nil |
|
478 |
] |
|
479 |
] ifFalse:[ |
|
480 |
item := indicatorTask := task := nil |
|
481 |
] |
|
482 |
]. |
|
2306 | 483 |
item notNil ifTrue:[ |
2259 | 484 |
item fetchIndicator. |
485 |
Processor yield. |
|
486 |
]. |
|
487 |
] |
|
488 |
] valueNowOrOnUnwindDo:[ |
|
2306 | 489 |
task notNil ifTrue:[ |
2259 | 490 |
"/ oops, process terminated |
491 |
self criticalDo:[ |
|
492 |
"/ test whether a new task already started |
|
493 |
indicatorTask == task ifTrue:[ |
|
494 |
indicatorTask := nil |
|
495 |
] |
|
496 |
] |
|
497 |
] |
|
498 |
]. |
|
499 |
! ! |
|
500 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
501 |
!HierarchicalFileList::HierarchicalFileItem class methodsFor:'instance creation'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
502 |
|
2297 | 503 |
fileName:aFileName |
504 |
^ self forContentsItem:(DirectoryContents contentsItemForFileName:aFileName) |
|
505 |
! |
|
506 |
||
2299 | 507 |
forContentsItem:aContentsItem |
2294 | 508 |
|item cls| |
509 |
||
2299 | 510 |
cls := HierarchicalFileList::File. |
511 |
||
512 |
aContentsItem notNil ifTrue:[ |
|
513 |
aContentsItem isRemoteDirectory ifTrue:[ |
|
514 |
cls := HierarchicalFileList::RemoteDirectory |
|
2294 | 515 |
] ifFalse:[ |
2299 | 516 |
aContentsItem isDirectory ifTrue:[ |
517 |
cls := HierarchicalFileList::Directory |
|
518 |
] |
|
519 |
]. |
|
2294 | 520 |
]. |
521 |
item := cls basicNew initialize. |
|
2299 | 522 |
item contentsItem:aContentsItem. |
2297 | 523 |
^ item |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
524 |
! |
1390 | 525 |
|
2294 | 526 |
new |
527 |
self error. |
|
1390 | 528 |
! ! |
529 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
530 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'accessing'! |
1390 | 531 |
|
532 |
baseName |
|
533 |
"returns the baseName |
|
534 |
" |
|
2297 | 535 |
^ contentsItem fileName baseName. |
536 |
! |
|
537 |
||
538 |
contentsItem:aContentsItem |
|
539 |
contentsItem := aContentsItem |
|
2293 | 540 |
! |
541 |
||
1390 | 542 |
fileName |
543 |
"returns the fileName |
|
544 |
" |
|
2297 | 545 |
^ contentsItem fileName |
1390 | 546 |
! |
547 |
||
2294 | 548 |
fileName:aFilename |
2297 | 549 |
self halt. |
550 |
contentsItem := DirectoryContents contentsItemForFileName:aFilename |
|
551 |
||
552 |
"/ fileName = aFilename ifFalse:[ |
|
553 |
"/ fileName := aFilename. |
|
554 |
"/ self changed:#label |
|
555 |
"/ ]. |
|
1390 | 556 |
! |
557 |
||
2293 | 558 |
fileSize |
559 |
"returns the fileSize |
|
560 |
" |
|
2297 | 561 |
|fileInfo| |
562 |
||
563 |
fileInfo := contentsItem info. |
|
2293 | 564 |
fileInfo isNil ifTrue:[^ nil]. |
2297 | 565 |
^ fileInfo fileSize |
2293 | 566 |
! |
2267 | 567 |
|
2293 | 568 |
group |
569 |
"returns the printable group |
|
570 |
" |
|
2297 | 571 |
|fileInfo gid group| |
2294 | 572 |
|
2297 | 573 |
fileInfo := contentsItem info. |
2294 | 574 |
fileInfo notNil ifTrue:[ |
575 |
gid := fileInfo gid. |
|
2293 | 576 |
|
2294 | 577 |
gid notNil ifTrue:[ |
578 |
(LastGIDToGroupNameMapping notNil and:[gid == LastGIDToGroupNameMapping key]) ifTrue:[ |
|
579 |
^ LastGIDToGroupNameMapping value |
|
580 |
]. |
|
2293 | 581 |
group := OperatingSystem getGroupNameFromID:gid. |
582 |
LastGIDToGroupNameMapping := gid -> group. |
|
2294 | 583 |
^ group |
2293 | 584 |
] |
2267 | 585 |
]. |
2294 | 586 |
^ '???' |
2267 | 587 |
! |
588 |
||
1390 | 589 |
icon |
590 |
"returns the icon key |
|
591 |
" |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
592 |
icon isNil ifTrue:[ |
2387 | 593 |
self isRemoteDirectory ifTrue:[ |
594 |
icon := FileBrowser iconForKeyMatching:#directoryNetwork |
|
595 |
] ifFalse:[ |
|
596 |
icon := FileBrowser iconForFile:(self fileName). |
|
597 |
] |
|
1390 | 598 |
]. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
599 |
^ icon. |
1390 | 600 |
! |
601 |
||
602 |
label |
|
603 |
"returns the printable name, the baseName |
|
604 |
" |
|
2297 | 605 |
^ contentsItem fileName baseName |
1390 | 606 |
! |
607 |
||
2293 | 608 |
modificationTime |
609 |
"returns the absolute time of modification |
|
610 |
" |
|
2297 | 611 |
|
612 |
|fileInfo| |
|
613 |
||
614 |
fileInfo := contentsItem info. |
|
2293 | 615 |
fileInfo isNil ifTrue:[^ nil]. |
2297 | 616 |
^ fileInfo modificationTime |
2293 | 617 |
! |
618 |
||
619 |
owner |
|
620 |
"returns the printable owner |
|
621 |
" |
|
2297 | 622 |
|fileInfo uid owner| |
2294 | 623 |
|
2297 | 624 |
fileInfo := contentsItem info. |
2294 | 625 |
fileInfo notNil ifTrue:[ |
626 |
uid := fileInfo uid. |
|
2293 | 627 |
|
2294 | 628 |
uid notNil ifTrue:[ |
629 |
(LastUIDToUserNameMapping notNil and:[uid == LastUIDToUserNameMapping key]) ifTrue:[ |
|
630 |
^ LastUIDToUserNameMapping value |
|
631 |
]. |
|
2293 | 632 |
owner := OperatingSystem getUserNameFromID:uid. |
633 |
LastUIDToUserNameMapping := uid -> owner. |
|
2294 | 634 |
^ owner |
2293 | 635 |
] |
636 |
]. |
|
2294 | 637 |
|
638 |
^ '???' |
|
2293 | 639 |
! |
640 |
||
1390 | 641 |
pathName |
642 |
"returns the pathName |
|
643 |
" |
|
2297 | 644 |
^ contentsItem fileName pathName |
2267 | 645 |
! |
646 |
||
2293 | 647 |
permissions |
648 |
"returns the permissions as printable string |
|
649 |
" |
|
2297 | 650 |
|fileInfo mode perms| |
2267 | 651 |
|
2297 | 652 |
fileInfo := contentsItem info. |
2294 | 653 |
fileInfo notNil ifTrue:[ |
654 |
mode := fileInfo mode. |
|
655 |
||
656 |
mode notNil ifTrue:[ |
|
657 |
perms := String new:9 withAll:$-. |
|
2293 | 658 |
|
2294 | 659 |
1 to:9 by:3 do:[:i| |
660 |
(mode bitAt:i ) == 1 ifTrue:[perms at:10 - i put:$x]. |
|
661 |
(mode bitAt:i + 1) == 1 ifTrue:[perms at:9 - i put:$w]. |
|
662 |
(mode bitAt:i + 2) == 1 ifTrue:[perms at:8 - i put:$r]. |
|
663 |
]. |
|
664 |
^ perms |
|
665 |
] |
|
2293 | 666 |
]. |
2294 | 667 |
^ '???' |
2293 | 668 |
! |
669 |
||
670 |
suffix |
|
671 |
"returns the suffix of the file |
|
672 |
" |
|
2294 | 673 |
(OperatingSystem isUNIXlike and:[(self baseName at:1) == $.]) ifTrue:[ |
674 |
^ '' |
|
2267 | 675 |
]. |
2297 | 676 |
^ contentsItem fileName suffix |
2294 | 677 |
! ! |
678 |
||
679 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'change & update'! |
|
680 |
||
681 |
changed:aParameter |
|
682 |
"the item changed; raise change notification |
|
683 |
" |
|
684 |
aParameter == #icon ifTrue:[ icon := nil ]. |
|
685 |
super changed:aParameter. |
|
686 |
! ! |
|
687 |
||
688 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'instance creation'! |
|
689 |
||
690 |
fileName:aFilename fileInfo:aFileInfoOrNil |
|
2297 | 691 |
self halt. |
692 |
"/ fileName := aFilename. |
|
693 |
"/ fileInfo := aFileInfoOrNil. |
|
1390 | 694 |
! ! |
695 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
696 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'invalidate'! |
1390 | 697 |
|
698 |
invalidate |
|
699 |
"invalidate the contents |
|
700 |
" |
|
701 |
self invalidateRepairNow:false |
|
702 |
||
703 |
! |
|
704 |
||
705 |
invalidateRepairNow |
|
706 |
"invalidate the contents; repair now |
|
707 |
" |
|
708 |
self invalidateRepairNow:true |
|
709 |
||
710 |
! |
|
711 |
||
712 |
invalidateRepairNow:doRepair |
|
713 |
"invalidate the contents; dependent on the boolean |
|
714 |
do repair immediately |
|
715 |
" |
|
716 |
||
717 |
||
1866 | 718 |
! |
719 |
||
720 |
matchBlockChanged |
|
721 |
"called if the matchBlock changed |
|
722 |
" |
|
723 |
||
1390 | 724 |
! ! |
725 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
726 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'printing'! |
2127 | 727 |
|
728 |
printString |
|
729 |
||
730 |
^ super printString, ' for: ', self fileName asString |
|
731 |
! ! |
|
732 |
||
2270 | 733 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'protocol'! |
734 |
||
735 |
flushChildren |
|
736 |
"flush the children because node not visible .... |
|
737 |
canbe redefined by subclass |
|
738 |
" |
|
739 |
children := nil. |
|
740 |
! ! |
|
741 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
742 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'queries'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
743 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
744 |
isDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
745 |
^ false |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
746 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
747 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
748 |
isRemoteDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
749 |
^ false |
2267 | 750 |
! |
751 |
||
752 |
time |
|
753 |
||
754 |
^ self valueAt:#modified |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
755 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
756 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
757 |
!HierarchicalFileList::File methodsFor:'accessing'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
758 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
759 |
children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
760 |
"always returns an empty list |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
761 |
" |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
762 |
^ #() |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
763 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
764 |
|
1390 | 765 |
!HierarchicalFileList::File methodsFor:'queries'! |
766 |
||
767 |
hasChildren |
|
768 |
"always returns false |
|
769 |
" |
|
770 |
^ false |
|
771 |
! ! |
|
772 |
||
2259 | 773 |
!HierarchicalFileList::Directory class methodsFor:'documentation'! |
774 |
||
775 |
documentation |
|
776 |
" |
|
777 |
[Instance variables:] |
|
778 |
||
2267 | 779 |
fetchOperation <Symbol/Boolean> nil if children is nil, no information about has children |
780 |
#fetching registered in list to be updated for indication |
|
781 |
#hasChildren registered in list to be updated for indication |
|
782 |
#hasNoChildren has children but children list might be nil (remote) |
|
2259 | 783 |
" |
784 |
! ! |
|
785 |
||
2475 | 786 |
!HierarchicalFileList::Directory class methodsFor:'initialization'! |
787 |
||
788 |
initialize |
|
789 |
StateUnknown := nil. |
|
790 |
StateHasChildren := #hasChildren. |
|
791 |
StateHasNoChildren := #hasNoChildren. |
|
792 |
StateFetching := #fetching |
|
793 |
||
794 |
" |
|
795 |
self initialize |
|
796 |
" |
|
797 |
! ! |
|
798 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
799 |
!HierarchicalFileList::Directory methodsFor:'accessing'! |
1390 | 800 |
|
801 |
children |
|
802 |
"returns the list of children |
|
803 |
" |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
804 |
|model| |
1390 | 805 |
|
2306 | 806 |
children notNil ifTrue:[ ^ children ]. |
1390 | 807 |
|
2259 | 808 |
model := self model. |
2306 | 809 |
model isNil ifTrue:[ ^ nil ]. |
1390 | 810 |
|
2259 | 811 |
model criticalDo:[ |
2306 | 812 |
children isNil ifTrue:[ self readChildren ]. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
813 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
814 |
^ children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
815 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
816 |
|
2475 | 817 |
icon |
818 |
"returns the icon |
|
2270 | 819 |
" |
2475 | 820 |
|
821 |
|nameKey| |
|
2270 | 822 |
|
2387 | 823 |
isExpanded ifTrue:[ |
2475 | 824 |
(makeIconGray == true) ifTrue:[ |
825 |
nameKey := #directoryOpenGray |
|
826 |
] ifFalse:[ |
|
827 |
nameKey := #directoryOpen |
|
828 |
] |
|
829 |
] ifFalse:[ |
|
2428 | 830 |
makeIconGray == true ifTrue:[ |
2475 | 831 |
nameKey := #directoryGray |
832 |
] |
|
2387 | 833 |
]. |
2475 | 834 |
|
835 |
nameKey notNil ifTrue:[ |
|
836 |
^ FileBrowser iconForKeyMatching:nameKey |
|
2428 | 837 |
]. |
2475 | 838 |
|
2387 | 839 |
icon isNil ifTrue:[ |
840 |
^ super icon |
|
841 |
]. |
|
842 |
^ icon |
|
843 |
! |
|
844 |
||
2457 | 845 |
label |
846 |
"returns the printable name, the baseName |
|
847 |
" |
|
848 |
contentsItem fileName isRootDirectory ifTrue:[ |
|
849 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
850 |
^ contentsItem fileName pathName |
|
851 |
] |
|
852 |
]. |
|
853 |
^ contentsItem fileName baseName |
|
854 |
! |
|
855 |
||
2428 | 856 |
makeIconGray:something |
2475 | 857 |
"set/clear the flag which enforces the icon to be shown in grey" |
2428 | 858 |
|
859 |
makeIconGray := something. |
|
860 |
! |
|
861 |
||
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
862 |
modificationTime:something |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
863 |
"set the value of the instance variable 'modificationTime' (automatically generated)" |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
864 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
865 |
modificationTime := something. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
866 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
867 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
868 |
readChildren |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
869 |
"reads the list of children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
870 |
" |
2259 | 871 |
|model list hadChildren hasChildren| |
872 |
||
2475 | 873 |
self forgetAboutChildren. |
874 |
||
2259 | 875 |
model := self model. |
2306 | 876 |
model isNil ifTrue:[ |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
877 |
"/ must reread later |
2475 | 878 |
modificationTime := children := nil. |
879 |
^ nil |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
880 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
881 |
|
2259 | 882 |
hadChildren := children size ~~ 0. |
883 |
||
884 |
"/ set to suppress reading of children |
|
1867 | 885 |
children := #(). |
2297 | 886 |
modificationTime := self fileName modificationTime. |
2259 | 887 |
model stopIndicatorValidationFor:self. |
888 |
||
1867 | 889 |
list := model childrenFor:self. |
890 |
||
891 |
list size ~~ 0 ifTrue:[ |
|
892 |
list do:[:aChild| aChild parent:self]. |
|
893 |
children := list. |
|
1390 | 894 |
]. |
2259 | 895 |
hasChildren := children size ~~ 0. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
896 |
|
2259 | 897 |
hasChildren ~~ hadChildren ifTrue:[ |
898 |
self changed:#redraw |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
899 |
]. |
1390 | 900 |
^ children |
901 |
! ! |
|
902 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
903 |
!HierarchicalFileList::Directory methodsFor:'accessing-hierarchy'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
904 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
905 |
collapse |
2270 | 906 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
907 |
super collapse. |
2270 | 908 |
|
909 |
children notNil ifTrue:[ |
|
910 |
children do:[:el| el flushChildren ] |
|
911 |
]. |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
912 |
! |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
913 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
914 |
expand |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
915 |
"expand children; must redefine to raise a notification |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
916 |
if children are not yet initialized and after initialization empty. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
917 |
" |
2270 | 918 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
919 |
super expand. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
920 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
921 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
922 |
recursiveCollapse |
2270 | 923 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
924 |
super recursiveCollapse. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
925 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
926 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
927 |
recursiveExpand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
928 |
"redefined to expand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
929 |
" |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
930 |
self expand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
931 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
932 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
933 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
934 |
|
2259 | 935 |
!HierarchicalFileList::Directory methodsFor:'fetching'! |
936 |
||
937 |
basicFetchIndicator |
|
2267 | 938 |
|hasChildren| |
939 |
||
2475 | 940 |
hasChildren := DirectoryContents directoryNamed:(self fileName) detect:(self model matchBlock). |
941 |
self knownToHaveChildren:hasChildren. |
|
942 |
children notNil ifTrue:[self halt]. |
|
943 |
||
2267 | 944 |
children isNil ifTrue:[ |
945 |
"setup modification time to suppress monitorCycle |
|
946 |
" |
|
2297 | 947 |
modificationTime := self fileName modificationTime. |
2267 | 948 |
]. |
2259 | 949 |
! |
950 |
||
951 |
fetchIndicator |
|
2475 | 952 |
"fetch the indicator value which indicates whether children exist or not. |
953 |
Called by the lists update process. |
|
2259 | 954 |
" |
2306 | 955 |
children notNil ifTrue:[ |
2259 | 956 |
"/ children already read |
2475 | 957 |
self forgetAboutChildren. |
958 |
^ self |
|
2259 | 959 |
]. |
960 |
||
2475 | 961 |
self isFetchingChildrenInfo ifFalse:[ |
962 |
"/ children will be updated in a second.... |
|
2259 | 963 |
^ self |
964 |
]. |
|
965 |
"/ suppress restart of fetchIndicator |
|
966 |
||
967 |
self basicFetchIndicator. |
|
968 |
||
2475 | 969 |
children notNil ifTrue:[self halt]. |
970 |
||
2259 | 971 |
children notNil ifTrue:[ |
2475 | 972 |
self forgetAboutChildren. |
2259 | 973 |
children notEmpty ifTrue:[ self changed:#redraw ]. |
974 |
] ifFalse:[ |
|
975 |
"/ is a remote or very slow file system |
|
2475 | 976 |
self isKnownToHaveChildren ifTrue:[ |
2267 | 977 |
self changed:#redraw |
978 |
]. |
|
2259 | 979 |
]. |
980 |
! |
|
981 |
||
982 |
resetFetchIndicator |
|
983 |
"update indication cycle has deregistered the item |
|
984 |
" |
|
2475 | 985 |
|
986 |
self forgetAboutChildren. |
|
987 |
! ! |
|
988 |
||
989 |
!HierarchicalFileList::Directory methodsFor:'private'! |
|
990 |
||
991 |
flushChildren |
|
992 |
"flush the children because the node is going to be invisible. |
|
993 |
" |
|
994 |
children notNil ifTrue:[ |
|
995 |
self knownToHaveChildren:(children size ~~ 0). |
|
996 |
children := nil. |
|
997 |
]. |
|
998 |
! ! |
|
999 |
||
1000 |
!HierarchicalFileList::Directory methodsFor:'private - quick children info'! |
|
1001 |
||
1002 |
forgetAboutChildren |
|
1003 |
quickChildrenInfo := StateUnknown |
|
1004 |
! |
|
1005 |
||
1006 |
isChildrenInfoValid |
|
1007 |
^ quickChildrenInfo ~~ StateUnknown and:[quickChildrenInfo ~~ StateFetching] |
|
1008 |
! |
|
1009 |
||
1010 |
isFetchingChildrenInfo |
|
1011 |
^ quickChildrenInfo == StateFetching |
|
1012 |
! |
|
1013 |
||
1014 |
isKnownToHaveChildren |
|
1015 |
^ quickChildrenInfo == StateHasChildren |
|
1016 |
! |
|
1017 |
||
1018 |
isKnownToHaveNoChildren |
|
1019 |
^ quickChildrenInfo == StateHasNoChildren |
|
1020 |
! |
|
1021 |
||
1022 |
knownToHaveChildren:aBoolean |
|
1023 |
aBoolean ifTrue:[ |
|
1024 |
quickChildrenInfo := StateHasChildren. |
|
1025 |
] ifFalse:[ |
|
1026 |
quickChildrenInfo := StateHasNoChildren. |
|
1027 |
]. |
|
1028 |
! |
|
1029 |
||
1030 |
setFetchingChildrenInfo |
|
1031 |
quickChildrenInfo := StateFetching |
|
2259 | 1032 |
! ! |
1033 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1034 |
!HierarchicalFileList::Directory methodsFor:'queries'! |
1390 | 1035 |
|
2475 | 1036 |
canExpand |
1037 |
super canExpand ifTrue:[^ true]. |
|
1038 |
"/ in case we are fetching the subdirectory |
|
1039 |
self isFetchingChildrenInfo ifTrue:[ |
|
1040 |
self halt. |
|
1041 |
]. |
|
1042 |
||
1043 |
^ false |
|
1044 |
! |
|
1045 |
||
1390 | 1046 |
hasChildren |
2475 | 1047 |
"returns true if children exist |
1390 | 1048 |
" |
2259 | 1049 |
|model| |
1050 |
||
1051 |
children notNil ifTrue:[ |
|
2475 | 1052 |
self forgetAboutChildren. |
1053 |
^ children size ~~ 0 |
|
2259 | 1054 |
]. |
1055 |
||
2475 | 1056 |
self isFetchingChildrenInfo ifTrue:[ |
1057 |
^ false. |
|
1058 |
]. |
|
1059 |
self isChildrenInfoValid ifTrue:[ |
|
1060 |
^ self isKnownToHaveChildren |
|
2259 | 1061 |
]. |
1062 |
||
1063 |
model := self model. |
|
1064 |
||
1065 |
model notNil ifTrue:[ |
|
2475 | 1066 |
self setFetchingChildrenInfo. |
2259 | 1067 |
model startIndicatorValidationFor:self. |
1068 |
] ifFalse:[ |
|
2267 | 1069 |
self error:'should not happen' mayProceed:true. |
2475 | 1070 |
self forgetAboutChildren |
2259 | 1071 |
]. |
2475 | 1072 |
children size ~~ 0 ifTrue:[self halt. ^ true]. |
1073 |
^ false |
|
1390 | 1074 |
! |
1075 |
||
1076 |
isDirectory |
|
1077 |
"always returns true |
|
1078 |
" |
|
1079 |
^ true |
|
1080 |
||
1081 |
||
1082 |
! ! |
|
1083 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1084 |
!HierarchicalFileList::Directory methodsFor:'validation'! |
1390 | 1085 |
|
2267 | 1086 |
invalidateRepairNow:doRepair |
1087 |
"invalidate contents |
|
1088 |
" |
|
2475 | 1089 |
modificationTime := nil. |
1090 |
self forgetAboutChildren |
|
2267 | 1091 |
|
1092 |
isExpanded ifFalse:[ |
|
1093 |
children := nil |
|
1094 |
] ifTrue:[ |
|
1095 |
doRepair ifTrue:[ |
|
1096 |
self monitoringCycle |
|
1097 |
] ifFalse:[ |
|
1098 |
children size == 0 ifTrue:[ |
|
1099 |
"/ expanded but no children added, thus can reset the children |
|
1100 |
children := nil |
|
1101 |
] |
|
1102 |
] |
|
1103 |
]. |
|
1104 |
! |
|
1105 |
||
1106 |
matchBlockChanged |
|
1107 |
"called if the matchBlock changed |
|
1108 |
" |
|
1109 |
modificationTime := nil. |
|
1110 |
||
1111 |
isExpanded ifFalse:[ |
|
2475 | 1112 |
children := nil. |
1113 |
self forgetAboutChildren |
|
2267 | 1114 |
] ifTrue:[ |
1115 |
self monitoringCycle. |
|
1116 |
||
1117 |
children size ~~ 0 ifTrue:[ |
|
1118 |
children do:[:aChild| aChild matchBlockChanged ] |
|
1119 |
] |
|
1120 |
]. |
|
1121 |
! |
|
1122 |
||
1123 |
monitoringCycle |
|
1124 |
"run monitoring cycle |
|
1125 |
!!!!!!!! called by the HierarchicalList only !!!!!!!! |
|
1126 |
" |
|
1127 |
|unusedDict addedItems mergedList size modifyTime model timeChanged| |
|
1128 |
||
2297 | 1129 |
modifyTime := self fileName modificationTime. |
2306 | 1130 |
modifyTime isNil ifTrue:[^ self]. |
2267 | 1131 |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1132 |
timeChanged := (modificationTime isNil or:[modifyTime ~= modificationTime]). |
2267 | 1133 |
modificationTime := modifyTime. |
1134 |
||
2306 | 1135 |
children notNil ifTrue:[ |
2267 | 1136 |
timeChanged ifFalse:[ |
1137 |
^ self |
|
1138 |
]. |
|
1139 |
]. |
|
2475 | 1140 |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1141 |
DirectoryContents flushCachedDirectoryFor:(self fileName). |
2267 | 1142 |
isExpanded ifFalse:[ |
1143 |
timeChanged ifTrue:[ |
|
2475 | 1144 |
children := nil. |
1145 |
self forgetAboutChildren. |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1146 |
self changed:#redraw. |
2267 | 1147 |
]. |
1148 |
^ self |
|
1149 |
]. |
|
2475 | 1150 |
|
2306 | 1151 |
children isNil ifTrue:[ children := #() ]. "/ disable update during merge |
2267 | 1152 |
|
2475 | 1153 |
self forgetAboutChildren. |
1154 |
model := self model. |
|
1155 |
mergedList := model childrenFor:self. |
|
2267 | 1156 |
|
1157 |
mergedList size == 0 ifTrue:[ |
|
1158 |
self removeAll. |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1159 |
^ self |
2267 | 1160 |
]. |
1161 |
||
1162 |
size := children size. |
|
1163 |
size == 0 ifTrue:[ |
|
1164 |
self addAll:mergedList. |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1165 |
^ self |
2267 | 1166 |
]. |
1167 |
||
1168 |
model criticalDo:[ |
|
1169 |
addedItems := OrderedCollection new:128. |
|
1170 |
unusedDict := Dictionary new:size. |
|
1171 |
||
1172 |
children do:[:el| unusedDict at:(el fileName) put:el ]. |
|
1173 |
||
1174 |
mergedList keysAndValuesDo:[:anIndex :anItem| |item| |
|
1175 |
item := unusedDict removeKey:(anItem fileName) ifAbsent:nil. |
|
1176 |
||
1177 |
item notNil ifTrue:[ |
|
1178 |
mergedList at:anIndex put:item |
|
1179 |
] ifFalse:[ |
|
1180 |
addedItems add:anItem. |
|
1181 |
anItem parent:self. |
|
1182 |
]. |
|
1183 |
]. |
|
1184 |
"/ 12 is hardcoded !!!!!!!! |
|
1185 |
||
1186 |
(unusedDict size + addedItems size) > 12 ifTrue:[ |
|
1187 |
"/ generate two nofifications: collapse and expand |
|
1188 |
self collapse. |
|
1189 |
children := mergedList. |
|
1190 |
self expand. |
|
1191 |
] ifFalse:[ |
|
1192 |
unusedDict do:[:el| self remove:el ]. |
|
1193 |
||
1194 |
addedItems notEmpty ifTrue:[ |
|
1195 |
self addAll:addedItems |
|
1196 |
]. |
|
1197 |
"/ children order changed test |
|
1198 |
children := mergedList. |
|
1199 |
self childrenOrderChanged. |
|
1200 |
]. |
|
1201 |
]. |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1202 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1203 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1204 |
updateList |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1205 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1206 |
modificationTime := nil. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1207 |
self monitoringCycle. |
1390 | 1208 |
! ! |
1209 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1210 |
!HierarchicalFileList::RemoteDirectory methodsFor:'queries'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1211 |
|
2267 | 1212 |
hasChildren |
1213 |
"returns true if children exists |
|
1214 |
" |
|
1215 |
children notNil ifTrue:[ |
|
2475 | 1216 |
self forgetAboutChildren. |
2267 | 1217 |
^ children size ~~ 0 |
1218 |
]. |
|
2475 | 1219 |
|
1220 |
"/ assume that there are children; |
|
1221 |
"/ this might be wrong and clicking on the expand-icon |
|
1222 |
"/ will then not perform an expand, but remove the can-expand indicator. |
|
1223 |
self knownToHaveChildren:true. |
|
1224 |
^ true |
|
2267 | 1225 |
! |
1226 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1227 |
isRemoteDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1228 |
^ true |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1229 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1230 |
|
1390 | 1231 |
!HierarchicalFileList class methodsFor:'documentation'! |
1232 |
||
1233 |
version |
|
2475 | 1234 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.44 2003-04-08 13:38:08 cg Exp $' |
1390 | 1235 |
! ! |
2475 | 1236 |
|
1237 |
HierarchicalFileList::Directory initialize! |