FSelList.st
changeset 287 82691623dd4c
parent 285 e1f09d0f2c15
child 296 e1b9431b3aef
equal deleted inserted replaced
286:3ec5d73fdf54 287:82691623dd4c
     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 directoryName 
    14 	instanceVariableNames:'pattern directory timeStamp directoryId directoryName
    15 		directoryContents directoryFileTypes fileTypes realAction matchBlock
    15 		directoryContents directoryFileTypes fileTypes realAction
    16 		stayInDirectory ignoreParentDirectory markDirectories'
    16 		matchBlock stayInDirectory ignoreParentDirectory markDirectories'
    17 	classVariableNames:''
    17 	classVariableNames:''
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Views-Text'
    19 	category:'Views-Text'
    20 !
    20 !
    21 
    21 
   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 
   516 ! !
   521 ! !
   517 
   522 
   518 !FileSelectionList class methodsFor:'documentation'!
   523 !FileSelectionList class methodsFor:'documentation'!
   519 
   524 
   520 version
   525 version
   521     ^ '$Header: /cvs/stx/stx/libwidg/Attic/FSelList.st,v 1.18 1996-01-14 16:46:33 cg Exp $'
   526     ^ '$Header: /cvs/stx/stx/libwidg/Attic/FSelList.st,v 1.19 1996-01-15 22:14:28 ca Exp $'
   522 ! !
   527 ! !