FileSelectionList.st
changeset 1687 bf72059725a1
parent 1445 2c717104c3fb
child 1690 77d381b11f95
equal deleted inserted replaced
1686:12619751ba2c 1687:bf72059725a1
    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
    15 		directoryContents directoryFileTypes realAction matchBlock
    16 		matchBlock stayInDirectory ignoreParentDirectory markDirectories
    16 		stayInDirectory ignoreParentDirectory markDirectories
    17 		ignoreDirectories directoryChangeCheckBlock quickDirectoryChange
    17 		ignoreDirectories directoryChangeCheckBlock quickDirectoryChange
    18 		directoryChangeAction directorySelectAction fileSelectAction
    18 		directoryChangeAction directorySelectAction fileSelectAction
    19 		ignoreFiles directoryHolder'
    19 		ignoreFiles directoryHolder'
    20 	classVariableNames:''
    20 	classVariableNames:''
    21 	poolDictionaries:''
    21 	poolDictionaries:''
   668     super redrawFromVisibleLine:startVisLineNr to:endVisLineNr.
   668     super redrawFromVisibleLine:startVisLineNr to:endVisLineNr.
   669     markDirectories ifFalse:[^ self].
   669     markDirectories ifFalse:[^ self].
   670 
   670 
   671     "then draw marks"
   671     "then draw marks"
   672     startVisLineNr to:endVisLineNr do:[:visLineNr |
   672     startVisLineNr to:endVisLineNr do:[:visLineNr |
   673 	l := self visibleLineToListLine:visLineNr.
   673         l := self visibleLineToListLine:visLineNr.
   674 	l notNil ifTrue:[
   674         l notNil ifTrue:[
   675 	    (fileTypes at:l) == #directory ifTrue:[
   675             (directoryFileTypes at:l) == true ifTrue:[
   676 		self drawRightArrowInVisibleLine:visLineNr
   676                 self drawRightArrowInVisibleLine:visLineNr
   677 	    ]
   677             ]
   678 	]
   678         ]
   679     ]
   679     ]
       
   680 
       
   681     "Modified: / 22.9.1998 / 12:32:24 / cg"
   680 !
   682 !
   681 
   683 
   682 redrawVisibleLine:visLineNr
   684 redrawVisibleLine:visLineNr
   683     "if the line is one for a directory, draw a right arrow"
   685     "if the line is one for a directory, draw a right arrow"
   684 
   686 
   687     super redrawVisibleLine:visLineNr.
   689     super redrawVisibleLine:visLineNr.
   688     markDirectories ifFalse:[^ self].
   690     markDirectories ifFalse:[^ self].
   689 
   691 
   690     l := self visibleLineToListLine:visLineNr.
   692     l := self visibleLineToListLine:visLineNr.
   691     l notNil ifTrue:[
   693     l notNil ifTrue:[
   692 	(fileTypes at:l) == #directory ifTrue:[
   694         (directoryFileTypes at:l) == true ifTrue:[
   693 	    self drawRightArrowInVisibleLine:visLineNr
   695             self drawRightArrowInVisibleLine:visLineNr
   694 	]
   696         ]
   695     ]
   697     ]
       
   698 
       
   699     "Modified: / 22.9.1998 / 12:32:34 / cg"
   696 ! !
   700 ! !
   697 
   701 
   698 !FileSelectionList methodsFor:'events'!
   702 !FileSelectionList methodsFor:'events'!
   699 
   703 
   700 directoryHolderChange
   704 directoryHolderChange
   850     "Modified: 26.5.1996 / 15:03:21 / cg"
   854     "Modified: 26.5.1996 / 15:03:21 / cg"
   851     "Modified: 18.9.1997 / 23:34:39 / stefan"
   855     "Modified: 18.9.1997 / 23:34:39 / stefan"
   852 !
   856 !
   853 
   857 
   854 selectionIsDirectory
   858 selectionIsDirectory
       
   859     "return true, if the current selection is a directory"
       
   860 
   855     |entry|
   861     |entry|
   856 
   862 
   857     entry := self selectionValue.
   863     entry := self selectionValue.
   858     (entry isNil or:[entry isEmpty]) ifTrue:[ ^ false].
   864     (entry isNil or:[entry isEmpty]) ifTrue:[ ^ false].
   859 
   865 
   860     (entry endsWith:' ...') ifTrue:[
   866     (entry endsWith:' ...') ifTrue:[
   861         entry := entry copyWithoutLast:4.
   867         entry := entry copyWithoutLast:4.
   862     ].
   868     ].
   863     ^ (directory construct:entry) type == #directory
   869     ^ (directory construct:entry) isDirectory
   864 
   870 
   865     "Created: 4.3.1996 / 17:43:26 / cg"
   871     "Created: / 4.3.1996 / 17:43:26 / cg"
   866     "Modified: 18.9.1997 / 23:37:05 / stefan"
   872     "Modified: / 18.9.1997 / 23:37:05 / stefan"
       
   873     "Modified: / 22.9.1998 / 12:30:21 / cg"
   867 !
   874 !
   868 
   875 
   869 updateList
   876 updateList
   870     "set the lists contents to the filenames in the directory"
   877     "set the lists contents to the filenames in the directory"
   871 
   878 
   872     |oldCursor files newList index obsolete matching patternList dir|
   879     |oldCursor files newList index obsolete 
       
   880      matching patternList dir|
   873 
   881 
   874     directory isNil ifTrue:[
   882     directory isNil ifTrue:[
   875         super list:nil.
   883         super list:nil.
   876         files :=  newList := fileTypes := nil.
   884         files :=  newList := nil.
   877         ^ self
   885         ^ self
   878     ].
   886     ].
   879 
   887 
   880     oldCursor := cursor.
   888     oldCursor := cursor.
   881     self cursor:(Cursor read).
   889     self cursor:(Cursor read).
   893     obsolete ifTrue:[
   901     obsolete ifTrue:[
   894         timeStamp := directory modificationTime.
   902         timeStamp := directory modificationTime.
   895         directoryId := directory id.
   903         directoryId := directory id.
   896         directoryName := directory pathName.
   904         directoryName := directory pathName.
   897         directoryContents := directory fullDirectoryContents sort.
   905         directoryContents := directory fullDirectoryContents sort.
   898 
       
   899         directoryFileTypes := OrderedCollection new.
   906         directoryFileTypes := OrderedCollection new.
   900         directoryContents do:[:name | directoryFileTypes add:(directory construct:name)type].
   907         directoryContents do:[:name | 
       
   908             |f|
       
   909 
       
   910             f := directory construct:name.
       
   911             directoryFileTypes add:(f isDirectory)
       
   912         ].
   901     ].
   913     ].
   902 
   914 
   903     files := directoryContents.
   915     files := directoryContents.
   904     newList := OrderedCollection new.
   916     newList := OrderedCollection new.
   905     fileTypes := OrderedCollection new.
       
   906     index := 1.
   917     index := 1.
   907 
   918 
   908     dir := directory pathName asFilename.
   919     dir := directory pathName asFilename.
   909     files do:[:name |
   920     files do:[:name |
   910         |type fullName|
   921         |type fullName|
   911 
   922 
   912         fullName := dir constructString:name.
   923         fullName := dir constructString:name.
   913         (matchBlock isNil or:[matchBlock value:fullName]) ifTrue:[
   924         (matchBlock isNil or:[matchBlock value:fullName]) ifTrue:[
   914             type := directoryFileTypes at:index.
   925             (directoryFileTypes at:index) == true ifTrue:[
   915             type == #directory ifTrue:[
       
   916                 ignoreDirectories ifFalse:[
   926                 ignoreDirectories ifFalse:[
   917                     name = '..' ifTrue:[
   927                     name = '..' ifTrue:[
   918                         ignoreParentDirectory ifFalse:[
   928                         ignoreParentDirectory ifFalse:[
   919                             newList add:name.
   929                             newList add:name.
   920                             fileTypes add:type
       
   921                         ]
   930                         ]
   922                     ] ifFalse:[
   931                     ] ifFalse:[
   923                         name = '.' ifTrue:[
   932                         name = '.' ifTrue:[
   924                             "ignore"
   933                             "ignore"
   925                         ] ifFalse:[
   934                         ] ifFalse:[
   926                             newList add:(name ", ' ...'").
   935                             newList add:(name ", ' ...'").
   927                             fileTypes add:type
       
   928                         ]
   936                         ]
   929                     ]
   937                     ]
   930                 ]
   938                 ]
   931             ] ifFalse:[
   939             ] ifFalse:[
   932                 ignoreFiles ifFalse:[
   940                 ignoreFiles ifFalse:[
   944                         ]
   952                         ]
   945                     ].
   953                     ].
   946                                     
   954                                     
   947                     matching ifTrue:[
   955                     matching ifTrue:[
   948                         newList add:name.
   956                         newList add:name.
   949                         fileTypes add:type
       
   950                     ]
   957                     ]
   951                 ]
   958                 ]
   952             ].
   959             ].
   953         ].
   960         ].
   954         index := index + 1
   961         index := index + 1
   955     ].
   962     ].
   956     super list:newList.
   963     super list:newList.
   957 
   964 
   958     self cursor:oldCursor.
   965     self cursor:oldCursor.
   959 
   966 
   960     "Modified: 18.9.1997 / 23:43:52 / stefan"
   967     "Modified: / 18.9.1997 / 23:43:52 / stefan"
   961     "Modified: 20.9.1997 / 13:03:48 / cg"
   968     "Modified: / 22.9.1998 / 12:33:24 / cg"
   962 !
   969 !
   963 
   970 
   964 visibleLineNeedsSpecialCare:visLineNr
   971 visibleLineNeedsSpecialCare:visLineNr
   965     |l|
   972     |l|
   966 
   973 
   967     l := self visibleLineToListLine:visLineNr.
   974     l := self visibleLineToListLine:visLineNr.
   968     l notNil ifTrue:[
   975     l notNil ifTrue:[
   969 	(fileTypes at:l) == #directory ifTrue:[^ true].
   976         (directoryFileTypes at:l) == true ifTrue:[^ true].
   970 	^ super visibleLineNeedsSpecialCare:visLineNr
   977         ^ super visibleLineNeedsSpecialCare:visLineNr
   971     ].
   978     ].
   972     ^ false
   979     ^ false
       
   980 
       
   981     "Modified: / 22.9.1998 / 12:32:48 / cg"
   973 !
   982 !
   974 
   983 
   975 widthForScrollBetween:firstLine and:lastLine
   984 widthForScrollBetween:firstLine and:lastLine
   976     "return the width in pixels for a scroll between firstLine and lastLine
   985     "return the width in pixels for a scroll between firstLine and lastLine
   977      - return full width here since there might be directory marks"
   986      - return full width here since there might be directory marks"
  1000 ! !
  1009 ! !
  1001 
  1010 
  1002 !FileSelectionList class methodsFor:'documentation'!
  1011 !FileSelectionList class methodsFor:'documentation'!
  1003 
  1012 
  1004 version
  1013 version
  1005     ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.41 1998-02-05 22:52:55 cg Exp $'
  1014     ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.42 1998-09-22 11:17:04 cg Exp $'
  1006 ! !
  1015 ! !