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