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