9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 SelectionInListView subclass:#FileSelectionList |
13 SelectionInListView subclass:#FileSelectionList |
14 instanceVariableNames:'pattern directory timeStamp directoryId directoryContents |
14 instanceVariableNames:'pattern directory timeStamp directoryId directoryContents |
15 directoryFileTypes fileTypes realAction matchBlock |
15 directoryFileTypes fileTypes realAction matchBlock |
16 stayInDirectory ignoreParentDirectory' |
16 stayInDirectory ignoreParentDirectory markDirectories' |
17 classVariableNames:'' |
17 classVariableNames:'' |
18 poolDictionaries:'' |
18 poolDictionaries:'' |
19 category:'Views-Text' |
19 category:'Views-Text' |
20 ! |
20 ! |
21 |
21 |
22 !FileSelectionList class methodsFor:'documentation'! |
22 !FileSelectionList class methodsFor:'documentation'! |
23 |
23 |
24 copyright |
24 copyright |
261 is shown in the list. The default is false (i.e. show it)" |
257 is shown in the list. The default is false (i.e. show it)" |
262 |
258 |
263 ignoreParentDirectory := aBoolean |
259 ignoreParentDirectory := aBoolean |
264 ! |
260 ! |
265 |
261 |
|
262 markDirectories:aBoolean |
|
263 "turn on/off marking of directories with an arrow. |
|
264 The default is on" |
|
265 |
|
266 markDirectories := aBoolean |
|
267 ! |
|
268 |
266 matchBlock:aBlock |
269 matchBlock:aBlock |
267 "set the matchBlock - if non-nil, it controls which |
270 "set the matchBlock - if non-nil, it controls which |
268 names are shown in the list." |
271 names are shown in the list." |
269 |
272 |
270 matchBlock := aBlock |
273 matchBlock := aBlock |
309 |
312 |
310 |l| |
313 |l| |
311 |
314 |
312 "first, draw chunk of lines" |
315 "first, draw chunk of lines" |
313 super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. |
316 super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. |
|
317 markDirectories ifFalse:[^ self]. |
314 |
318 |
315 "then draw marks" |
319 "then draw marks" |
316 startVisLineNr to:endVisLineNr do:[:visLineNr | |
320 startVisLineNr to:endVisLineNr do:[:visLineNr | |
317 l := self visibleLineToListLine:visLineNr. |
321 l := self visibleLineToListLine:visLineNr. |
318 l notNil ifTrue:[ |
322 l notNil ifTrue:[ |
319 (fileTypes at:l) == #directory ifTrue:[ |
323 (fileTypes at:l) == #directory ifTrue:[ |
320 self drawRightArrowInVisibleLine:visLineNr |
324 self drawRightArrowInVisibleLine:visLineNr |
321 ] |
325 ] |
322 ] |
326 ] |
323 ] |
327 ] |
324 ! |
328 ! |
325 |
329 |
326 redrawVisibleLine:visLineNr |
330 redrawVisibleLine:visLineNr |
327 "if the line is one for a directory, draw a right arrow" |
331 "if the line is one for a directory, draw a right arrow" |
328 |
332 |
329 |l| |
333 |l| |
330 |
334 |
331 super redrawVisibleLine:visLineNr. |
335 super redrawVisibleLine:visLineNr. |
|
336 markDirectories ifFalse:[^ self]. |
|
337 |
332 l := self visibleLineToListLine:visLineNr. |
338 l := self visibleLineToListLine:visLineNr. |
333 l notNil ifTrue:[ |
339 l notNil ifTrue:[ |
334 (fileTypes at:l) == #directory ifTrue:[ |
340 (fileTypes at:l) == #directory ifTrue:[ |
335 self drawRightArrowInVisibleLine:visLineNr |
341 self drawRightArrowInVisibleLine:visLineNr |
336 ] |
342 ] |
337 ] |
343 ] |
338 ! ! |
344 ! ! |
339 |
345 |
340 !FileSelectionList methodsFor:'initialization'! |
346 !FileSelectionList methodsFor:'initialization'! |
341 |
347 |
342 initialize |
348 initialize |
343 directory := FileDirectory currentDirectory. |
349 directory := FileDirectory currentDirectory. |
344 stayInDirectory := false. |
350 stayInDirectory := false. |
345 ignoreParentDirectory := false. |
351 ignoreParentDirectory := false. |
346 |
352 markDirectories := true. |
347 super initialize. |
353 super initialize. |
348 |
354 |
349 pattern := '*'. |
355 pattern := '*'. |
350 self initializeAction. |
356 self initializeAction. |
351 |
357 |
361 initializeAction |
367 initializeAction |
362 "setup action as: selections in list get forwarded to enterfield if not |
368 "setup action as: selections in list get forwarded to enterfield if not |
363 a directory; otherwise directory is changed" |
369 a directory; otherwise directory is changed" |
364 |
370 |
365 actionBlock := [:lineNr | |
371 actionBlock := [:lineNr | |
366 |entry ok| |
372 |entry ok| |
367 |
373 |
368 self selection isCollection ifFalse:[ |
374 self selection isCollection ifFalse:[ |
369 entry := self selectionValue. |
375 entry := self selectionValue. |
370 (entry endsWith:' ...') ifTrue:[ |
376 (entry endsWith:' ...') ifTrue:[ |
371 entry := entry copyWithoutLast:4 "copyTo:(entry size - 4)". |
377 entry := entry copyWithoutLast:4 "copyTo:(entry size - 4)". |
372 ]. |
378 ]. |
373 (stayInDirectory not |
379 (stayInDirectory not |
374 and:[(directory typeOf:entry) == #directory]) ifTrue:[ |
380 and:[(directory typeOf:entry) == #directory]) ifTrue:[ |
375 ok := false. |
381 ok := false. |
376 (directory isReadable:entry) ifFalse:[ |
382 (directory isReadable:entry) ifFalse:[ |
377 self warn:(resources string:'not allowed to read directory %1' with:entry) |
383 self warn:(resources string:'not allowed to read directory %1' with:entry) |
378 ] ifTrue:[ |
384 ] ifTrue:[ |
379 (directory isExecutable:entry) ifFalse:[ |
385 (directory isExecutable:entry) ifFalse:[ |
380 self warn:(resources string:'not allowed to change to directory %1' with:entry) |
386 self warn:(resources string:'not allowed to change to directory %1' with:entry) |
381 ] ifTrue:[ |
387 ] ifTrue:[ |
382 self directory:(directory pathName , Filename separator asString , entry). |
388 self directory:(directory pathName , Filename separator asString , entry). |
383 ok := true. |
389 ok := true. |
384 ] |
390 ] |
385 ]. |
391 ]. |
386 ok ifFalse:[ |
392 ok ifFalse:[ |
387 self deselect |
393 self deselect |
388 ] |
394 ] |
389 |
395 |
390 ] ifFalse:[ |
396 ] ifFalse:[ |
391 realAction notNil ifTrue:[ |
397 realAction notNil ifTrue:[ |
392 realAction value:lineNr |
398 realAction value:lineNr |
393 ] |
399 ] |
394 ] |
400 ] |
395 ] |
401 ] |
396 ] |
402 ] |
397 ! |
403 ! |
398 |
404 |
399 reinitialize |
405 reinitialize |
400 directory := FileDirectory currentDirectory. |
406 directory := FileDirectory currentDirectory. |