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