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