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