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