author | penk |
Wed, 15 Jan 2003 11:15:57 +0100 | |
changeset 2428 | 6911eddb2c1d |
parent 2425 | 7421b8bb7d31 |
child 2429 | b789b36dc069 |
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 |
2428 | 38 |
instanceVariableNames:'modificationTime fetchOperation makeIconGray' |
2138 | 39 |
classVariableNames:'' |
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 |
]. |
|
225 |
doExpand ifTrue:[ newRoot expand ]. |
|
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 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
308 |
item := root. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
309 |
index := showRoot ifTrue:[1] ifFalse:[0]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
310 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
311 |
item isNil ifTrue:[ |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
312 |
item := self at:index ifAbsent:nil. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
313 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
314 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
315 |
[item notNil] whileTrue:[ |
2380 | 316 |
dependents size == 0 ifTrue:[ ^ self ]. |
317 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
318 |
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
|
319 |
update ifTrue:[ |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
320 |
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
|
321 |
]. |
2267 | 322 |
item monitoringCycle |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
323 |
]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
324 |
Processor yield. |
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 |
item := self at:index ifAbsent:nil. |
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 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
329 |
|
1390 | 330 |
!HierarchicalFileList methodsFor:'protocol'! |
331 |
||
332 |
childrenFor:anItem |
|
333 |
"returns all visible children derived from the physical |
|
334 |
directory contents. |
|
335 |
" |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
336 |
|contents list matchBlock| |
1390 | 337 |
|
2130 | 338 |
anItem isDirectory ifFalse:[^ #()]. |
1390 | 339 |
|
2248 | 340 |
contents := DirectoryContents directoryNamed:anItem fileName. |
2306 | 341 |
contents isNil ifTrue:[ ^ #() ]. |
1390 | 342 |
|
2248 | 343 |
list := OrderedCollection new. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
344 |
matchBlock := self matchBlockFor:anItem. |
2130 | 345 |
|
2297 | 346 |
contents itemsDo:[:anItem| |
347 |
(matchBlock isNil or:[matchBlock value:(anItem fileName) value:(anItem isDirectory)]) ifTrue:[ |
|
348 |
list add:(HierarchicalFileItem forContentsItem:anItem). |
|
1390 | 349 |
] |
350 |
]. |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
351 |
|
2130 | 352 |
list isEmpty ifTrue:[^ #()]. |
2293 | 353 |
list sort:self sortBlock. |
2248 | 354 |
^ list |
1390 | 355 |
! |
356 |
||
357 |
hasChildrenFor:anItem |
|
358 |
"returns true if the physical directory contains at least |
|
359 |
one visible item otherwise false. |
|
360 |
" |
|
361 |
|block| |
|
362 |
||
363 |
anItem isDirectory ifFalse:[ |
|
364 |
^ false |
|
365 |
]. |
|
366 |
||
367 |
(block := self matchBlockFor:anItem) isNil ifTrue:[ |
|
368 |
block := [:aFilename :isDirectory| true ] |
|
369 |
]. |
|
370 |
^ DirectoryContents directoryNamed:(anItem fileName) detect:block |
|
371 |
! |
|
372 |
||
373 |
matchBlockFor:anItem |
|
374 |
"get the matchBlock - if non-nil, it controls which files are |
|
375 |
visible within the physical directory |
|
376 |
" |
|
377 |
^ matchBlock |
|
2425
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 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
380 |
updateList |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
381 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
382 |
self monitoringCycle:true |
1390 | 383 |
! ! |
384 |
||
1581 | 385 |
!HierarchicalFileList methodsFor:'searching'! |
386 |
||
2272 | 387 |
findLastForFile:aPathOrFile |
388 |
"find last item which matches the path or file |
|
389 |
returns the item or nil if not contained in self |
|
1581 | 390 |
" |
2272 | 391 |
|file searchItem rootDir rootComponents searchComponents| |
1581 | 392 |
|
2272 | 393 |
(aPathOrFile isNil or:[root isNil]) ifTrue:[ |
1582 | 394 |
^ nil |
1581 | 395 |
]. |
396 |
||
2272 | 397 |
file := aPathOrFile asFilename. |
398 |
file exists ifFalse:[ ^ nil ]. |
|
1581 | 399 |
|
2272 | 400 |
rootDir := root fileName asAbsoluteFilename. |
2290
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
401 |
"/ file := file asAbsoluteFilename. |
2272 | 402 |
|
1581 | 403 |
|
2290
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
404 |
"/ (file pathName startsWith:(rootDir pathName)) ifFalse:[ |
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
405 |
(file asString startsWith:(rootDir pathName)) ifFalse:[ |
2272 | 406 |
"not included" |
407 |
^ nil |
|
1581 | 408 |
]. |
2272 | 409 |
rootComponents := rootDir components. |
2299 | 410 |
searchComponents := file asCanonicalizedFilename components. |
2272 | 411 |
searchItem := root. |
1581 | 412 |
|
2272 | 413 |
searchComponents from:(rootComponents size + 1) do:[:aName| |child| |
414 |
child := searchItem detect:[:el| el baseName = aName ] ifNone:nil. |
|
415 |
||
416 |
child isNil ifTrue:[ ^ searchItem ]. |
|
417 |
searchItem := child. |
|
1581 | 418 |
]. |
2272 | 419 |
^ searchItem |
1581 | 420 |
! ! |
421 |
||
2259 | 422 |
!HierarchicalFileList methodsFor:'update'! |
423 |
||
424 |
startIndicatorValidationFor:anItem |
|
425 |
"an item will be registered for an indication update |
|
426 |
" |
|
427 |
|prio| |
|
428 |
||
429 |
self criticalDo:[ |
|
430 |
indicatorList size == 0 ifTrue:[ |
|
431 |
indicatorList := OrderedCollection new. |
|
432 |
] ifFalse:[ |
|
433 |
indicatorList removeIdentical:anItem ifAbsent:nil. |
|
434 |
]. |
|
435 |
"/ indicatorList addFirst:anItem. |
|
436 |
indicatorList add:anItem. |
|
437 |
||
2306 | 438 |
indicatorTask isNil ifTrue:[ |
2259 | 439 |
prio := Processor activePriority. |
440 |
indicatorTask := [ self updateIndicatorCycle. ] forkAt:(prio - 1). |
|
441 |
indicatorTask priorityRange:(prio-1 to:prio). |
|
442 |
] |
|
443 |
]. |
|
444 |
! |
|
445 |
||
446 |
stopIndicatorValidationFor:anItem |
|
447 |
"stop the indicator validation for an item |
|
448 |
" |
|
449 |
self criticalDo:[ |
|
2306 | 450 |
indicatorList notNil ifTrue:[ |
2259 | 451 |
indicatorList removeIdentical:anItem ifAbsent:nil. |
452 |
anItem resetFetchIndicator. |
|
453 |
] |
|
454 |
]. |
|
455 |
! |
|
456 |
||
457 |
updateIndicatorCycle |
|
458 |
"run fetching indicator task cycle. |
|
459 |
This is done in the background to avoid long startup |
|
460 |
delays, in case the indicator information takes long to |
|
461 |
gather (i.e. when reading directories) |
|
462 |
" |
|
463 |
|repeat task item| |
|
464 |
||
465 |
repeat := true. |
|
466 |
task := indicatorTask. |
|
467 |
||
468 |
[ [ task notNil ] whileTrue:[ |
|
469 |
self criticalDo:[ |
|
470 |
( dependents size ~~ 0 "/ no dependencies (stop task) |
|
471 |
and:[indicatorList size ~~ 0] "/ nothing to do |
|
472 |
) ifTrue:[ |
|
473 |
item := indicatorList removeFirst. |
|
474 |
||
475 |
(self includesIdentical:item) ifFalse:[ |
|
476 |
"/ no longer visible |
|
477 |
item resetFetchIndicator. |
|
478 |
item := nil |
|
479 |
] |
|
480 |
] ifFalse:[ |
|
481 |
item := indicatorTask := task := nil |
|
482 |
] |
|
483 |
]. |
|
2306 | 484 |
item notNil ifTrue:[ |
2259 | 485 |
item fetchIndicator. |
486 |
Processor yield. |
|
487 |
]. |
|
488 |
] |
|
489 |
] valueNowOrOnUnwindDo:[ |
|
2306 | 490 |
task notNil ifTrue:[ |
2259 | 491 |
"/ oops, process terminated |
492 |
self criticalDo:[ |
|
493 |
"/ test whether a new task already started |
|
494 |
indicatorTask == task ifTrue:[ |
|
495 |
indicatorTask := nil |
|
496 |
] |
|
497 |
] |
|
498 |
] |
|
499 |
]. |
|
500 |
! ! |
|
501 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
502 |
!HierarchicalFileList::HierarchicalFileItem class methodsFor:'instance creation'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
503 |
|
2297 | 504 |
fileName:aFileName |
505 |
^ self forContentsItem:(DirectoryContents contentsItemForFileName:aFileName) |
|
506 |
! |
|
507 |
||
2299 | 508 |
forContentsItem:aContentsItem |
2294 | 509 |
|item cls| |
510 |
||
2299 | 511 |
cls := HierarchicalFileList::File. |
512 |
||
513 |
aContentsItem notNil ifTrue:[ |
|
514 |
aContentsItem isRemoteDirectory ifTrue:[ |
|
515 |
cls := HierarchicalFileList::RemoteDirectory |
|
2294 | 516 |
] ifFalse:[ |
2299 | 517 |
aContentsItem isDirectory ifTrue:[ |
518 |
cls := HierarchicalFileList::Directory |
|
519 |
] |
|
520 |
]. |
|
2294 | 521 |
]. |
522 |
item := cls basicNew initialize. |
|
2299 | 523 |
item contentsItem:aContentsItem. |
2297 | 524 |
^ item |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
525 |
! |
1390 | 526 |
|
2294 | 527 |
new |
528 |
self error. |
|
1390 | 529 |
! ! |
530 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
531 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'accessing'! |
1390 | 532 |
|
533 |
baseName |
|
534 |
"returns the baseName |
|
535 |
" |
|
2297 | 536 |
^ contentsItem fileName baseName. |
537 |
! |
|
538 |
||
539 |
contentsItem:aContentsItem |
|
540 |
contentsItem := aContentsItem |
|
2293 | 541 |
! |
542 |
||
1390 | 543 |
fileName |
544 |
"returns the fileName |
|
545 |
" |
|
2297 | 546 |
^ contentsItem fileName |
1390 | 547 |
! |
548 |
||
2294 | 549 |
fileName:aFilename |
2297 | 550 |
self halt. |
551 |
contentsItem := DirectoryContents contentsItemForFileName:aFilename |
|
552 |
||
553 |
"/ fileName = aFilename ifFalse:[ |
|
554 |
"/ fileName := aFilename. |
|
555 |
"/ self changed:#label |
|
556 |
"/ ]. |
|
1390 | 557 |
! |
558 |
||
2293 | 559 |
fileSize |
560 |
"returns the fileSize |
|
561 |
" |
|
2297 | 562 |
|fileInfo| |
563 |
||
564 |
fileInfo := contentsItem info. |
|
2293 | 565 |
fileInfo isNil ifTrue:[^ nil]. |
2297 | 566 |
^ fileInfo fileSize |
2293 | 567 |
! |
2267 | 568 |
|
2293 | 569 |
group |
570 |
"returns the printable group |
|
571 |
" |
|
2297 | 572 |
|fileInfo gid group| |
2294 | 573 |
|
2297 | 574 |
fileInfo := contentsItem info. |
2294 | 575 |
fileInfo notNil ifTrue:[ |
576 |
gid := fileInfo gid. |
|
2293 | 577 |
|
2294 | 578 |
gid notNil ifTrue:[ |
579 |
(LastGIDToGroupNameMapping notNil and:[gid == LastGIDToGroupNameMapping key]) ifTrue:[ |
|
580 |
^ LastGIDToGroupNameMapping value |
|
581 |
]. |
|
2293 | 582 |
group := OperatingSystem getGroupNameFromID:gid. |
583 |
LastGIDToGroupNameMapping := gid -> group. |
|
2294 | 584 |
^ group |
2293 | 585 |
] |
2267 | 586 |
]. |
2294 | 587 |
^ '???' |
2267 | 588 |
! |
589 |
||
1390 | 590 |
icon |
591 |
"returns the icon key |
|
592 |
" |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
593 |
icon isNil ifTrue:[ |
2387 | 594 |
self isRemoteDirectory ifTrue:[ |
595 |
icon := FileBrowser iconForKeyMatching:#directoryNetwork |
|
596 |
] ifFalse:[ |
|
597 |
icon := FileBrowser iconForFile:(self fileName). |
|
598 |
] |
|
1390 | 599 |
]. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
600 |
^ icon. |
1390 | 601 |
! |
602 |
||
603 |
label |
|
604 |
"returns the printable name, the baseName |
|
605 |
" |
|
2297 | 606 |
^ contentsItem fileName baseName |
1390 | 607 |
! |
608 |
||
2293 | 609 |
modificationTime |
610 |
"returns the absolute time of modification |
|
611 |
" |
|
2297 | 612 |
|
613 |
|fileInfo| |
|
614 |
||
615 |
fileInfo := contentsItem info. |
|
2293 | 616 |
fileInfo isNil ifTrue:[^ nil]. |
2297 | 617 |
^ fileInfo modificationTime |
2293 | 618 |
! |
619 |
||
620 |
owner |
|
621 |
"returns the printable owner |
|
622 |
" |
|
2297 | 623 |
|fileInfo uid owner| |
2294 | 624 |
|
2297 | 625 |
fileInfo := contentsItem info. |
2294 | 626 |
fileInfo notNil ifTrue:[ |
627 |
uid := fileInfo uid. |
|
2293 | 628 |
|
2294 | 629 |
uid notNil ifTrue:[ |
630 |
(LastUIDToUserNameMapping notNil and:[uid == LastUIDToUserNameMapping key]) ifTrue:[ |
|
631 |
^ LastUIDToUserNameMapping value |
|
632 |
]. |
|
2293 | 633 |
owner := OperatingSystem getUserNameFromID:uid. |
634 |
LastUIDToUserNameMapping := uid -> owner. |
|
2294 | 635 |
^ owner |
2293 | 636 |
] |
637 |
]. |
|
2294 | 638 |
|
639 |
^ '???' |
|
2293 | 640 |
! |
641 |
||
1390 | 642 |
pathName |
643 |
"returns the pathName |
|
644 |
" |
|
2297 | 645 |
^ contentsItem fileName pathName |
2267 | 646 |
! |
647 |
||
2293 | 648 |
permissions |
649 |
"returns the permissions as printable string |
|
650 |
" |
|
2297 | 651 |
|fileInfo mode perms| |
2267 | 652 |
|
2297 | 653 |
fileInfo := contentsItem info. |
2294 | 654 |
fileInfo notNil ifTrue:[ |
655 |
mode := fileInfo mode. |
|
656 |
||
657 |
mode notNil ifTrue:[ |
|
658 |
perms := String new:9 withAll:$-. |
|
2293 | 659 |
|
2294 | 660 |
1 to:9 by:3 do:[:i| |
661 |
(mode bitAt:i ) == 1 ifTrue:[perms at:10 - i put:$x]. |
|
662 |
(mode bitAt:i + 1) == 1 ifTrue:[perms at:9 - i put:$w]. |
|
663 |
(mode bitAt:i + 2) == 1 ifTrue:[perms at:8 - i put:$r]. |
|
664 |
]. |
|
665 |
^ perms |
|
666 |
] |
|
2293 | 667 |
]. |
2294 | 668 |
^ '???' |
2293 | 669 |
! |
670 |
||
671 |
suffix |
|
672 |
"returns the suffix of the file |
|
673 |
" |
|
2294 | 674 |
(OperatingSystem isUNIXlike and:[(self baseName at:1) == $.]) ifTrue:[ |
675 |
^ '' |
|
2267 | 676 |
]. |
2297 | 677 |
^ contentsItem fileName suffix |
2294 | 678 |
! ! |
679 |
||
680 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'change & update'! |
|
681 |
||
682 |
changed:aParameter |
|
683 |
"the item changed; raise change notification |
|
684 |
" |
|
685 |
aParameter == #icon ifTrue:[ icon := nil ]. |
|
686 |
super changed:aParameter. |
|
687 |
! ! |
|
688 |
||
689 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'instance creation'! |
|
690 |
||
691 |
fileName:aFilename fileInfo:aFileInfoOrNil |
|
2297 | 692 |
self halt. |
693 |
"/ fileName := aFilename. |
|
694 |
"/ fileInfo := aFileInfoOrNil. |
|
1390 | 695 |
! ! |
696 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
697 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'invalidate'! |
1390 | 698 |
|
699 |
invalidate |
|
700 |
"invalidate the contents |
|
701 |
" |
|
702 |
self invalidateRepairNow:false |
|
703 |
||
704 |
! |
|
705 |
||
706 |
invalidateRepairNow |
|
707 |
"invalidate the contents; repair now |
|
708 |
" |
|
709 |
self invalidateRepairNow:true |
|
710 |
||
711 |
! |
|
712 |
||
713 |
invalidateRepairNow:doRepair |
|
714 |
"invalidate the contents; dependent on the boolean |
|
715 |
do repair immediately |
|
716 |
" |
|
717 |
||
718 |
||
1866 | 719 |
! |
720 |
||
721 |
matchBlockChanged |
|
722 |
"called if the matchBlock changed |
|
723 |
" |
|
724 |
||
1390 | 725 |
! ! |
726 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
727 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'printing'! |
2127 | 728 |
|
729 |
printString |
|
730 |
||
731 |
^ super printString, ' for: ', self fileName asString |
|
732 |
! ! |
|
733 |
||
2270 | 734 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'protocol'! |
735 |
||
736 |
flushChildren |
|
737 |
"flush the children because node not visible .... |
|
738 |
canbe redefined by subclass |
|
739 |
" |
|
740 |
children := nil. |
|
741 |
! ! |
|
742 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
743 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'queries'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
744 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
745 |
isDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
746 |
^ false |
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 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
749 |
isRemoteDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
750 |
^ false |
2267 | 751 |
! |
752 |
||
753 |
time |
|
754 |
||
755 |
^ self valueAt:#modified |
|
2223
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 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
758 |
!HierarchicalFileList::File methodsFor:'accessing'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
759 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
760 |
children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
761 |
"always returns an empty list |
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 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
765 |
|
1390 | 766 |
!HierarchicalFileList::File methodsFor:'queries'! |
767 |
||
768 |
hasChildren |
|
769 |
"always returns false |
|
770 |
" |
|
771 |
^ false |
|
772 |
! ! |
|
773 |
||
2259 | 774 |
!HierarchicalFileList::Directory class methodsFor:'documentation'! |
775 |
||
776 |
documentation |
|
777 |
" |
|
778 |
[Instance variables:] |
|
779 |
||
2267 | 780 |
fetchOperation <Symbol/Boolean> nil if children is nil, no information about has children |
781 |
#fetching registered in list to be updated for indication |
|
782 |
#hasChildren registered in list to be updated for indication |
|
783 |
#hasNoChildren has children but children list might be nil (remote) |
|
2259 | 784 |
" |
785 |
! ! |
|
786 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
787 |
!HierarchicalFileList::Directory methodsFor:'accessing'! |
1390 | 788 |
|
789 |
children |
|
790 |
"returns the list of children |
|
791 |
" |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
792 |
|model| |
1390 | 793 |
|
2306 | 794 |
children notNil ifTrue:[ ^ children ]. |
1390 | 795 |
|
2259 | 796 |
model := self model. |
2306 | 797 |
model isNil ifTrue:[ ^ nil ]. |
1390 | 798 |
|
2259 | 799 |
model criticalDo:[ |
2306 | 800 |
children isNil ifTrue:[ self readChildren ]. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
801 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
802 |
^ children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
803 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
804 |
|
2270 | 805 |
flushChildren |
806 |
"flush the children because node not visible .... |
|
807 |
" |
|
2306 | 808 |
children notNil ifTrue:[ |
2270 | 809 |
"keep hasChildren information |
810 |
" |
|
811 |
children size ~~ 0 ifTrue:[ fetchOperation := #hasChildren ] |
|
812 |
ifFalse:[ fetchOperation := #hasNoChildren ]. |
|
813 |
children := nil. |
|
814 |
]. |
|
815 |
! |
|
816 |
||
2387 | 817 |
icon |
818 |
"returns the icon key |
|
819 |
" |
|
820 |
isExpanded ifTrue:[ |
|
2428 | 821 |
makeIconGray == true ifTrue:[ |
822 |
^ FileBrowser iconForKeyMatching:#directoryOpenGray |
|
823 |
]. |
|
2387 | 824 |
^ FileBrowser iconForKeyMatching:#directoryOpen |
825 |
]. |
|
2428 | 826 |
makeIconGray == true ifTrue:[ |
827 |
^ FileBrowser iconForKeyMatching:#directoryGray |
|
828 |
]. |
|
2387 | 829 |
icon isNil ifTrue:[ |
830 |
^ super icon |
|
831 |
]. |
|
832 |
^ icon |
|
833 |
! |
|
834 |
||
2428 | 835 |
makeIconGray:something |
836 |
"set the value of the instance variable 'makeIconGray' (automatically generated)" |
|
837 |
||
838 |
makeIconGray := something. |
|
839 |
! |
|
840 |
||
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
841 |
modificationTime:something |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
842 |
"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
|
843 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
844 |
modificationTime := something. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
845 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
846 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
847 |
readChildren |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
848 |
"reads the list of children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
849 |
" |
2259 | 850 |
|model list hadChildren hasChildren| |
851 |
||
852 |
model := self model. |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
853 |
|
2306 | 854 |
model isNil ifTrue:[ |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
855 |
"/ must reread later |
2259 | 856 |
fetchOperation := modificationTime := children := nil. |
857 |
^ nil |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
858 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
859 |
|
2259 | 860 |
hadChildren := children size ~~ 0. |
861 |
||
862 |
"/ set to suppress reading of children |
|
1867 | 863 |
children := #(). |
2259 | 864 |
fetchOperation := nil. |
2297 | 865 |
modificationTime := self fileName modificationTime. |
2259 | 866 |
model stopIndicatorValidationFor:self. |
867 |
||
1867 | 868 |
list := model childrenFor:self. |
869 |
||
870 |
list size ~~ 0 ifTrue:[ |
|
871 |
list do:[:aChild| aChild parent:self]. |
|
872 |
children := list. |
|
1390 | 873 |
]. |
2259 | 874 |
hasChildren := children size ~~ 0. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
875 |
|
2259 | 876 |
hasChildren ~~ hadChildren ifTrue:[ |
877 |
self changed:#redraw |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
878 |
]. |
1390 | 879 |
^ children |
880 |
! ! |
|
881 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
882 |
!HierarchicalFileList::Directory methodsFor:'accessing-hierarchy'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
883 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
884 |
collapse |
2270 | 885 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
886 |
super collapse. |
2270 | 887 |
|
888 |
children notNil ifTrue:[ |
|
889 |
children do:[:el| el flushChildren ] |
|
890 |
]. |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
891 |
! |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
892 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
893 |
expand |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
894 |
"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
|
895 |
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
|
896 |
" |
2270 | 897 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
898 |
super expand. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
899 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
900 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
901 |
recursiveCollapse |
2270 | 902 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
903 |
super recursiveCollapse. |
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 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
906 |
recursiveExpand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
907 |
"redefined to expand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
908 |
" |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
909 |
self expand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
910 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
911 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
912 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
913 |
|
2259 | 914 |
!HierarchicalFileList::Directory methodsFor:'fetching'! |
915 |
||
916 |
basicFetchIndicator |
|
2267 | 917 |
|hasChildren| |
918 |
||
2297 | 919 |
hasChildren := DirectoryContents directoryNamed:self fileName detect:(self model matchBlock). |
2267 | 920 |
hasChildren ifTrue:[ |
921 |
fetchOperation := #hasChildren |
|
922 |
] ifFalse:[ |
|
923 |
fetchOperation := #hasNoChildren |
|
924 |
]. |
|
925 |
children isNil ifTrue:[ |
|
926 |
"setup modification time to suppress monitorCycle |
|
927 |
" |
|
2297 | 928 |
modificationTime := self fileName modificationTime. |
2267 | 929 |
]. |
2259 | 930 |
! |
931 |
||
932 |
fetchIndicator |
|
933 |
"fetch the indicator value which indicates whether children exists or not |
|
934 |
called by the list |
|
935 |
" |
|
2306 | 936 |
children notNil ifTrue:[ |
2259 | 937 |
"/ children already read |
938 |
fetchOperation := nil. |
|
939 |
^ self |
|
940 |
]. |
|
941 |
||
2267 | 942 |
fetchOperation ~~ #fetching ifTrue:[ |
2259 | 943 |
"/ children will be updated .... |
944 |
^ self |
|
945 |
]. |
|
946 |
"/ suppress restart of fetchIndicator |
|
947 |
||
948 |
self basicFetchIndicator. |
|
949 |
||
950 |
children notNil ifTrue:[ |
|
951 |
fetchOperation := nil. |
|
952 |
children notEmpty ifTrue:[ self changed:#redraw ]. |
|
953 |
] ifFalse:[ |
|
954 |
"/ is a remote or very slow file system |
|
2267 | 955 |
fetchOperation == #hasChildren ifTrue:[ |
956 |
self changed:#redraw |
|
957 |
]. |
|
2259 | 958 |
]. |
959 |
! |
|
960 |
||
961 |
resetFetchIndicator |
|
962 |
"update indication cycle has deregistered the item |
|
963 |
" |
|
964 |
fetchOperation := nil. |
|
965 |
! ! |
|
966 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
967 |
!HierarchicalFileList::Directory methodsFor:'queries'! |
1390 | 968 |
|
969 |
hasChildren |
|
970 |
"returns true if children exists |
|
971 |
" |
|
2259 | 972 |
|model| |
973 |
||
974 |
children notNil ifTrue:[ |
|
975 |
fetchOperation := nil. |
|
976 |
^ children size ~~ 0 |
|
977 |
]. |
|
978 |
||
2306 | 979 |
fetchOperation notNil ifTrue:[ |
2267 | 980 |
^ fetchOperation == #hasChildren |
2259 | 981 |
]. |
982 |
||
983 |
model := self model. |
|
984 |
||
985 |
model notNil ifTrue:[ |
|
2267 | 986 |
fetchOperation := #fetching. |
2259 | 987 |
model startIndicatorValidationFor:self. |
988 |
] ifFalse:[ |
|
2267 | 989 |
self error:'should not happen' mayProceed:true. |
2259 | 990 |
fetchOperation := nil |
991 |
]. |
|
2267 | 992 |
^ children size ~~ 0 |
1390 | 993 |
! |
994 |
||
995 |
isDirectory |
|
996 |
"always returns true |
|
997 |
" |
|
998 |
^ true |
|
999 |
||
1000 |
||
1001 |
! ! |
|
1002 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1003 |
!HierarchicalFileList::Directory methodsFor:'validation'! |
1390 | 1004 |
|
2267 | 1005 |
invalidateRepairNow:doRepair |
1006 |
"invalidate contents |
|
1007 |
" |
|
1008 |
fetchOperation := modificationTime := nil. |
|
1009 |
||
1010 |
isExpanded ifFalse:[ |
|
1011 |
children := nil |
|
1012 |
] ifTrue:[ |
|
1013 |
doRepair ifTrue:[ |
|
1014 |
self monitoringCycle |
|
1015 |
] ifFalse:[ |
|
1016 |
children size == 0 ifTrue:[ |
|
1017 |
"/ expanded but no children added, thus can reset the children |
|
1018 |
children := nil |
|
1019 |
] |
|
1020 |
] |
|
1021 |
]. |
|
1022 |
! |
|
1023 |
||
1024 |
matchBlockChanged |
|
1025 |
"called if the matchBlock changed |
|
1026 |
" |
|
1027 |
modificationTime := nil. |
|
1028 |
||
1029 |
isExpanded ifFalse:[ |
|
1030 |
fetchOperation := children := nil. |
|
1031 |
] ifTrue:[ |
|
1032 |
self monitoringCycle. |
|
1033 |
||
1034 |
children size ~~ 0 ifTrue:[ |
|
1035 |
children do:[:aChild| aChild matchBlockChanged ] |
|
1036 |
] |
|
1037 |
]. |
|
1038 |
! |
|
1039 |
||
1040 |
monitoringCycle |
|
1041 |
"run monitoring cycle |
|
1042 |
!!!!!!!! called by the HierarchicalList only !!!!!!!! |
|
1043 |
" |
|
1044 |
|unusedDict addedItems mergedList size modifyTime model timeChanged| |
|
1045 |
||
2297 | 1046 |
modifyTime := self fileName modificationTime. |
2306 | 1047 |
modifyTime isNil ifTrue:[^ self]. |
2267 | 1048 |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1049 |
timeChanged := (modificationTime isNil or:[modifyTime ~= modificationTime]). |
2267 | 1050 |
modificationTime := modifyTime. |
1051 |
||
2306 | 1052 |
children notNil ifTrue:[ |
2267 | 1053 |
timeChanged ifFalse:[ |
1054 |
^ self |
|
1055 |
]. |
|
1056 |
]. |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1057 |
DirectoryContents flushCachedDirectoryFor:(self fileName). |
2267 | 1058 |
isExpanded ifFalse:[ |
1059 |
timeChanged ifTrue:[ |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1060 |
fetchOperation := children := nil. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1061 |
self changed:#redraw. |
2267 | 1062 |
]. |
1063 |
^ self |
|
1064 |
]. |
|
1065 |
model := self model. |
|
2306 | 1066 |
children isNil ifTrue:[ children := #() ]. "/ disable update during merge |
2267 | 1067 |
|
1068 |
||
1069 |
fetchOperation := nil. |
|
1070 |
mergedList := model childrenFor:self. |
|
1071 |
||
1072 |
mergedList size == 0 ifTrue:[ |
|
1073 |
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
|
1074 |
^ self |
2267 | 1075 |
]. |
1076 |
||
1077 |
size := children size. |
|
1078 |
||
1079 |
size == 0 ifTrue:[ |
|
1080 |
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
|
1081 |
^ self |
2267 | 1082 |
]. |
1083 |
||
1084 |
model criticalDo:[ |
|
1085 |
addedItems := OrderedCollection new:128. |
|
1086 |
unusedDict := Dictionary new:size. |
|
1087 |
||
1088 |
children do:[:el| unusedDict at:(el fileName) put:el ]. |
|
1089 |
||
1090 |
mergedList keysAndValuesDo:[:anIndex :anItem| |item| |
|
1091 |
item := unusedDict removeKey:(anItem fileName) ifAbsent:nil. |
|
1092 |
||
1093 |
item notNil ifTrue:[ |
|
1094 |
mergedList at:anIndex put:item |
|
1095 |
] ifFalse:[ |
|
1096 |
addedItems add:anItem. |
|
1097 |
anItem parent:self. |
|
1098 |
]. |
|
1099 |
]. |
|
1100 |
"/ 12 is hardcoded !!!!!!!! |
|
1101 |
||
1102 |
(unusedDict size + addedItems size) > 12 ifTrue:[ |
|
1103 |
"/ generate two nofifications: collapse and expand |
|
1104 |
self collapse. |
|
1105 |
children := mergedList. |
|
1106 |
self expand. |
|
1107 |
] ifFalse:[ |
|
1108 |
unusedDict do:[:el| self remove:el ]. |
|
1109 |
||
1110 |
addedItems notEmpty ifTrue:[ |
|
1111 |
self addAll:addedItems |
|
1112 |
]. |
|
1113 |
"/ children order changed test |
|
1114 |
children := mergedList. |
|
1115 |
self childrenOrderChanged. |
|
1116 |
]. |
|
1117 |
]. |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1118 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1119 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1120 |
updateList |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1121 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1122 |
modificationTime := nil. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1123 |
self monitoringCycle. |
1390 | 1124 |
! ! |
1125 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1126 |
!HierarchicalFileList::RemoteDirectory methodsFor:'queries'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1127 |
|
2267 | 1128 |
hasChildren |
1129 |
"returns true if children exists |
|
1130 |
" |
|
1131 |
children notNil ifTrue:[ |
|
1132 |
fetchOperation := nil. |
|
1133 |
^ children size ~~ 0 |
|
1134 |
]. |
|
1135 |
fetchOperation := #hasChildren. |
|
1136 |
^ true |
|
1137 |
! |
|
1138 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1139 |
isRemoteDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1140 |
^ true |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1141 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1142 |
|
1390 | 1143 |
!HierarchicalFileList class methodsFor:'documentation'! |
1144 |
||
1145 |
version |
|
2428 | 1146 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.41 2003-01-15 10:15:57 penk Exp $' |
1390 | 1147 |
! ! |