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