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