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