author | ca |
Fri, 19 Dec 2008 09:59:27 +0100 | |
changeset 3616 | 24e9cca2b5f6 |
parent 3611 | fd548fa851ac |
child 3617 | 86ab45e1e77f |
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 |
]. |
2267 | 321 |
item monitoringCycle |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
322 |
]. |
2809 | 323 |
"/ Processor yield. |
2429 | 324 |
item := self at:index ifAbsent:nil. |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
325 |
index := index + 1. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
326 |
]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
327 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
328 |
|
1390 | 329 |
!HierarchicalFileList methodsFor:'protocol'! |
330 |
||
331 |
childrenFor:anItem |
|
332 |
"returns all visible children derived from the physical |
|
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 |
list := OrderedCollection new. |
|
346 |
match := self matchBlockFor:anItem. |
|
2130 | 347 |
|
3616 | 348 |
contents itemsDo:[:each| |
349 |
( match isNil |
|
350 |
or:[match value:(each fileName) value:(each isDirectory)] |
|
351 |
) ifTrue:[ |
|
352 |
list add:(HierarchicalFileItem forContentsItem:each). |
|
353 |
] |
|
354 |
]. |
|
355 |
list notEmpty ifTrue:[ |
|
356 |
list sort:self sortBlock. |
|
357 |
^ list |
|
358 |
]. |
|
359 |
]. |
|
1390 | 360 |
]. |
3616 | 361 |
^ #() |
1390 | 362 |
! |
363 |
||
364 |
hasChildrenFor:anItem |
|
365 |
"returns true if the physical directory contains at least |
|
2806 | 366 |
one visible item; otherwise false." |
367 |
||
1390 | 368 |
|block| |
369 |
||
370 |
anItem isDirectory ifFalse:[ |
|
371 |
^ false |
|
372 |
]. |
|
373 |
||
374 |
(block := self matchBlockFor:anItem) isNil ifTrue:[ |
|
375 |
block := [:aFilename :isDirectory| true ] |
|
376 |
]. |
|
377 |
^ DirectoryContents directoryNamed:(anItem fileName) detect:block |
|
378 |
! |
|
379 |
||
380 |
matchBlockFor:anItem |
|
381 |
"get the matchBlock - if non-nil, it controls which files are |
|
2806 | 382 |
visible within the physical directory" |
383 |
||
1390 | 384 |
^ matchBlock |
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
385 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
386 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
387 |
updateList |
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 |
self monitoringCycle:true |
1390 | 390 |
! ! |
391 |
||
1581 | 392 |
!HierarchicalFileList methodsFor:'searching'! |
393 |
||
2272 | 394 |
findLastForFile:aPathOrFile |
395 |
"find last item which matches the path or file |
|
2806 | 396 |
returns the item or nil if not contained in self" |
397 |
||
2272 | 398 |
|file searchItem rootDir rootComponents searchComponents| |
1581 | 399 |
|
2272 | 400 |
(aPathOrFile isNil or:[root isNil]) ifTrue:[ |
1582 | 401 |
^ nil |
1581 | 402 |
]. |
403 |
||
2272 | 404 |
file := aPathOrFile asFilename. |
405 |
file exists ifFalse:[ ^ nil ]. |
|
1581 | 406 |
|
2272 | 407 |
rootDir := root fileName asAbsoluteFilename. |
2290
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
408 |
"/ file := file asAbsoluteFilename. |
2272 | 409 |
|
1581 | 410 |
|
2290
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
411 |
"/ (file pathName startsWith:(rootDir pathName)) ifFalse:[ |
29e279812a45
search not for absoluteFilename in searchItem to get the link files
penk
parents:
2272
diff
changeset
|
412 |
(file asString startsWith:(rootDir pathName)) ifFalse:[ |
2272 | 413 |
"not included" |
414 |
^ nil |
|
1581 | 415 |
]. |
2272 | 416 |
rootComponents := rootDir components. |
2299 | 417 |
searchComponents := file asCanonicalizedFilename components. |
2272 | 418 |
searchItem := root. |
1581 | 419 |
|
2272 | 420 |
searchComponents from:(rootComponents size + 1) do:[:aName| |child| |
421 |
child := searchItem detect:[:el| el baseName = aName ] ifNone:nil. |
|
422 |
||
423 |
child isNil ifTrue:[ ^ searchItem ]. |
|
424 |
searchItem := child. |
|
1581 | 425 |
]. |
2272 | 426 |
^ searchItem |
1581 | 427 |
! ! |
428 |
||
2259 | 429 |
!HierarchicalFileList methodsFor:'update'! |
430 |
||
431 |
startIndicatorValidationFor:anItem |
|
2806 | 432 |
"an item will be registered for an indication update" |
433 |
||
2259 | 434 |
|prio| |
435 |
||
436 |
self criticalDo:[ |
|
437 |
indicatorList size == 0 ifTrue:[ |
|
438 |
indicatorList := OrderedCollection new. |
|
439 |
] ifFalse:[ |
|
440 |
indicatorList removeIdentical:anItem ifAbsent:nil. |
|
441 |
]. |
|
442 |
"/ indicatorList addFirst:anItem. |
|
443 |
indicatorList add:anItem. |
|
444 |
||
2306 | 445 |
indicatorTask isNil ifTrue:[ |
2259 | 446 |
prio := Processor activePriority. |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
447 |
indicatorTask := |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
448 |
[ |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
449 |
self updateIndicatorCycle. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
450 |
] newProcess. |
2259 | 451 |
indicatorTask priorityRange:(prio-1 to:prio). |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
452 |
indicatorTask resume. |
2259 | 453 |
] |
454 |
]. |
|
455 |
! |
|
456 |
||
457 |
stopIndicatorValidationFor:anItem |
|
2806 | 458 |
"stop the indicator validation for an item" |
459 |
||
2259 | 460 |
self criticalDo:[ |
2306 | 461 |
indicatorList notNil ifTrue:[ |
2259 | 462 |
indicatorList removeIdentical:anItem ifAbsent:nil. |
463 |
anItem resetFetchIndicator. |
|
464 |
] |
|
465 |
]. |
|
466 |
! |
|
467 |
||
468 |
updateIndicatorCycle |
|
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
469 |
"run fetching indicator (hasChildren info) task cycle. |
2259 | 470 |
This is done in the background to avoid long startup |
471 |
delays, in case the indicator information takes long to |
|
2806 | 472 |
gather (i.e. when reading remote directories)" |
2510
ba2eed40ba9f
Stream streamErrorSignal -> StreamError
Stefan Vogel <sv@exept.de>
parents:
2493
diff
changeset
|
473 |
|
2259 | 474 |
|repeat task item| |
475 |
||
476 |
repeat := true. |
|
477 |
task := indicatorTask. |
|
478 |
||
2806 | 479 |
[ |
480 |
[ task notNil ] whileTrue:[ |
|
481 |
self criticalDo:[ |
|
482 |
( dependents size ~~ 0 "/ no dependencies (stop task) |
|
483 |
and:[indicatorList size ~~ 0] "/ nothing to do |
|
484 |
) ifTrue:[ |
|
485 |
item := indicatorList removeFirst. |
|
2259 | 486 |
|
2806 | 487 |
(self includesIdentical:item) ifFalse:[ |
488 |
"/ item is no longer visible |
|
489 |
item resetFetchIndicator. |
|
490 |
item := nil |
|
491 |
] |
|
492 |
] ifFalse:[ |
|
493 |
item := indicatorTask := task := nil |
|
2259 | 494 |
] |
2806 | 495 |
]. |
496 |
item notNil ifTrue:[ |
|
497 |
item fetchIndicator. |
|
498 |
]. |
|
3178 | 499 |
Processor yield. |
2806 | 500 |
] |
501 |
] ifCurtailed:[ |
|
2306 | 502 |
task notNil ifTrue:[ |
2259 | 503 |
"/ oops, process terminated |
504 |
self criticalDo:[ |
|
505 |
"/ test whether a new task already started |
|
506 |
indicatorTask == task ifTrue:[ |
|
507 |
indicatorTask := nil |
|
508 |
] |
|
509 |
] |
|
510 |
] |
|
511 |
]. |
|
3178 | 512 |
|
513 |
"Modified: / 27-02-2007 / 11:49:07 / cg" |
|
2259 | 514 |
! ! |
515 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
516 |
!HierarchicalFileList::HierarchicalFileItem class methodsFor:'instance creation'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
517 |
|
2297 | 518 |
fileName:aFileName |
519 |
^ self forContentsItem:(DirectoryContents contentsItemForFileName:aFileName) |
|
520 |
! |
|
521 |
||
2299 | 522 |
forContentsItem:aContentsItem |
2294 | 523 |
|item cls| |
524 |
||
2299 | 525 |
cls := HierarchicalFileList::File. |
526 |
||
527 |
aContentsItem notNil ifTrue:[ |
|
528 |
aContentsItem isRemoteDirectory ifTrue:[ |
|
529 |
cls := HierarchicalFileList::RemoteDirectory |
|
2294 | 530 |
] ifFalse:[ |
2299 | 531 |
aContentsItem isDirectory ifTrue:[ |
532 |
cls := HierarchicalFileList::Directory |
|
533 |
] |
|
534 |
]. |
|
2294 | 535 |
]. |
536 |
item := cls basicNew initialize. |
|
2299 | 537 |
item contentsItem:aContentsItem. |
2297 | 538 |
^ item |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
539 |
! |
1390 | 540 |
|
2294 | 541 |
new |
542 |
self error. |
|
1390 | 543 |
! ! |
544 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
545 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'accessing'! |
1390 | 546 |
|
547 |
baseName |
|
2297 | 548 |
^ contentsItem fileName baseName. |
549 |
! |
|
550 |
||
551 |
contentsItem:aContentsItem |
|
552 |
contentsItem := aContentsItem |
|
2293 | 553 |
! |
554 |
||
1390 | 555 |
fileName |
2297 | 556 |
^ contentsItem fileName |
1390 | 557 |
! |
558 |
||
2294 | 559 |
fileName:aFilename |
3584
f9cdd1fa3b75
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
3563
diff
changeset
|
560 |
self shouldImplement. |
2297 | 561 |
contentsItem := DirectoryContents contentsItemForFileName:aFilename |
562 |
||
563 |
"/ fileName = aFilename ifFalse:[ |
|
564 |
"/ fileName := aFilename. |
|
565 |
"/ self changed:#label |
|
566 |
"/ ]. |
|
1390 | 567 |
! |
568 |
||
2293 | 569 |
fileSize |
2297 | 570 |
|fileInfo| |
571 |
||
572 |
fileInfo := contentsItem info. |
|
2293 | 573 |
fileInfo isNil ifTrue:[^ nil]. |
2832 | 574 |
^ fileInfo fileSize |
2293 | 575 |
! |
2267 | 576 |
|
2293 | 577 |
group |
2832 | 578 |
"returns the printable group" |
579 |
||
2297 | 580 |
|fileInfo gid group| |
2294 | 581 |
|
2297 | 582 |
fileInfo := contentsItem info. |
2294 | 583 |
fileInfo notNil ifTrue:[ |
584 |
gid := fileInfo gid. |
|
2293 | 585 |
|
2294 | 586 |
gid notNil ifTrue:[ |
587 |
(LastGIDToGroupNameMapping notNil and:[gid == LastGIDToGroupNameMapping key]) ifTrue:[ |
|
588 |
^ LastGIDToGroupNameMapping value |
|
589 |
]. |
|
2293 | 590 |
group := OperatingSystem getGroupNameFromID:gid. |
591 |
LastGIDToGroupNameMapping := gid -> group. |
|
2832 | 592 |
^ group |
2293 | 593 |
] |
2267 | 594 |
]. |
2294 | 595 |
^ '???' |
2267 | 596 |
! |
597 |
||
1390 | 598 |
icon |
2832 | 599 |
"returns the icon" |
600 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
601 |
icon isNil ifTrue:[ |
2387 | 602 |
self isRemoteDirectory ifTrue:[ |
603 |
icon := FileBrowser iconForKeyMatching:#directoryNetwork |
|
604 |
] ifFalse:[ |
|
605 |
icon := FileBrowser iconForFile:(self fileName). |
|
606 |
] |
|
1390 | 607 |
]. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
608 |
^ icon. |
1390 | 609 |
! |
610 |
||
611 |
label |
|
2832 | 612 |
"returns the printable name, the baseName" |
613 |
||
2297 | 614 |
^ contentsItem fileName baseName |
1390 | 615 |
! |
616 |
||
2293 | 617 |
modificationTime |
2832 | 618 |
"returns the absolute time of modification" |
2297 | 619 |
|
620 |
|fileInfo| |
|
621 |
||
622 |
fileInfo := contentsItem info. |
|
2293 | 623 |
fileInfo isNil ifTrue:[^ nil]. |
2297 | 624 |
^ fileInfo modificationTime |
2293 | 625 |
! |
626 |
||
627 |
owner |
|
2832 | 628 |
"returns the printable owner" |
629 |
||
2297 | 630 |
|fileInfo uid owner| |
2294 | 631 |
|
2297 | 632 |
fileInfo := contentsItem info. |
2294 | 633 |
fileInfo notNil ifTrue:[ |
634 |
uid := fileInfo uid. |
|
2293 | 635 |
|
2294 | 636 |
uid notNil ifTrue:[ |
637 |
(LastUIDToUserNameMapping notNil and:[uid == LastUIDToUserNameMapping key]) ifTrue:[ |
|
638 |
^ LastUIDToUserNameMapping value |
|
639 |
]. |
|
2293 | 640 |
owner := OperatingSystem getUserNameFromID:uid. |
641 |
LastUIDToUserNameMapping := uid -> owner. |
|
2832 | 642 |
^ owner |
2293 | 643 |
] |
644 |
]. |
|
2294 | 645 |
|
646 |
^ '???' |
|
2293 | 647 |
! |
648 |
||
1390 | 649 |
pathName |
2832 | 650 |
"returns the pathName" |
651 |
||
2297 | 652 |
^ contentsItem fileName pathName |
2267 | 653 |
! |
654 |
||
2293 | 655 |
permissions |
2832 | 656 |
"returns the permissions as printable string" |
657 |
||
2297 | 658 |
|fileInfo mode perms| |
2267 | 659 |
|
2297 | 660 |
fileInfo := contentsItem info. |
2294 | 661 |
fileInfo notNil ifTrue:[ |
662 |
mode := fileInfo mode. |
|
663 |
||
664 |
mode notNil ifTrue:[ |
|
665 |
perms := String new:9 withAll:$-. |
|
2293 | 666 |
|
2294 | 667 |
1 to:9 by:3 do:[:i| |
668 |
(mode bitAt:i ) == 1 ifTrue:[perms at:10 - i put:$x]. |
|
669 |
(mode bitAt:i + 1) == 1 ifTrue:[perms at:9 - i put:$w]. |
|
670 |
(mode bitAt:i + 2) == 1 ifTrue:[perms at:8 - i put:$r]. |
|
671 |
]. |
|
672 |
^ perms |
|
673 |
] |
|
2293 | 674 |
]. |
2294 | 675 |
^ '???' |
2293 | 676 |
! |
677 |
||
678 |
suffix |
|
2832 | 679 |
"returns the suffix of the file" |
680 |
||
2294 | 681 |
(OperatingSystem isUNIXlike and:[(self baseName at:1) == $.]) ifTrue:[ |
682 |
^ '' |
|
2267 | 683 |
]. |
2297 | 684 |
^ contentsItem fileName suffix |
2294 | 685 |
! ! |
686 |
||
687 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'change & update'! |
|
688 |
||
689 |
changed:aParameter |
|
2832 | 690 |
"the item changed; send a change notification" |
691 |
||
2294 | 692 |
aParameter == #icon ifTrue:[ icon := nil ]. |
693 |
super changed:aParameter. |
|
694 |
! ! |
|
695 |
||
696 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'instance creation'! |
|
697 |
||
698 |
fileName:aFilename fileInfo:aFileInfoOrNil |
|
3584
f9cdd1fa3b75
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
3563
diff
changeset
|
699 |
self shouldImplement. |
2297 | 700 |
"/ fileName := aFilename. |
701 |
"/ fileInfo := aFileInfoOrNil. |
|
1390 | 702 |
! ! |
703 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
704 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'invalidate'! |
1390 | 705 |
|
706 |
invalidate |
|
707 |
self invalidateRepairNow:false |
|
708 |
! |
|
709 |
||
710 |
invalidateRepairNow |
|
711 |
self invalidateRepairNow:true |
|
712 |
! |
|
713 |
||
714 |
invalidateRepairNow:doRepair |
|
715 |
"invalidate the contents; dependent on the boolean |
|
716 |
do repair immediately |
|
717 |
" |
|
718 |
||
719 |
||
1866 | 720 |
! |
721 |
||
722 |
matchBlockChanged |
|
2832 | 723 |
"called if the matchBlock changed" |
1390 | 724 |
! ! |
725 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
726 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'printing'! |
2127 | 727 |
|
2479 | 728 |
printOn:aStream |
729 |
super printOn:aStream. |
|
730 |
' for: ' printOn:aStream. |
|
731 |
self fileName printOn:aStream |
|
2127 | 732 |
! ! |
733 |
||
2270 | 734 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'protocol'! |
735 |
||
3616 | 736 |
displayIcon:anIcon atX:x y:y on:aGC |
737 |
"called to draw the icon - if the item is inaccessible |
|
738 |
a red cross is drawn over thge item" |
|
739 |
||
740 |
|x0 y0 y1 w| |
|
741 |
||
742 |
anIcon displayOn:aGC x:x y:y. |
|
743 |
||
744 |
self isInAccessible ifTrue:[ |
|
745 |
aGC paint:(Color red). |
|
746 |
||
747 |
y0 := y + 1. |
|
748 |
y1 := y + anIcon height - 2. |
|
749 |
||
750 |
x0 := x - 1. |
|
751 |
w := anIcon width. |
|
752 |
||
753 |
2 timesRepeat:[ |
|
754 |
aGC displayLineFromX:x0 y:y0 toX:(x0 + w) y:y1. |
|
755 |
aGC displayLineFromX:x0 y:y1 toX:(x0 + w) y:y0. |
|
756 |
x0 := x0 + 1. |
|
757 |
]. |
|
758 |
]. |
|
759 |
! |
|
760 |
||
2270 | 761 |
flushChildren |
2832 | 762 |
"flush the children (because node is not visible) |
763 |
Can be redefined by subclass" |
|
764 |
||
2270 | 765 |
children := nil. |
766 |
! ! |
|
767 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
768 |
!HierarchicalFileList::HierarchicalFileItem methodsFor:'queries'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
769 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
770 |
isDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
771 |
^ false |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
772 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
773 |
|
3174 | 774 |
isDirectoryItem |
775 |
^ self isDirectory |
|
776 |
||
777 |
"Created: / 23-02-2007 / 12:04:37 / User" |
|
778 |
! |
|
779 |
||
3616 | 780 |
isInAccessible |
781 |
"answer true if the underlaying file is not accessible - for example a directors |
|
782 |
than we will draw a red cross through the item..." |
|
783 |
||
784 |
^ false |
|
785 |
! |
|
786 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
787 |
isRemoteDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
788 |
^ false |
2267 | 789 |
! |
790 |
||
2832 | 791 |
isWritable |
792 |
^ self fileName isWritable |
|
793 |
! |
|
794 |
||
2267 | 795 |
time |
796 |
^ self valueAt:#modified |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
797 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
798 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
799 |
!HierarchicalFileList::File methodsFor:'accessing'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
800 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
801 |
children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
802 |
"always returns an empty list |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
803 |
" |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
804 |
^ #() |
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 |
|
1390 | 807 |
!HierarchicalFileList::File methodsFor:'queries'! |
808 |
||
809 |
hasChildren |
|
810 |
"always returns false |
|
811 |
" |
|
812 |
^ false |
|
813 |
! ! |
|
814 |
||
2259 | 815 |
!HierarchicalFileList::Directory class methodsFor:'documentation'! |
816 |
||
817 |
documentation |
|
818 |
" |
|
819 |
[Instance variables:] |
|
820 |
||
2267 | 821 |
fetchOperation <Symbol/Boolean> nil if children is nil, no information about has children |
822 |
#fetching registered in list to be updated for indication |
|
823 |
#hasChildren registered in list to be updated for indication |
|
824 |
#hasNoChildren has children but children list might be nil (remote) |
|
2259 | 825 |
" |
826 |
! ! |
|
827 |
||
2475 | 828 |
!HierarchicalFileList::Directory class methodsFor:'initialization'! |
829 |
||
830 |
initialize |
|
831 |
StateUnknown := nil. |
|
832 |
StateHasChildren := #hasChildren. |
|
833 |
StateHasNoChildren := #hasNoChildren. |
|
834 |
StateFetching := #fetching |
|
835 |
||
836 |
" |
|
837 |
self initialize |
|
838 |
" |
|
839 |
! ! |
|
840 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
841 |
!HierarchicalFileList::Directory methodsFor:'accessing'! |
1390 | 842 |
|
843 |
children |
|
2832 | 844 |
"returns the collection of children or nil" |
845 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
846 |
|model| |
1390 | 847 |
|
2306 | 848 |
children notNil ifTrue:[ ^ children ]. |
1390 | 849 |
|
2259 | 850 |
model := self model. |
2306 | 851 |
model isNil ifTrue:[ ^ nil ]. |
1390 | 852 |
|
2259 | 853 |
model criticalDo:[ |
2306 | 854 |
children isNil ifTrue:[ self readChildren ]. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
855 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
856 |
^ children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
857 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
858 |
|
2475 | 859 |
icon |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
860 |
"returns the icon" |
2475 | 861 |
|
3616 | 862 |
|nameKey filename| |
2270 | 863 |
|
2387 | 864 |
isExpanded ifTrue:[ |
3616 | 865 |
makeIconGray == true ifTrue:[ nameKey := #directoryOpenGray ] |
866 |
ifFalse:[ nameKey := #directoryOpen ]. |
|
2475 | 867 |
] ifFalse:[ |
3616 | 868 |
makeIconGray == true ifTrue:[ nameKey := #directoryGray ] |
2387 | 869 |
]. |
2475 | 870 |
|
871 |
nameKey notNil ifTrue:[ |
|
872 |
^ FileBrowser iconForKeyMatching:nameKey |
|
2428 | 873 |
]. |
3616 | 874 |
icon notNil ifTrue:[^ icon ]. |
2475 | 875 |
|
3616 | 876 |
filename := contentsItem fileName. |
877 |
||
878 |
self isRemoteDirectory ifTrue:[ |
|
879 |
nameKey := FileBrowser iconKeyForRemoteDirectory:filename. |
|
880 |
] ifFalse:[ |
|
881 |
contentsItem isSymbolicLink ifTrue:[ |
|
882 |
icon := FileBrowser iconForLinkedDirectory. |
|
883 |
] ifFalse:[ |
|
884 |
nameKey := filename mimeTypeFromName. |
|
885 |
nameKey isNil ifTrue:[ nameKey := #directory ]. |
|
886 |
icon := FileBrowser iconForKeyMatching:nameKey. |
|
887 |
]. |
|
2387 | 888 |
]. |
889 |
^ icon |
|
890 |
! |
|
891 |
||
2457 | 892 |
label |
893 |
"returns the printable name, the baseName |
|
894 |
" |
|
2654 | 895 |
parent isHierarchicalItem ifFalse:[ |
896 |
"no parent exists, thus we have to test for rootDirectory |
|
897 |
" |
|
898 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
899 |
contentsItem fileName isRootDirectory ifTrue:[ |
|
900 |
^ contentsItem fileName pathName |
|
901 |
] |
|
902 |
]. |
|
2457 | 903 |
]. |
904 |
^ contentsItem fileName baseName |
|
905 |
! |
|
906 |
||
2428 | 907 |
makeIconGray:something |
2475 | 908 |
"set/clear the flag which enforces the icon to be shown in grey" |
2428 | 909 |
|
910 |
makeIconGray := something. |
|
911 |
! |
|
912 |
||
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
913 |
modificationTime:something |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
914 |
modificationTime := something. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
915 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
916 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
917 |
readChildren |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
918 |
"reads the list of children |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
919 |
" |
2259 | 920 |
|model list hadChildren hasChildren| |
921 |
||
2475 | 922 |
self forgetAboutChildren. |
923 |
||
2259 | 924 |
model := self model. |
2306 | 925 |
model isNil ifTrue:[ |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
926 |
"/ must reread later |
2475 | 927 |
modificationTime := children := nil. |
928 |
^ nil |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
929 |
]. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
930 |
|
2259 | 931 |
hadChildren := children size ~~ 0. |
932 |
||
933 |
"/ set to suppress reading of children |
|
1867 | 934 |
children := #(). |
2297 | 935 |
modificationTime := self fileName modificationTime. |
2259 | 936 |
model stopIndicatorValidationFor:self. |
937 |
||
3616 | 938 |
"/ set to false - will be set by my model during reading the contents |
939 |
isInAccessible := false. |
|
1867 | 940 |
list := model childrenFor:self. |
941 |
||
942 |
list size ~~ 0 ifTrue:[ |
|
943 |
list do:[:aChild| aChild parent:self]. |
|
944 |
children := list. |
|
1390 | 945 |
]. |
2259 | 946 |
hasChildren := children size ~~ 0. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
947 |
|
2259 | 948 |
hasChildren ~~ hadChildren ifTrue:[ |
949 |
self changed:#redraw |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
950 |
]. |
1390 | 951 |
^ children |
952 |
! ! |
|
953 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
954 |
!HierarchicalFileList::Directory methodsFor:'accessing-hierarchy'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
955 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
956 |
collapse |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
957 |
super collapse. |
2270 | 958 |
|
959 |
children notNil ifTrue:[ |
|
960 |
children do:[:el| el flushChildren ] |
|
961 |
]. |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
962 |
! |
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
963 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
964 |
expand |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
965 |
"expand children; must redefine to raise a notification |
2832 | 966 |
if children are not yet initialized and after initialization empty." |
2270 | 967 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
968 |
super expand. |
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
969 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
970 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
971 |
recursiveCollapse |
2270 | 972 |
|
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
973 |
super recursiveCollapse. |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
974 |
! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
975 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
976 |
recursiveExpand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
977 |
"redefined to expand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
978 |
" |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
979 |
self expand |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
980 |
|
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
981 |
|
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
982 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
983 |
|
2259 | 984 |
!HierarchicalFileList::Directory methodsFor:'fetching'! |
985 |
||
986 |
basicFetchIndicator |
|
3616 | 987 |
|linkName fileName hasChildren info fileItem model| |
2267 | 988 |
|
2583 | 989 |
fileName := self fileName. |
3611 | 990 |
fileItem := DirectoryContents contentsItemForFileName:fileName. |
991 |
||
992 |
fileItem notNil ifTrue:[ |
|
993 |
info := fileItem info. |
|
994 |
]. |
|
995 |
||
2734
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
996 |
(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
|
997 |
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
|
998 |
] ifFalse:[ |
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
999 |
linkName := fileName name. |
2583 | 1000 |
]. |
2734
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
1001 |
|
2766
04990ee7e604
dont automaticly fetch indicator for nfs mounted filesystems only
Michael Beyl <mb@exept.de>
parents:
2734
diff
changeset
|
1002 |
(OperatingSystem mountPoints contains:[:mp | mp mountPointPath = linkName and:[mp isRemote]]) ifTrue:[ |
2583 | 1003 |
"do not follow mounted directories automatically (could be an NFS hardlink)" |
1004 |
^ self. |
|
1005 |
]. |
|
1006 |
||
3616 | 1007 |
(model := self model) notNil ifTrue:[ |
1008 |
isInAccessible := false. |
|
1009 |
||
1010 |
hasChildren := DirectoryContents |
|
1011 |
directoryNamed:fileName |
|
1012 |
detect:(model matchBlock) |
|
1013 |
onOpenErrorDo:[:fn| isInAccessible := true ]. |
|
1014 |
||
1015 |
] ifFalse:[ |
|
1016 |
hasChildren := false. |
|
1017 |
]. |
|
2475 | 1018 |
self knownToHaveChildren:hasChildren. |
2809 | 1019 |
"/ self assert:children isNil. |
2475 | 1020 |
|
2734
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
1021 |
(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
|
1022 |
"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
|
1023 |
modificationTime := info modificationTime. |
2267 | 1024 |
]. |
3145 | 1025 |
|
1026 |
"Modified: / 08-11-2006 / 17:31:16 / cg" |
|
2259 | 1027 |
! |
1028 |
||
1029 |
fetchIndicator |
|
2475 | 1030 |
"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
|
1031 |
Called by the indocator update process." |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1032 |
|
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1033 |
|stateBefore stateNow| |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1034 |
|
2306 | 1035 |
children notNil ifTrue:[ |
2259 | 1036 |
"/ children already read |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1037 |
self knownToHaveChildren:(children size > 0). |
2475 | 1038 |
^ self |
2259 | 1039 |
]. |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1040 |
quickChildrenInfo == StateFetching ifFalse:[ |
2475 | 1041 |
"/ children will be updated in a second.... |
2259 | 1042 |
^ self |
1043 |
]. |
|
1044 |
||
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1045 |
stateBefore := quickChildrenInfo. |
2259 | 1046 |
self basicFetchIndicator. |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1047 |
stateNow := quickChildrenInfo. |
2259 | 1048 |
|
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1049 |
stateBefore ~~ stateNow ifTrue:[ |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1050 |
self changed:#redraw |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1051 |
]. |
2475 | 1052 |
|
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1053 |
"/ children notNil ifTrue:[ |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1054 |
"/ self forgetAboutChildren. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1055 |
"/ children notEmpty ifTrue:[ self changed:#redraw ]. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1056 |
"/ ] ifFalse:[ |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1057 |
"/ "/ is a remote or very slow file system |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1058 |
"/ self isKnownToHaveChildren ifTrue:[ |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1059 |
"/ self changed:#redraw |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1060 |
"/ ]. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1061 |
"/ ]. |
2259 | 1062 |
! |
1063 |
||
1064 |
resetFetchIndicator |
|
1065 |
"update indication cycle has deregistered the item |
|
1066 |
" |
|
2475 | 1067 |
|
1068 |
self forgetAboutChildren. |
|
1069 |
! ! |
|
1070 |
||
1071 |
!HierarchicalFileList::Directory methodsFor:'private'! |
|
1072 |
||
1073 |
flushChildren |
|
2832 | 1074 |
"flush the children because the node is going to be invisible." |
1075 |
||
2859 | 1076 |
children notNil ifTrue:[ |
1077 |
self knownToHaveChildren:(children size ~~ 0). |
|
1078 |
children := nil. |
|
1079 |
] ifFalse:[ |
|
1080 |
"/ state is unknown |
|
1081 |
self forgetAboutChildren. |
|
1082 |
]. |
|
2475 | 1083 |
! ! |
1084 |
||
2493 | 1085 |
!HierarchicalFileList::Directory methodsFor:'private-quick children info'! |
2475 | 1086 |
|
1087 |
forgetAboutChildren |
|
1088 |
quickChildrenInfo := StateUnknown |
|
1089 |
! |
|
1090 |
||
1091 |
isChildrenInfoValid |
|
1092 |
^ quickChildrenInfo ~~ StateUnknown and:[quickChildrenInfo ~~ StateFetching] |
|
1093 |
! |
|
1094 |
||
1095 |
isFetchingChildrenInfo |
|
1096 |
^ quickChildrenInfo == StateFetching |
|
1097 |
! |
|
1098 |
||
1099 |
isKnownToHaveChildren |
|
1100 |
^ quickChildrenInfo == StateHasChildren |
|
1101 |
! |
|
1102 |
||
1103 |
isKnownToHaveNoChildren |
|
1104 |
^ quickChildrenInfo == StateHasNoChildren |
|
1105 |
! |
|
1106 |
||
1107 |
knownToHaveChildren:aBoolean |
|
1108 |
aBoolean ifTrue:[ |
|
1109 |
quickChildrenInfo := StateHasChildren. |
|
1110 |
] ifFalse:[ |
|
1111 |
quickChildrenInfo := StateHasNoChildren. |
|
1112 |
]. |
|
1113 |
! |
|
1114 |
||
1115 |
setFetchingChildrenInfo |
|
1116 |
quickChildrenInfo := StateFetching |
|
2259 | 1117 |
! ! |
1118 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1119 |
!HierarchicalFileList::Directory methodsFor:'queries'! |
1390 | 1120 |
|
3616 | 1121 |
beInAccessible |
1122 |
isInAccessible := true. |
|
1123 |
! |
|
1124 |
||
2475 | 1125 |
canExpand |
1126 |
super canExpand ifTrue:[^ true]. |
|
2832 | 1127 |
|
1128 |
"/ in case we are currently fetching the subdirectory |
|
1129 |
"/ self isFetchingChildrenInfo ifTrue:[ |
|
2525 | 1130 |
"/self halt. |
2832 | 1131 |
"/ ]. |
2475 | 1132 |
|
1133 |
^ false |
|
1134 |
! |
|
1135 |
||
1390 | 1136 |
hasChildren |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1137 |
"returns true if children exist" |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1138 |
|
2259 | 1139 |
|model| |
1140 |
||
1141 |
children notNil ifTrue:[ |
|
2475 | 1142 |
self forgetAboutChildren. |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1143 |
children size ~~ 0 ifTrue:[ |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1144 |
^ true |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1145 |
]. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1146 |
isExpanded := false. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1147 |
children := #(). |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1148 |
^ false |
2259 | 1149 |
]. |
1150 |
||
2475 | 1151 |
self isFetchingChildrenInfo ifTrue:[ |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1152 |
^ true. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1153 |
"/ ^ false. |
2475 | 1154 |
]. |
1155 |
self isChildrenInfoValid ifTrue:[ |
|
1156 |
^ self isKnownToHaveChildren |
|
2259 | 1157 |
]. |
1158 |
||
1159 |
model := self model. |
|
1160 |
||
1161 |
model notNil ifTrue:[ |
|
2475 | 1162 |
self setFetchingChildrenInfo. |
2259 | 1163 |
model startIndicatorValidationFor:self. |
1164 |
] ifFalse:[ |
|
2267 | 1165 |
self error:'should not happen' mayProceed:true. |
2475 | 1166 |
self forgetAboutChildren |
2259 | 1167 |
]. |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1168 |
children size ~~ 0 ifTrue:[ ^ true]. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1169 |
|
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1170 |
self isFetchingChildrenInfo ifTrue:[ |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1171 |
^ true. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1172 |
"/ ^ false. |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1173 |
]. |
2475 | 1174 |
^ false |
1390 | 1175 |
! |
1176 |
||
1177 |
isDirectory |
|
2832 | 1178 |
"always true here" |
1179 |
||
1390 | 1180 |
^ true |
3616 | 1181 |
! |
1182 |
||
1183 |
isInAccessible |
|
1184 |
"answer true if the directory is not accessible" |
|
1185 |
||
1186 |
^ isInAccessible ? false |
|
1390 | 1187 |
! ! |
1188 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1189 |
!HierarchicalFileList::Directory methodsFor:'validation'! |
1390 | 1190 |
|
2267 | 1191 |
invalidateRepairNow:doRepair |
2832 | 1192 |
"invalidate contents" |
1193 |
||
2475 | 1194 |
modificationTime := nil. |
1195 |
self forgetAboutChildren |
|
2267 | 1196 |
|
1197 |
isExpanded ifFalse:[ |
|
1198 |
children := nil |
|
1199 |
] ifTrue:[ |
|
1200 |
doRepair ifTrue:[ |
|
1201 |
self monitoringCycle |
|
1202 |
] ifFalse:[ |
|
1203 |
children size == 0 ifTrue:[ |
|
1204 |
"/ expanded but no children added, thus can reset the children |
|
1205 |
children := nil |
|
1206 |
] |
|
1207 |
] |
|
1208 |
]. |
|
1209 |
! |
|
1210 |
||
1211 |
matchBlockChanged |
|
1212 |
"called if the matchBlock changed |
|
1213 |
" |
|
1214 |
modificationTime := nil. |
|
1215 |
||
1216 |
isExpanded ifFalse:[ |
|
2475 | 1217 |
children := nil. |
1218 |
self forgetAboutChildren |
|
2267 | 1219 |
] ifTrue:[ |
1220 |
self monitoringCycle. |
|
1221 |
||
1222 |
children size ~~ 0 ifTrue:[ |
|
1223 |
children do:[:aChild| aChild matchBlockChanged ] |
|
1224 |
] |
|
1225 |
]. |
|
1226 |
! |
|
1227 |
||
1228 |
monitoringCycle |
|
1229 |
"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
|
1230 |
!!!!!!!! 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
|
1231 |
|
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
1232 |
|fileName unusedDict addedItems mergedList size modifyTime model timeChanged info| |
2267 | 1233 |
|
2583 | 1234 |
fileName := self fileName. |
2734
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
1235 |
info := fileName linkInfo. |
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
1236 |
info isNil ifTrue:[^ self]. |
2267 | 1237 |
|
2734
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
1238 |
modifyTime := info modificationTime. |
4934113dc4c0
#linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents:
2654
diff
changeset
|
1239 |
timeChanged := modifyTime ~= modificationTime. |
2267 | 1240 |
modificationTime := modifyTime. |
1241 |
||
2306 | 1242 |
children notNil ifTrue:[ |
2267 | 1243 |
timeChanged ifFalse:[ |
1244 |
^ self |
|
1245 |
]. |
|
1246 |
]. |
|
2475 | 1247 |
|
2583 | 1248 |
DirectoryContents flushCachedDirectoryFor:fileName. |
2267 | 1249 |
isExpanded ifFalse:[ |
1250 |
timeChanged ifTrue:[ |
|
2475 | 1251 |
children := nil. |
1252 |
self forgetAboutChildren. |
|
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1253 |
self changed:#redraw. |
2267 | 1254 |
]. |
1255 |
^ self |
|
1256 |
]. |
|
2475 | 1257 |
|
2306 | 1258 |
children isNil ifTrue:[ children := #() ]. "/ disable update during merge |
2267 | 1259 |
|
2475 | 1260 |
self forgetAboutChildren. |
1261 |
model := self model. |
|
1262 |
mergedList := model childrenFor:self. |
|
2267 | 1263 |
|
1264 |
mergedList size == 0 ifTrue:[ |
|
1265 |
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
|
1266 |
^ self |
2267 | 1267 |
]. |
1268 |
||
1269 |
size := children size. |
|
1270 |
size == 0 ifTrue:[ |
|
1271 |
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
|
1272 |
^ self |
2267 | 1273 |
]. |
1274 |
||
1275 |
model criticalDo:[ |
|
1276 |
addedItems := OrderedCollection new:128. |
|
1277 |
unusedDict := Dictionary new:size. |
|
1278 |
||
1279 |
children do:[:el| unusedDict at:(el fileName) put:el ]. |
|
1280 |
||
1281 |
mergedList keysAndValuesDo:[:anIndex :anItem| |item| |
|
1282 |
item := unusedDict removeKey:(anItem fileName) ifAbsent:nil. |
|
1283 |
||
1284 |
item notNil ifTrue:[ |
|
1285 |
mergedList at:anIndex put:item |
|
1286 |
] ifFalse:[ |
|
1287 |
addedItems add:anItem. |
|
1288 |
anItem parent:self. |
|
1289 |
]. |
|
1290 |
]. |
|
2952
10e34346944b
avoid the \"return to original directory when filter changes\"
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1291 |
|
10e34346944b
avoid the \"return to original directory when filter changes\"
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1292 |
unusedDict do:[:el| self remove:el ]. |
2267 | 1293 |
|
2952
10e34346944b
avoid the \"return to original directory when filter changes\"
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1294 |
addedItems notEmpty ifTrue:[ |
10e34346944b
avoid the \"return to original directory when filter changes\"
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1295 |
self addAll:addedItems |
2267 | 1296 |
]. |
2952
10e34346944b
avoid the \"return to original directory when filter changes\"
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1297 |
"/ children order changed test |
10e34346944b
avoid the \"return to original directory when filter changes\"
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1298 |
children := mergedList. |
10e34346944b
avoid the \"return to original directory when filter changes\"
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1299 |
self childrenOrderChanged. |
2267 | 1300 |
]. |
2425
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1301 |
! |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1302 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1303 |
updateList |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1304 |
|
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1305 |
modificationTime := nil. |
7421b8bb7d31
reset modificationtime for updates to get the new files on remote systems where times are different
penk
parents:
2388
diff
changeset
|
1306 |
self monitoringCycle. |
1390 | 1307 |
! ! |
1308 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1309 |
!HierarchicalFileList::RemoteDirectory methodsFor:'queries'! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1310 |
|
2267 | 1311 |
hasChildren |
2808
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1312 |
"returns true if children exist" |
2ee9a7008a6d
update - StateUnknown is treated like \"hasChildren\".
Claus Gittinger <cg@exept.de>
parents:
2806
diff
changeset
|
1313 |
|
2267 | 1314 |
children notNil ifTrue:[ |
2475 | 1315 |
self forgetAboutChildren. |
2267 | 1316 |
^ children size ~~ 0 |
1317 |
]. |
|
2475 | 1318 |
|
1319 |
"/ assume that there are children; |
|
1320 |
"/ this might be wrong and clicking on the expand-icon |
|
1321 |
"/ will then not perform an expand, but remove the can-expand indicator. |
|
1322 |
self knownToHaveChildren:true. |
|
1323 |
^ true |
|
2267 | 1324 |
! |
1325 |
||
2223
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1326 |
isRemoteDirectory |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1327 |
^ true |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1328 |
! ! |
c34e7fd25e53
monitoring; delayed for directories; never for remoteDirectories
penk
parents:
2180
diff
changeset
|
1329 |
|
1390 | 1330 |
!HierarchicalFileList class methodsFor:'documentation'! |
1331 |
||
1332 |
version |
|
3616 | 1333 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.71 2008-12-19 08:59:27 ca Exp $' |
1390 | 1334 |
! ! |
2475 | 1335 |
|
1336 |
HierarchicalFileList::Directory initialize! |