411 !FileSelectionList methodsFor:'private'! |
411 !FileSelectionList methodsFor:'private'! |
412 |
412 |
413 updateList |
413 updateList |
414 "set the lists contents to the filenames in the directory" |
414 "set the lists contents to the filenames in the directory" |
415 |
415 |
416 |oldCursor files newList index path| |
416 |oldCursor files newList index path obsolete| |
417 |
417 |
418 directory isNil ifTrue:[ |
418 directory isNil ifTrue:[ |
419 super list:nil. |
419 super list:nil. |
420 files := newList := fileTypes := nil. |
420 files := newList := fileTypes := nil. |
421 ^ self |
421 ^ self |
422 ]. |
422 ]. |
423 |
423 |
424 oldCursor := cursor. |
424 oldCursor := cursor. |
425 self cursor:(Cursor read). |
425 self cursor:(Cursor read). |
426 |
426 |
427 " |
427 " |
428 if the directory-id changed, MUST update. |
428 if the directory-id changed, MUST update. |
429 (can happen after a restart, when a file is no longer |
429 (can happen after a restart, when a file is no longer |
430 there, has moved or is NFS-mounted differently) |
430 there, has moved or is NFS-mounted differently) |
431 " |
431 " |
432 (directoryId == directory id |
432 obsolete := directoryId ~~ directory id |
433 and:[directoryName = directory pathName]) ifFalse:[ |
433 or:[directoryName ~= directory pathName |
434 timeStamp := directory timeOfLastChange. |
434 or:[timeStamp notNil |
435 directoryId := directory id. |
435 and:[directory timeOfLastChange > timeStamp]]]. |
436 directoryName := directory pathName. |
436 |
437 directoryContents := directory asStringCollection sort. |
437 obsolete ifTrue:[ |
438 directoryFileTypes := OrderedCollection new. |
438 timeStamp := directory timeOfLastChange. |
439 directoryContents do:[:name | directoryFileTypes add:(directory typeOf:name)]. |
439 directoryId := directory id. |
|
440 directoryName := directory pathName. |
|
441 directoryContents := directory asStringCollection sort. |
|
442 directoryFileTypes := OrderedCollection new. |
|
443 directoryContents do:[:name | directoryFileTypes add:(directory typeOf:name)]. |
440 ]. |
444 ]. |
441 |
445 |
442 files := directoryContents. |
446 files := directoryContents. |
443 newList := OrderedCollection new. |
447 newList := OrderedCollection new. |
444 fileTypes := OrderedCollection new. |
448 fileTypes := OrderedCollection new. |
445 index := 1. |
449 index := 1. |
446 |
450 |
447 path := directory pathName , Filename separator asString. |
451 path := directory pathName , Filename separator asString. |
448 files do:[:name | |
452 files do:[:name | |
449 |type| |
453 |type| |
450 |
454 |
451 (matchBlock isNil or:[matchBlock value:(path , name)]) ifTrue:[ |
455 (matchBlock isNil or:[matchBlock value:(path , name)]) ifTrue:[ |
452 type := directoryFileTypes at:index. |
456 type := directoryFileTypes at:index. |
453 type == #directory ifTrue:[ |
457 type == #directory ifTrue:[ |
454 name = '..' ifTrue:[ |
458 name = '..' ifTrue:[ |
455 ignoreParentDirectory ifFalse:[ |
459 ignoreParentDirectory ifFalse:[ |
456 newList add:name. |
460 newList add:name. |
457 fileTypes add:type |
461 fileTypes add:type |
458 ] |
462 ] |
459 ] ifFalse:[ |
463 ] ifFalse:[ |
460 name = '.' ifTrue:[ |
464 name = '.' ifTrue:[ |
461 "ignore" |
465 "ignore" |
462 ] ifFalse:[ |
466 ] ifFalse:[ |
463 newList add:(name ", ' ...'"). |
467 newList add:(name ", ' ...'"). |
464 fileTypes add:type |
468 fileTypes add:type |
465 ] |
469 ] |
466 ] |
470 ] |
467 ] ifFalse:[ |
471 ] ifFalse:[ |
468 (pattern isNil |
472 (pattern isNil |
469 or:[pattern isEmpty |
473 or:[pattern isEmpty |
470 or:[pattern = '*' |
474 or:[pattern = '*' |
471 or:[pattern match:name]]]) ifTrue:[ |
475 or:[pattern match:name]]]) ifTrue:[ |
472 newList add:name. |
476 newList add:name. |
473 fileTypes add:type |
477 fileTypes add:type |
474 ] |
478 ] |
475 ]. |
479 ]. |
476 ]. |
480 ]. |
477 index := index + 1 |
481 index := index + 1 |
478 ]. |
482 ]. |
479 super list:newList. |
483 super list:newList. |
480 |
484 |
481 self cursor:oldCursor. |
485 self cursor:oldCursor. |
|
486 |
482 ! |
487 ! |
483 |
488 |
484 visibleLineNeedsSpecialCare:visLineNr |
489 visibleLineNeedsSpecialCare:visLineNr |
485 |l| |
490 |l| |
486 |
491 |