FileSelectionItem.st
changeset 1139 465a6c941877
parent 901 0e090a691095
child 1141 6484e896b1df
equal deleted inserted replaced
1138:14dc9f6791d2 1139:465a6c941877
   106     |path|
   106     |path|
   107 
   107 
   108     path := aPathname asString.
   108     path := aPathname asString.
   109 
   109 
   110     (path size > 1 and:[path endsWith:(Filename separator)]) ifTrue:[
   110     (path size > 1 and:[path endsWith:(Filename separator)]) ifTrue:[
   111         ^ (path copyWithout:1) asFilename.
   111         ^ (path copyWithoutLast:1) asFilename.
   112     ].
   112     ].
   113   ^ aPathname asFilename
   113   ^ aPathname asFilename
       
   114 
       
   115     "Modified: / 24.9.1998 / 15:33:50 / cg"
   114 ! !
   116 ! !
   115 
   117 
   116 !FileSelectionItem class methodsFor:'default icons'!
   118 !FileSelectionItem class methodsFor:'default icons'!
   117 
   119 
   118 keysAndIcons
   120 keysAndIcons
   211 pathName:aPathname
   213 pathName:aPathname
   212     "initialze attributes associated with the full pathname, aPathname
   214     "initialze attributes associated with the full pathname, aPathname
   213     "
   215     "
   214     |file|
   216     |file|
   215 
   217 
   216     file := self class asFilename:aPathname.
   218 "/    file := self class asFilename:aPathname.
   217     self fileName:file baseName:(file baseName) parent:nil isDirectory:(file isDirectory)
   219     file := aPathname asFilename pathName asFilename.
       
   220     self 
       
   221         fileName:file 
       
   222         baseName:(file baseName) 
       
   223         parent:nil 
       
   224         isDirectory:(file isDirectory)
       
   225 
       
   226     "Modified: / 24.9.1998 / 16:02:53 / cg"
   218 ! !
   227 ! !
   219 
   228 
   220 !FileSelectionItem methodsFor:'accessing hierarchy'!
   229 !FileSelectionItem methodsFor:'accessing hierarchy'!
   221 
   230 
   222 collapse
   231 collapse
   258     self expand
   267     self expand
   259 ! !
   268 ! !
   260 
   269 
   261 !FileSelectionItem methodsFor:'private'!
   270 !FileSelectionItem methodsFor:'private'!
   262 
   271 
   263 fileName:aFilenname baseName:aBaseName parent:aParent isDirectory:aBool
   272 childFileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool matchAction:mA
       
   273     "initialze attributes associated with the full pathname, aPathname.
       
   274      Same as #fileName:baseName:parent:isDirectory:,
       
   275      but used only for children (i.e. no need to check for
       
   276      being a rootDirectory).
       
   277     "
       
   278     |f|
       
   279 
       
   280     contents    := aFilename.
       
   281     name        := aBaseName.
       
   282     parent      := aParent.
       
   283     isDirectory := readChildren := aBool.
       
   284 
       
   285     isDirectory ifFalse:[
       
   286         showIndicator := false
       
   287     ] ifTrue:[
       
   288         showIndicator := nil
       
   289     ].
       
   290 
       
   291     matchAction := mA
       
   292 
       
   293     "Modified: / 24.9.1998 / 14:10:38 / cg"
       
   294     "Created: / 24.9.1998 / 15:51:58 / cg"
       
   295 !
       
   296 
       
   297 directoryIsLocked
       
   298     ^ self imageType == #directoryLocked
       
   299 
       
   300     "Created: / 24.9.1998 / 14:22:08 / cg"
       
   301 !
       
   302 
       
   303 fileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool
   264     "initialze attributes associated with the full pathname, aPathname
   304     "initialze attributes associated with the full pathname, aPathname
   265     "
   305     "
   266     contents    := aFilenname.
   306     |f|
   267     name        := aBaseName.
   307 
       
   308     contents    := aFilename.
       
   309     (f := aFilename asFilename) isRootDirectory ifTrue:[
       
   310         name := f name.
       
   311         (name endsWith:Filename separator) ifTrue:[
       
   312             name := name copyWithoutLast:1.
       
   313         ]
       
   314     ] ifFalse:[
       
   315         name        := aBaseName.
       
   316     ].
   268     parent      := aParent.
   317     parent      := aParent.
   269     isDirectory := readChildren := aBool.
   318     isDirectory := readChildren := aBool.
   270 
   319 
   271     isDirectory ifFalse:[
   320     isDirectory ifFalse:[
   272         showIndicator := false
   321         showIndicator := false
   278         matchAction := parent matchAction       "/ same as from parent
   327         matchAction := parent matchAction       "/ same as from parent
   279     ] ifFalse:[
   328     ] ifFalse:[
   280         self match:nil                          "/ setup matchAction new
   329         self match:nil                          "/ setup matchAction new
   281     ]
   330     ]
   282 
   331 
       
   332     "Modified: / 24.9.1998 / 16:05:13 / cg"
   283 !
   333 !
   284 
   334 
   285 matchAction
   335 matchAction
   286     "returns my match action
   336     "returns my match action
   287     "
   337     "
   411     "returns true if the node is a not empty directory
   461     "returns true if the node is a not empty directory
   412     "
   462     "
   413     |model|
   463     |model|
   414 
   464 
   415     showIndicator isNil ifTrue:[
   465     showIndicator isNil ifTrue:[
   416         (self imageType == #directoryLocked) ifTrue:[
   466         self directoryIsLocked ifTrue:[
   417             showIndicator := readChildren := false.
   467             showIndicator := readChildren := false.
   418         ] ifFalse:[
   468         ] ifFalse:[
   419             (model := self model) notNil ifTrue:[
   469             (model := self model) notNil ifTrue:[
   420                 model startIndicatorValidationFor:self.
   470                 model startIndicatorValidationFor:self.
   421             ].
   471             ].
   422             ^ false
   472             ^ false
   423         ]
   473         ]
   424     ].
   474     ].
   425     ^ showIndicator
   475     ^ showIndicator
   426 
   476 
   427 
   477     "Modified: / 24.9.1998 / 14:22:34 / cg"
   428 !
   478 !
   429 
   479 
   430 showIndicator:aBool
   480 showIndicator:aBool
   431     "indication might change; raise a change notification
   481     "indication might change; raise a change notification
   432     "
   482     "
   496 ! !
   546 ! !
   497 
   547 
   498 !FileSelectionItem methodsFor:'update'!
   548 !FileSelectionItem methodsFor:'update'!
   499 
   549 
   500 imageType
   550 imageType
       
   551     "return my icon-image type - a symbol"
   501 
   552 
   502     |readable|
   553     |readable|
   503 
   554 
   504     imageType isNil ifTrue:[
   555     imageType isNil ifTrue:[
   505         readable := contents isReadable.
   556         readable := contents isReadable.
   506 
   557 
   507         isDirectory ifTrue:[
   558         isDirectory ifTrue:[
   508             (readable and:[contents isExecutable]) ifTrue:[
   559             (readable and:[contents isExecutable]) ifTrue:[
   509                 contents isSymbolicLink ifFalse:[imageType := #directory]
   560                 contents isSymbolicLink 
   510                                          ifTrue:[imageType := #directoryLink]
   561                     ifFalse:[imageType := #directory]
       
   562                     ifTrue:[imageType := #directoryLink]
   511             ] ifFalse:[
   563             ] ifFalse:[
   512                 imageType := #directoryLocked
   564                 imageType := #directoryLocked
   513             ]
   565             ]
   514         ] ifFalse:[
   566         ] ifFalse:[
   515             readable ifFalse:[
   567             readable ifFalse:[
   527             ]
   579             ]
   528         ]
   580         ]
   529     ].
   581     ].
   530     ^ imageType
   582     ^ imageType
   531 
   583 
       
   584     "Modified: / 24.9.1998 / 15:47:38 / cg"
   532 !
   585 !
   533 
   586 
   534 readInChildren
   587 readInChildren
   535     "read children from directory
   588     "read children from directory
   536     "
   589     "
   538 
   591 
   539     list := OrderedCollection new.
   592     list := OrderedCollection new.
   540     readChildren  := false.
   593     readChildren  := false.
   541     showIndicator := false.
   594     showIndicator := false.
   542 
   595 
   543     self imageType == #directoryLocked ifFalse:[
   596     self directoryIsLocked ifFalse:[
   544         Cursor wait showWhile:[
   597         Cursor wait showWhile:[
   545             directory := DirectoryContents directoryNamed:contents.
   598             directory := DirectoryContents directoryNamed:contents.
   546 
   599 
   547             directory isNil ifTrue:[
   600             directory isNil ifTrue:[
   548                 self stopIndicatorValidation.
   601                 self stopIndicatorValidation.
   551             ] ifFalse:[
   604             ] ifFalse:[
   552                 modificationTime := directory modificationTime.
   605                 modificationTime := directory modificationTime.
   553 
   606 
   554                 directory contentsAndBaseNamesDo:[:file :bname :isDir|
   607                 directory contentsAndBaseNamesDo:[:file :bname :isDir|
   555                     (self isVisibleFile:file isDirectory:isDir baseName:bname) ifTrue:[
   608                     (self isVisibleFile:file isDirectory:isDir baseName:bname) ifTrue:[
   556                         list add:(self class new fileName:file baseName:bname parent:self isDirectory:isDir)
   609                         list add:(self class new 
       
   610                                     childFileName:file 
       
   611                                     baseName:bname 
       
   612                                     parent:self 
       
   613                                     isDirectory:isDir
       
   614                                      matchAction:matchAction)
   557                     ]
   615                     ]
   558                 ].
   616                 ].
   559                 showIndicator := list size ~~ 0.
   617                 showIndicator := list size ~~ 0.
   560             ]
   618             ]
   561         ]
   619         ]
   562     ].
   620     ].
   563   ^ list
   621   ^ list
   564 
   622 
       
   623     "Modified: / 24.9.1998 / 15:52:53 / cg"
   565 ! !
   624 ! !
   566 
   625 
   567 !FileSelectionItem::Directory class methodsFor:'documentation'!
   626 !FileSelectionItem::Directory class methodsFor:'documentation'!
   568 
   627 
   569 documentation
   628 documentation
   612 ! !
   671 ! !
   613 
   672 
   614 !FileSelectionItem class methodsFor:'documentation'!
   673 !FileSelectionItem class methodsFor:'documentation'!
   615 
   674 
   616 version
   675 version
   617     ^ '$Header: /cvs/stx/stx/libwidg2/FileSelectionItem.st,v 1.11 1998-05-29 11:01:26 ca Exp $'
   676     ^ '$Header: /cvs/stx/stx/libwidg2/FileSelectionItem.st,v 1.12 1998-09-24 14:50:41 cg Exp $'
   618 ! !
   677 ! !