author | Claus Gittinger <cg@exept.de> |
Wed, 04 May 2016 18:55:02 +0200 | |
changeset 5058 | 925bc542ebd1 |
parent 4211 | c553f879beac |
child 5283 | 781bb59c4cd7 |
permissions | -rw-r--r-- |
486 | 1 |
" |
489 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
486 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1818 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
486 | 14 |
TreeItem subclass:#FileSelectionItem |
786 | 15 |
instanceVariableNames:'modificationTime matchAction isDirectory imageType showIndicator' |
2037 | 16 |
classVariableNames:'ReadDirectoriesForIndicator' |
486 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-Support' |
|
19 |
! |
|
20 |
||
21 |
FileSelectionItem subclass:#Directory |
|
22 |
instanceVariableNames:'' |
|
23 |
classVariableNames:'' |
|
24 |
poolDictionaries:'' |
|
25 |
privateIn:FileSelectionItem |
|
26 |
! |
|
27 |
||
28 |
FileSelectionItem subclass:#File |
|
29 |
instanceVariableNames:'' |
|
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
32 |
privateIn:FileSelectionItem |
|
33 |
! |
|
34 |
||
35 |
!FileSelectionItem class methodsFor:'documentation'! |
|
36 |
||
37 |
copyright |
|
38 |
" |
|
489 | 39 |
COPYRIGHT (c) 1997 by eXept Software AG |
486 | 40 |
All Rights Reserved |
41 |
||
42 |
This software is furnished under a license and may be used |
|
43 |
only in accordance with the terms of that license and with the |
|
44 |
inclusion of the above copyright notice. This software may not |
|
45 |
be provided or otherwise made available to, or used by, any |
|
46 |
other person. No title to or ownership of the software is |
|
47 |
hereby transferred. |
|
48 |
" |
|
49 |
||
50 |
||
51 |
! |
|
52 |
||
53 |
documentation |
|
54 |
" |
|
2805 | 55 |
class to build up file tree like structures. You can define your own |
56 |
icons and filter. To change the icons, look for these methods: |
|
486 | 57 |
|
2805 | 58 |
class method: #keysAndIcons : returns a list of icons and access keys used |
486 | 59 |
|
2805 | 60 |
instance method: #imageType : get type of icon assigned to file |
486 | 61 |
|
2805 | 62 |
#icon : get the type of image to be drawn |
486 | 63 |
|
64 |
Especially suited for use with FileSelectionTree. |
|
65 |
||
2037 | 66 |
[class variables:] |
67 |
ReadDirectoriesForIndicator <Boolean> if true, the directories are searched |
|
68 |
for subdirectories to update the |
|
69 |
indicator; on auto mounted file systems |
|
70 |
this would take a very long time!!!! |
|
2805 | 71 |
therefore the default is set to false. |
2037 | 72 |
|
486 | 73 |
[Author:] |
74 |
Claus Atzkern |
|
75 |
||
76 |
[See also:] |
|
77 |
TreeItem |
|
78 |
FileSelectionTree |
|
79 |
" |
|
80 |
! ! |
|
81 |
||
2037 | 82 |
!FileSelectionItem class methodsFor:'initialization'! |
83 |
||
84 |
initialize |
|
85 |
ReadDirectoriesForIndicator := false. |
|
86 |
! ! |
|
87 |
||
486 | 88 |
!FileSelectionItem class methodsFor:'instance creation'! |
89 |
||
90 |
pathName:aPath |
|
91 |
"create a new node entry associated with the full pathname, aPath |
|
92 |
" |
|
93 |
|node| |
|
94 |
||
95 |
node := self new. |
|
96 |
node pathName:aPath. |
|
97 |
^ node |
|
98 |
||
99 |
||
100 |
! ! |
|
101 |
||
102 |
!FileSelectionItem class methodsFor:'accessing class'! |
|
103 |
||
731 | 104 |
filterClassForDirectoriesOnly |
486 | 105 |
^ Directory |
106 |
! |
|
107 |
||
731 | 108 |
filterClassForFilesOnly |
486 | 109 |
^ File |
110 |
! ! |
|
111 |
||
112 |
!FileSelectionItem class methodsFor:'converting'! |
|
113 |
||
114 |
asFilename:aPathname |
|
115 |
"convert pathname to an absolute path |
|
116 |
" |
|
117 |
|path| |
|
118 |
||
119 |
path := aPathname asString. |
|
120 |
||
121 |
(path size > 1 and:[path endsWith:(Filename separator)]) ifTrue:[ |
|
4211
c553f879beac
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
2929
diff
changeset
|
122 |
^ (path copyButLast:1) asFilename. |
486 | 123 |
]. |
124 |
^ aPathname asFilename |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
125 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
126 |
"Modified: / 24.9.1998 / 15:33:50 / cg" |
486 | 127 |
! ! |
128 |
||
786 | 129 |
!FileSelectionItem class methodsFor:'default icons'! |
486 | 130 |
|
786 | 131 |
keysAndIcons |
486 | 132 |
"returns an IdentityDictionary containing a list of images and keys used |
133 |
by any file entry. |
|
134 |
" |
|
135 |
|icons image| |
|
136 |
||
137 |
icons := IdentityDictionary new. |
|
138 |
||
139 |
#( |
|
140 |
(#directory 'tiny_yellow_dir.xpm') |
|
141 |
(#directoryOpened 'tiny_yellow_dir_open.xpm') |
|
142 |
(#directoryLocked 'tiny_yellow_dir_locked.xpm') |
|
143 |
(#directoryLink 'tiny_yellow_dir_link.xpm' ) |
|
144 |
||
145 |
(#file 'tiny_file_plain.xpm' ) |
|
146 |
(#fileLink 'tiny_file_link.xpm' ) |
|
147 |
(#fileLocked 'tiny_file_lock.xpm' ) |
|
148 |
(#imageFile 'tiny_file_pix.xpm' ) |
|
149 |
||
150 |
) do:[:el | |
|
151 |
image := Image fromFile:('xpmBitmaps/document_images/', el last ). |
|
786 | 152 |
|
569 | 153 |
image notNil ifTrue:[ |
154 |
icons at:(el first) put:image. |
|
155 |
] |
|
486 | 156 |
]. |
157 |
^ icons |
|
158 |
||
159 |
||
160 |
! ! |
|
161 |
||
162 |
!FileSelectionItem methodsFor:'accessing'! |
|
163 |
||
164 |
children |
|
165 |
"get's list of children |
|
166 |
" |
|
786 | 167 |
readChildren ifTrue:[ |
569 | 168 |
children := self readInChildren |
486 | 169 |
]. |
170 |
^ children |
|
171 |
! |
|
172 |
||
811 | 173 |
fileName |
174 |
"returns the fileName of node |
|
175 |
" |
|
176 |
^ contents |
|
177 |
||
178 |
||
179 |
||
180 |
! |
|
181 |
||
786 | 182 |
icon |
569 | 183 |
"returns type of image to be drawn |
184 |
" |
|
185 |
(children size ~~ 0 and:[hide == false]) ifTrue:[ |
|
186 |
^ #directoryOpened |
|
187 |
]. |
|
188 |
^ self imageType |
|
189 |
! |
|
190 |
||
191 |
match:aOneArgBlock |
|
192 |
||
193 |
aOneArgBlock isNil ifTrue:[ |
|
194 |
self discardFiles ifTrue:[ |
|
195 |
matchAction := [:aFile :isDirectory| isDirectory ] |
|
196 |
] ifFalse:[ |
|
197 |
self discardDirectories ifTrue:[ |
|
198 |
matchAction := [:aFile :isDirectory| isDirectory not ] |
|
199 |
] ifFalse:[ |
|
200 |
matchAction := [:aFile :isDir| true ] |
|
201 |
] |
|
202 |
] |
|
203 |
] ifFalse:[ |
|
204 |
self discardFiles ifTrue:[ |
|
205 |
matchAction := [:aFile :isDirectory| (isDirectory and:[aOneArgBlock value:aFile]) ] |
|
206 |
] ifFalse:[ |
|
207 |
self discardDirectories ifTrue:[ |
|
208 |
matchAction := [:aFile :isDirectory| (isDirectory not and:[aOneArgBlock value:aFile]) ] |
|
209 |
] ifFalse:[ |
|
210 |
matchAction := [:aFile :isDir| aOneArgBlock value:aFile ] |
|
211 |
] |
|
212 |
] |
|
213 |
] |
|
214 |
! |
|
215 |
||
486 | 216 |
pathName |
217 |
"returns full pathname of node |
|
218 |
" |
|
569 | 219 |
^ contents asString |
486 | 220 |
|
221 |
||
222 |
! |
|
223 |
||
224 |
pathName:aPathname |
|
225 |
"initialze attributes associated with the full pathname, aPathname |
|
226 |
" |
|
569 | 227 |
|file| |
228 |
||
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
229 |
"/ file := self class asFilename:aPathname. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
230 |
file := aPathname asFilename pathName asFilename. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
231 |
self |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
232 |
fileName:file |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
233 |
baseName:(file baseName) |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
234 |
parent:nil |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
235 |
isDirectory:(file isDirectory) |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
236 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
237 |
"Modified: / 24.9.1998 / 16:02:53 / cg" |
569 | 238 |
! ! |
239 |
||
1818 | 240 |
!FileSelectionItem methodsFor:'accessing-hierarchy'! |
569 | 241 |
|
242 |
collapse |
|
811 | 243 |
"check to release children |
569 | 244 |
" |
811 | 245 |
self stopIndicatorValidation. |
569 | 246 |
hide := true. |
486 | 247 |
|
811 | 248 |
children notEmpty ifTrue:[ |
569 | 249 |
children do:[:aChild| |
811 | 250 |
aChild releaseCollapsedChildren ifFalse:[ ^ self ] |
569 | 251 |
]. |
811 | 252 |
self canReleaseChildren ifTrue:[ |
253 |
self releaseChildren |
|
569 | 254 |
] |
255 |
] |
|
811 | 256 |
|
569 | 257 |
! |
258 |
||
259 |
collapseAll |
|
260 |
"release my childrens |
|
261 |
" |
|
811 | 262 |
self stopIndicatorValidation. |
569 | 263 |
hide := true. |
264 |
||
811 | 265 |
children notEmpty ifTrue:[ |
266 |
self canReleaseChildren ifTrue:[ |
|
267 |
self releaseChildren |
|
569 | 268 |
] ifFalse:[ |
811 | 269 |
children do:[:c| c releaseChildren ] |
569 | 270 |
] |
486 | 271 |
]. |
811 | 272 |
|
844 | 273 |
! |
274 |
||
275 |
expandAll |
|
276 |
"not allowed for a file directory |
|
277 |
" |
|
278 |
self expand |
|
486 | 279 |
! ! |
280 |
||
2037 | 281 |
!FileSelectionItem methodsFor:'change & update'! |
282 |
||
283 |
changedSelected |
|
284 |
"called if the node is selected |
|
285 |
" |
|
286 |
|model| |
|
287 |
||
288 |
(showIndicator isNil and:[ReadDirectoriesForIndicator not]) ifTrue:[ |
|
289 |
model := self model. |
|
290 |
||
291 |
model notNil ifTrue:[ |
|
292 |
model startIndicatorValidationFor:self |
|
293 |
] |
|
294 |
]. |
|
295 |
! ! |
|
296 |
||
569 | 297 |
!FileSelectionItem methodsFor:'private'! |
486 | 298 |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
299 |
childFileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool matchAction:mA |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
300 |
"initialze attributes associated with the full pathname, aPathname. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
301 |
Same as #fileName:baseName:parent:isDirectory:, |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
302 |
but used only for children (i.e. no need to check for |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
303 |
being a rootDirectory). |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
304 |
" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
305 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
306 |
contents := aFilename. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
307 |
name := aBaseName. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
308 |
parent := aParent. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
309 |
isDirectory := readChildren := aBool. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
310 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
311 |
isDirectory ifFalse:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
312 |
showIndicator := false |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
313 |
] ifTrue:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
314 |
showIndicator := nil |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
315 |
]. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
316 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
317 |
matchAction := mA |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
318 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
319 |
"Modified: / 24.9.1998 / 14:10:38 / cg" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
320 |
"Created: / 24.9.1998 / 15:51:58 / cg" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
321 |
! |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
322 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
323 |
directoryIsLocked |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
324 |
^ self imageType == #directoryLocked |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
325 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
326 |
"Created: / 24.9.1998 / 14:22:08 / cg" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
327 |
! |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
328 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
329 |
fileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool |
569 | 330 |
"initialze attributes associated with the full pathname, aPathname |
486 | 331 |
" |
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
332 |
|f| |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
333 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
334 |
contents := aFilename. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
335 |
(f := aFilename asFilename) isRootDirectory ifTrue:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
336 |
name := f name. |
1144 | 337 |
"/ (name endsWith:Filename separator) ifTrue:[ |
338 |
"/ name ~= Filename separator asString ifTrue:[ |
|
339 |
"/ name := name copyWithoutLast:1. |
|
340 |
"/ ] |
|
341 |
"/ ] |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
342 |
] ifFalse:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
343 |
name := aBaseName. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
344 |
]. |
569 | 345 |
parent := aParent. |
786 | 346 |
isDirectory := readChildren := aBool. |
486 | 347 |
|
569 | 348 |
isDirectory ifFalse:[ |
349 |
showIndicator := false |
|
350 |
] ifTrue:[ |
|
351 |
showIndicator := nil |
|
352 |
]. |
|
353 |
||
354 |
parent notNil ifTrue:[ |
|
355 |
matchAction := parent matchAction "/ same as from parent |
|
356 |
] ifFalse:[ |
|
357 |
self match:nil "/ setup matchAction new |
|
358 |
] |
|
486 | 359 |
|
1144 | 360 |
"Modified: / 24.9.1998 / 19:19:57 / cg" |
486 | 361 |
! |
362 |
||
569 | 363 |
matchAction |
364 |
"returns my match action |
|
486 | 365 |
" |
569 | 366 |
^ matchAction |
811 | 367 |
! |
368 |
||
369 |
releaseChildren |
|
370 |
"release my childrens without tests and deregistration from |
|
371 |
update task |
|
372 |
" |
|
373 |
hide := true. |
|
374 |
readChildren := true. |
|
375 |
modificationTime := nil. |
|
376 |
children := OrderedCollection new. |
|
377 |
||
378 |
||
379 |
! |
|
380 |
||
381 |
stopIndicatorValidation |
|
382 |
"called to stop indicator validation on each child |
|
383 |
" |
|
384 |
|model| |
|
385 |
||
386 |
(hide or:[children isEmpty]) ifFalse:[ |
|
387 |
(model := self model) notNil ifTrue:[ |
|
388 |
children do:[:c| c stopIndicatorValidation:model ]. |
|
389 |
model stopIndicatorValidationFor:children |
|
390 |
] |
|
391 |
] |
|
392 |
||
393 |
||
394 |
! |
|
395 |
||
396 |
stopIndicatorValidation:aModel |
|
397 |
"called to stop indicator validation on each child |
|
398 |
" |
|
399 |
(hide or:[children isEmpty]) ifFalse:[ |
|
400 |
children do:[:c| c stopIndicatorValidation:aModel ]. |
|
401 |
aModel stopIndicatorValidationFor:children |
|
402 |
] |
|
403 |
||
404 |
||
486 | 405 |
! ! |
406 |
||
901 | 407 |
!FileSelectionItem methodsFor:'protected'! |
408 |
||
409 |
isVisibleFile:aFilename isDirectory:isDirectory baseName:aBasename |
|
410 |
^ matchAction value:aFilename value:isDirectory |
|
411 |
! ! |
|
412 |
||
486 | 413 |
!FileSelectionItem methodsFor:'queries'! |
414 |
||
811 | 415 |
canReleaseChildren |
416 |
"returns true if children could be released |
|
417 |
" |
|
418 |
^ (parent notNil and:[parent parent notNil]) |
|
419 |
||
420 |
||
421 |
! |
|
422 |
||
2037 | 423 |
defaultShowSeparator |
424 |
"returns true if the separator is shown if the contents |
|
425 |
from the directory is not yet read |
|
426 |
" |
|
427 |
^ ReadDirectoriesForIndicator not |
|
428 |
! |
|
429 |
||
569 | 430 |
discardDirectories |
431 |
"returns true if children are not type of directory; could be |
|
432 |
reimplemented for speed in any subclass |
|
433 |
" |
|
434 |
^ false |
|
435 |
! |
|
436 |
||
437 |
discardFiles |
|
438 |
"returns true if children are not type of file; could be |
|
439 |
reimplemented for speed in any subclass |
|
440 |
" |
|
441 |
^ false |
|
442 |
! |
|
443 |
||
486 | 444 |
hasChildren |
445 |
"returns true if the pathname assigned to this node is a directory |
|
446 |
otherwise false |
|
447 |
" |
|
569 | 448 |
^ isDirectory |
486 | 449 |
|
450 |
! |
|
451 |
||
811 | 452 |
hasValidIndicator |
453 |
"returns true if indication flag is uptodate |
|
454 |
" |
|
2037 | 455 |
|model| |
456 |
||
457 |
showIndicator notNil ifTrue:[ |
|
458 |
^ true |
|
459 |
]. |
|
460 |
ReadDirectoriesForIndicator ifTrue:[ |
|
461 |
^ false |
|
462 |
]. |
|
811 | 463 |
|
2037 | 464 |
model := self model. |
465 |
||
466 |
model isNil ifTrue:[ |
|
467 |
^ true "/ oops, no model exist |
|
468 |
]. |
|
469 |
||
470 |
model selectedNode == self ifTrue:[ |
|
471 |
^ false "/ i'am selected, update indicator |
|
472 |
]. |
|
473 |
^ true |
|
811 | 474 |
! |
475 |
||
486 | 476 |
isDirectory |
477 |
^ isDirectory |
|
478 |
! |
|
479 |
||
569 | 480 |
releaseCollapsedChildren |
481 |
"release collapsed children |
|
482 |
" |
|
1269 | 483 |
|canCollapse| |
569 | 484 |
|
811 | 485 |
children isEmpty ifTrue:[ |
569 | 486 |
^ true |
487 |
]. |
|
488 |
canCollapse := true. |
|
489 |
||
490 |
children do:[:aChild| |
|
491 |
aChild releaseCollapsedChildren ifFalse:[ |
|
492 |
canCollapse := false |
|
493 |
] |
|
494 |
]. |
|
811 | 495 |
|
569 | 496 |
(canCollapse and:[self isExpandable]) ifTrue:[ |
811 | 497 |
self canReleaseChildren ifTrue:[ |
498 |
self releaseChildren. |
|
569 | 499 |
^ true. |
500 |
] |
|
501 |
]. |
|
502 |
^ false |
|
811 | 503 |
|
504 |
! |
|
505 |
||
506 |
setShowIndicator:aBool |
|
507 |
"set indication; raise no change notification |
|
508 |
" |
|
509 |
showIndicator := aBool. |
|
569 | 510 |
! |
511 |
||
512 |
showIndicator |
|
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
513 |
"returns true if the node is a non-empty directory. |
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
514 |
This information is gathered lazily: first, false is |
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
515 |
returned and indicatorValidation is started for mySelf; |
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
516 |
this will read directories in the background to avoid |
2805 | 517 |
long startup delays (of my treeView)" |
518 |
||
811 | 519 |
|model| |
520 |
||
569 | 521 |
showIndicator isNil ifTrue:[ |
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
522 |
self directoryIsLocked ifTrue:[ |
786 | 523 |
showIndicator := readChildren := false. |
569 | 524 |
] ifFalse:[ |
811 | 525 |
(model := self model) notNil ifTrue:[ |
2037 | 526 |
ReadDirectoriesForIndicator ifFalse:[ |
527 |
^ true |
|
528 |
]. |
|
811 | 529 |
model startIndicatorValidationFor:self. |
530 |
]. |
|
531 |
^ false |
|
569 | 532 |
] |
533 |
]. |
|
534 |
^ showIndicator |
|
811 | 535 |
! |
536 |
||
537 |
showIndicator:aBool |
|
538 |
"indication might change; raise a change notification |
|
539 |
" |
|
2037 | 540 |
|oldState| |
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
541 |
|
2037 | 542 |
(oldState := showIndicator) isNil ifTrue:[ |
543 |
oldState := self defaultShowSeparator |
|
544 |
]. |
|
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
545 |
showIndicator := aBool. |
2037 | 546 |
|
547 |
oldState ~~ aBool ifTrue:[ |
|
548 |
self changed |
|
811 | 549 |
]. |
550 |
||
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
551 |
"Modified: / 28.9.1998 / 11:14:30 / cg" |
569 | 552 |
! ! |
553 |
||
554 |
!FileSelectionItem methodsFor:'repair mechanism'! |
|
555 |
||
556 |
hasObsoleteNodes |
|
557 |
"check whether node or any child node is obsolete |
|
486 | 558 |
" |
569 | 559 |
modificationTime notNil ifTrue:[ |
560 |
modificationTime < contents modificationTime ifTrue:[ |
|
561 |
^ true |
|
562 |
]. |
|
2929 | 563 |
self discardDirectories ifFalse:[ |
564 |
(children contains:[:aChild | aChild hasObsoleteNodes]) ifTrue:[^ true]. |
|
569 | 565 |
] |
566 |
]. |
|
567 |
^ false |
|
568 |
! |
|
569 |
||
570 |
repairObsoleteNodes |
|
571 |
"repair nodes |
|
572 |
" |
|
1269 | 573 |
|list hasChanged| |
569 | 574 |
|
575 |
modificationTime isNil ifTrue:[ |
|
576 |
^ false |
|
493 | 577 |
]. |
569 | 578 |
|
579 |
modificationTime < contents modificationTime ifTrue:[ |
|
580 |
list := self readInChildren. |
|
581 |
hasChanged := list size ~~ children size. |
|
582 |
||
583 |
children do:[:aChild||i| |
|
584 |
i := list findFirst:[:f| f name = aChild name ]. |
|
585 |
||
586 |
i ~~ 0 ifTrue:[ |
|
587 |
list at:i put:aChild |
|
588 |
] ifFalse:[ |
|
589 |
hasChanged := true |
|
590 |
]. |
|
591 |
]. |
|
592 |
hasChanged ifTrue:[ |
|
811 | 593 |
self stopIndicatorValidation. |
569 | 594 |
children := list |
595 |
] |
|
596 |
] ifFalse:[ |
|
597 |
hasChanged := false |
|
598 |
]. |
|
599 |
children size ~~ 0 ifTrue:[ |
|
600 |
children do:[:aChild| |
|
601 |
(aChild repairObsoleteNodes) ifTrue:[hasChanged := true] |
|
602 |
] |
|
603 |
]. |
|
604 |
^ self shown ifTrue:[hasChanged] |
|
605 |
ifFalse:[false] |
|
486 | 606 |
|
811 | 607 |
|
486 | 608 |
! ! |
609 |
||
610 |
!FileSelectionItem methodsFor:'update'! |
|
611 |
||
569 | 612 |
imageType |
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
613 |
"return my icon-image type - a symbol" |
569 | 614 |
|
615 |
|readable| |
|
616 |
||
617 |
imageType isNil ifTrue:[ |
|
618 |
readable := contents isReadable. |
|
486 | 619 |
|
569 | 620 |
isDirectory ifTrue:[ |
621 |
(readable and:[contents isExecutable]) ifTrue:[ |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
622 |
contents isSymbolicLink |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
623 |
ifFalse:[imageType := #directory] |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
624 |
ifTrue:[imageType := #directoryLink] |
569 | 625 |
] ifFalse:[ |
626 |
imageType := #directoryLocked |
|
627 |
] |
|
628 |
] ifFalse:[ |
|
629 |
readable ifFalse:[ |
|
630 |
imageType := #fileLocked |
|
631 |
] ifTrue:[ |
|
632 |
contents isSymbolicLink ifFalse:[ |
|
633 |
(Image isImageFileSuffix:(contents suffix)) ifFalse:[ |
|
634 |
imageType := #file |
|
635 |
] ifTrue:[ |
|
636 |
imageType := #imageFile |
|
637 |
] |
|
638 |
] ifTrue:[ |
|
639 |
imageType := #fileLink |
|
640 |
] |
|
486 | 641 |
] |
642 |
] |
|
643 |
]. |
|
569 | 644 |
^ imageType |
486 | 645 |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
646 |
"Modified: / 24.9.1998 / 15:47:38 / cg" |
486 | 647 |
! |
648 |
||
569 | 649 |
readInChildren |
650 |
"read children from directory |
|
486 | 651 |
" |
1269 | 652 |
|list directory| |
569 | 653 |
|
654 |
list := OrderedCollection new. |
|
811 | 655 |
readChildren := false. |
2037 | 656 |
showIndicator := self defaultShowSeparator. |
569 | 657 |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
658 |
self directoryIsLocked ifFalse:[ |
1141 | 659 |
Cursor read showWhile:[ |
811 | 660 |
directory := DirectoryContents directoryNamed:contents. |
569 | 661 |
|
811 | 662 |
directory isNil ifTrue:[ |
663 |
self stopIndicatorValidation. |
|
664 |
self releaseChildren. |
|
665 |
imageType := #directoryLocked. |
|
666 |
] ifFalse:[ |
|
667 |
modificationTime := directory modificationTime. |
|
668 |
||
901 | 669 |
directory contentsAndBaseNamesDo:[:file :bname :isDir| |
670 |
(self isVisibleFile:file isDirectory:isDir baseName:bname) ifTrue:[ |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
671 |
list add:(self class new |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
672 |
childFileName:file |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
673 |
baseName:bname |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
674 |
parent:self |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
675 |
isDirectory:isDir |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
676 |
matchAction:matchAction) |
811 | 677 |
] |
678 |
]. |
|
679 |
showIndicator := list size ~~ 0. |
|
486 | 680 |
] |
569 | 681 |
] |
486 | 682 |
]. |
2422 | 683 |
list sort:[:a :b | a fileName name < b fileName name]. |
684 |
^ list |
|
811 | 685 |
|
1141 | 686 |
"Modified: / 24.9.1998 / 17:51:48 / cg" |
486 | 687 |
! ! |
688 |
||
689 |
!FileSelectionItem::Directory class methodsFor:'documentation'! |
|
690 |
||
691 |
documentation |
|
692 |
" |
|
693 |
subtype of FileSelectionItem only showing directories; more an example to show |
|
694 |
how to implement filters |
|
695 |
||
696 |
[Author:] |
|
697 |
Claus Atzkern |
|
698 |
||
699 |
[See also:] |
|
700 |
FileSelectionItem |
|
701 |
" |
|
702 |
||
703 |
! ! |
|
704 |
||
569 | 705 |
!FileSelectionItem::Directory methodsFor:'queries'! |
486 | 706 |
|
569 | 707 |
discardFiles |
708 |
^ true |
|
486 | 709 |
! ! |
710 |
||
711 |
!FileSelectionItem::File class methodsFor:'documentation'! |
|
712 |
||
713 |
documentation |
|
714 |
" |
|
715 |
subtype of FileSelectionItem only showing files; more an example to show |
|
716 |
how to implement filters |
|
717 |
||
718 |
[Author:] |
|
719 |
Claus Atzkern |
|
720 |
||
721 |
[See also:] |
|
722 |
FileSelectionItem |
|
723 |
" |
|
724 |
||
725 |
||
726 |
! ! |
|
727 |
||
569 | 728 |
!FileSelectionItem::File methodsFor:'queries'! |
486 | 729 |
|
569 | 730 |
discardDirectories |
731 |
^ true |
|
486 | 732 |
|
733 |
||
734 |
! ! |
|
735 |
||
736 |
!FileSelectionItem class methodsFor:'documentation'! |
|
737 |
||
738 |
version |
|
4211
c553f879beac
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
2929
diff
changeset
|
739 |
^ '$Header: /cvs/stx/stx/libwidg2/FileSelectionItem.st,v 1.22 2013-04-25 13:12:17 stefan Exp $' |
486 | 740 |
! ! |
2422 | 741 |
|
4211
c553f879beac
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
2929
diff
changeset
|
742 |
|
2037 | 743 |
FileSelectionItem initialize! |