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