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