DirectoryView.st
author tz
Sat, 21 Mar 1998 01:44:00 +0100
changeset 744 20cbba6d7e96
parent 652 75644c11d619
child 820 e967a1359d77
permissions -rw-r--r--
oops - no #redefineMethods found

"
 COPYRIGHT (c) 1997 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice. This software may not
 be provided or otherwise made available to, or used by, any
 other person. No title to or ownership of the software is
 hereby transferred.
"


ApplicationModel subclass:#DirectoryView
	instanceVariableNames:'directory selectedFileFilter readTask monitoring
		monitoringTimeBlock fileDoubleClickAction fileSelectAction
		fileFilterSelectAction fileAttributes'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Support'
!

Object subclass:#FileRow
	instanceVariableNames:'fileName size modified iconKey imageFromFile group owner
		permissions baseName'
	classVariableNames:''
	poolDictionaries:''
	privateIn:DirectoryView
!

!DirectoryView class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1997 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice. This software may not
 be provided or otherwise made available to, or used by, any
 other person. No title to or ownership of the software is
 hereby transferred.
"

!

documentation
"
    documentation to be added.

    [author:]
        Thomas Zwick
"
! !

!DirectoryView class methodsFor:'instance creation'!

openOnDirectory: aDirectoryString
    "open a DirectoryView for a aDirectoryString"

    ^ (self new directory: aDirectoryString) open

    "
     self openOnDirectory: '/etc'
    "

    "Modified: / 28.1.1998 / 15:44:53 / stefan"
! !

!DirectoryView class methodsFor:'interface specs'!

windowSpec
    "this window spec was automatically generated by the ST/X UIPainter"

    "do not manually edit this - the painter/builder may not be able to
     handle the specification if its corrupted."

    "
     UIPainter new openOnClass:DirectoryView andSelector:#windowSpec
     DirectoryView new openInterface:#windowSpec
    "
    "DirectoryView open"

    <resource: #canvas>

    ^

       #(#FullSpec
          #window: 
           #(#WindowSpec
              #name: 'Directory View'
              #layout: #(#LayoutFrame 34 0 350 0 433 0 649 0)
              #label: 'Directory View'
              #min: #(#Point 10 10)
              #max: #(#Point 1152 900)
              #bounds: #(#Rectangle 34 350 434 650)
              #usePreferredExtent: false
          )
          #component: 
           #(#SpecCollection
              #collection: 
               #(
                 #(#DataSetSpec
                    #name: 'filesDataSetView'
                    #layout: #(#LayoutFrame 0 0.0 24 0.0 -2 1.0 0 1.0)
                    #model: #selectionOfFile
                    #hasHorizontalScrollBar: true
                    #hasVerticalScrollBar: true
                    #miniScrollerHorizontal: true
                    #dataList: #listOfFiles
                    #useIndex: false
                    #doubleClickSelector: #fileDoubleClicked
                    #columnHolder: #fileAttributeColumns
                    #valueChangeSelector: #fileSelected
                    #verticalSpacing: 1
                )
                 #(#ComboBoxSpec
                    #name: 'formatComboBox'
                    #layout: #(#LayoutFrame 63 0.0 0 0 0 1.0 22 0)
                    #model: #selectionOfFileFilter
                    #immediateAccept: false
                    #acceptOnTab: false
                    #comboList: #listOfFileFilters
                )
                 #(#LabelSpec
                    #name: 'label1'
                    #layout: #(#LayoutFrame 0 0 0 0 62 0 22 0)
                    #label: 'Filter: '
                    #adjust: #right
                )
              )
          )
      )

!

windowSpecOfFileAttributeColumns

    ^
     #(
       #(#DataSetColumnSpec
          #'label:' ''
          #'width:' 30
          #'height:' 22
          #'printSelector:' #'iconOn:'
          #'canSelect:' false
      )
       #(#DataSetColumnSpec
          #'label:' 'File name'
          #'labelAlignment:' #left
          #'minWidth:' 150
          #'model:' #baseName
          #'canSelect:' false
      )
       #(#DataSetColumnSpec
          #'label:' 'Size'
          #'labelAlignment:' #left
          #'width:' 70
          #'model:' #size
          #'canSelect:' false
      )
       #(#DataSetColumnSpec
          #'label:' 'Modified'
          #'labelAlignment:' #left
          #'model:' #modified
          #'canSelect:' false
      )
       #(#DataSetColumnSpec
          #'label:' 'Permissions'
          #'labelAlignment:' #left
          #'width:' 85
          #'model:' #permissions
          #'canSelect:' false
      )
       #(#DataSetColumnSpec
          #'label:' 'Owner'
          #'labelAlignment:' #left
          #'width:' 50
          #'model:' #owner
          #'canSelect:' false
      )
       #(#DataSetColumnSpec
          #'label:' 'Group'
          #'labelAlignment:' #left
          #'width:' 50
          #'model:' #group
          #'canSelect:' false
      )
    )

    "Modified: / 6.2.1998 / 03:40:16 / cg"
! !

!DirectoryView methodsFor:'accessing'!

directory: aDirectory

    directory := aDirectory asFilename asAbsoluteFilename name
!

fileAttributes: anArray

    fileAttributes := anArray
!

fileDoubleClickAction: anActionBlock

    fileDoubleClickAction := anActionBlock
!

fileFilterSelectAction: anActionBlock

    fileFilterSelectAction := anActionBlock
!

fileSelectAction: anActionBlock

    fileSelectAction := anActionBlock
!

listOfFileFilters: aCollection

    self listOfFileFilters contents: aCollection.
    self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]).
!

monitoring: aBoolean

    aBoolean
    ifTrue:
    [
        monitoringTimeBlock := [self readDirectory].
        self readDirectory.
    ]
    ifFalse:
    [
        monitoring ifTrue:
        [
            Processor removeTimedBlock:monitoringTimeBlock.
            monitoringTimeBlock := nil
        ]
    ].

    monitoring := aBoolean.

! !

!DirectoryView methodsFor:'aspects'!

fileAttributeColumns

    |holder|
    (holder := builder bindingAt:#fileAttributeColumns) isNil ifTrue:[
        |fileAttributeColumns|
        builder aspectAt:#fileAttributeColumns put:(holder := List new).
        fileAttributeColumns := self class windowSpecOfFileAttributeColumns collect: [:i| i decodeAsLiteralArray].
        holder add: fileAttributeColumns first.
        fileAttributeColumns do:
        [:col|
            (fileAttributes includes: col label) ifTrue: [holder add: col]
        ].
        holder do: [:col| col label: ' ', col label]
    ].
    ^ holder
!

listOfFileFilters

    |holder|          
    (holder := builder bindingAt:#listOfFileFilters) isNil ifTrue:[
        builder aspectAt:#listOfFileFilters put:(holder :=  List with: '*').
    ].
    ^ holder
!

listOfFiles

    |holder|
    (holder := builder bindingAt:#listOfFiles) isNil ifTrue:[
        builder aspectAt:#listOfFiles put:(holder :=  List new).
    ].
    ^ holder
!

selectionOfFile

    |holder|
    (holder := builder bindingAt:#selectionOfFile) isNil ifTrue:[
        builder aspectAt:#selectionOfFile put:(holder :=  ValueHolder new).
    ].
    ^ holder

!

selectionOfFileFilter

    |holder|
    (holder := builder bindingAt:#selectionOfFileFilter) isNil ifTrue:[
        builder aspectAt:#selectionOfFileFilter put:
        (holder := AspectAdaptor new subject:self; forAspect:#selectedFileFilter).
        selectedFileFilter := '*'.
    ].
    ^ holder
! !

!DirectoryView methodsFor:'callbacks'!

fileDoubleClicked
      
    (fileDoubleClickAction notNil and: [self selectionOfFile value notNil]) 
    ifTrue: 
    [
        fileDoubleClickAction numArgs = 0
        ifTrue:
        [
            fileDoubleClickAction value
        ].
        fileDoubleClickAction numArgs = 1
        ifTrue:
        [                
            fileDoubleClickAction value: (directory asFilename construct: self selectionOfFile value baseName) name
        ]
    ]
!

fileSelected
      
    (fileSelectAction notNil and: [self selectionOfFile value notNil]) 
    ifTrue: 
    [
        fileSelectAction numArgs = 0
        ifTrue:
        [
            fileSelectAction value
        ].
        fileSelectAction numArgs = 1
        ifTrue:
        [
            fileSelectAction value: (directory asFilename construct: self selectionOfFile value baseName) name
        ]
    ]
! !

!DirectoryView methodsFor:'initialization'!

initialize

    super initialize.

    directory :=  directory ? '.' asFilename asAbsoluteFilename directoryName.
    monitoring := false.
    fileAttributes := #('File name' 'Size' 'Modified').
    self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]).

! !

!DirectoryView methodsFor:'private'!

readDirectory

    |foundFiles list|    
    foundFiles := OrderedCollection new.
    list := self listOfFileFilters value.

    Cursor wait showWhile: 
    [ 
        (DirectoryContents directoryNamed: directory) filesAndBasenamesDo: 
        [:file :name|      
            list do:
            [:filter|
                ((filter match: name) and: [(foundFiles includes: file) not])
                ifTrue:
                [
                    foundFiles add: file
                ].
            ].
        ].
        self listOfFiles contents: (foundFiles collect: [:file| FileRow new fileName: file])
    ]

!

readMonitoringDirectory

    |readBlock|
    readTask notNil ifTrue: [readTask terminate].
    readBlock :=
    [
        |dir currentFilenames oldListOfFiles|
        dir := directory asFilename.
        currentFilenames := OrderedCollection new.
        (dir isReadable and:[dir isExecutable]) ifTrue:
        [
            self listOfFileFilters value do:
            [:filter|
                (dir filesMatchingWithoutDotDirs: filter) do:
                [:aFileName|
                    |file|
                    (file := dir construct: aFileName) isDirectory
                    ifFalse:
                    [
                        currentFilenames add: file
                    ]
                ].
            ].
        ].
        oldListOfFiles := self listOfFiles copy.
        (currentFilenames asSortedCollection: [:f1 :f2| f1 baseName < f2 baseName]) asSet do: 
        [:fileName| 
            (oldListOfFiles detect: [:fileRow| fileRow fileName = fileName] ifNone: nil) isNil
            ifTrue:                                                                             
            [
                |nearestFileRow r|
                nearestFileRow := self listOfFiles indexOf: (self listOfFiles detect: [:fileRow| fileRow baseName > fileName baseName] ifNone: nil).
                nearestFileRow = 0
                ifTrue: [self listOfFiles add: (r := FileRow new fileName: fileName asFilename)]
                ifFalse: [self listOfFiles add: (r := FileRow new fileName: fileName asFilename) beforeIndex: nearestFileRow].
                monitoring ifTrue: [self selectionOfFile value: r].
            ]
        ].
        self listOfFiles reverseDo:
        [:fileRow|
            (currentFilenames includes: fileRow fileName)
            ifFalse: [self listOfFiles remove: fileRow]
        ]
    ].

    monitoring
    ifTrue:
    [
        readTask := readBlock forkAt: Processor userBackgroundPriority.
        Processor addTimedBlock: monitoringTimeBlock afterSeconds: 1
    ]
    ifFalse:
    [
        Cursor wait showWhile: [readBlock value]
    ]
! !

!DirectoryView methodsFor:'selection'!

selectedFileFilter

    ^selectedFileFilter

!

selectedFileFilter: aString

    aString size = 0 ifTrue: [self listOfFileFilters remove: selectedFileFilter ifAbsent: nil].
    selectedFileFilter := aString.
    (self listOfFileFilters includes: selectedFileFilter) not &
    selectedFileFilter notEmpty
    ifTrue:
    [
        self listOfFileFilters addFirst: selectedFileFilter
    ].
    (self listOfFileFilters includes: selectedFileFilter) &
    fileFilterSelectAction notNil 
    ifTrue: 
    [
        fileFilterSelectAction numArgs = 0
        ifTrue:
        [
            fileFilterSelectAction value
        ].
        fileFilterSelectAction numArgs = 1
        ifTrue:
        [
            fileFilterSelectAction value: selectedFileFilter
        ]
    ].       
    self readDirectory.
! !

!DirectoryView methodsFor:'startup / release'!

closeRequest

    self release.

    super closeRequest

!

release

    monitoring ifTrue:
    [
        Processor removeTimedBlock:monitoringTimeBlock.
        monitoringTimeBlock := nil
    ].

    super release

! !

!DirectoryView::FileRow class methodsFor:'resources'!

HFileIcon

    ^self hFileIcon
!

MakefileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#MakefileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow MakefileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 @@0)IV0/U$0)]&0)UT;)UV4 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]!

binaryFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#binaryFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow binaryFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???3 @_7 @W4#&S0&6Q0&6_3&6O5&6@0#&@9 @@0&\@2&6@0&6@0&6@1&6@8&\@0 @@0???0???1'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]!

cFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#cFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow cFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 \@0 "@0  @0  @0&"@;&\@4 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]!

exeFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#exeFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow exeFileIcon'
        ifAbsentPut:[(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUU@@@@UUT@@@AEUP@@@DEU@@@@PETEUUUUUPZ**)UUAUUUUATG???4EP_???PUA???=ATG???4EP_???PUA???=ATEUUUTEP@@@@@U@@@@@AUUUUUUUUUUUUUTb'); colorMap:(((Array new:4) at:1 put:((Color white)); at:2 put:((Color black)); at:3 put:((Color red:0.0 green:49.9977 blue:49.9977)); at:4 put:((Color grey:66.9978)); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]!

fileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#fileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow fileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 @@0 @@0 @@0 @@0 @@; @@4 @@0 @@0???0???0') ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]!

hFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#hFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow hFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8  @0  @0 ,@0 2@0 "@0 "@0&"@;&"@4 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]!

htmlFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#htmlFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow htmlFileIcon'
        ifAbsentPut:[(Depth4Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'DQDQDQDQDQDQDQ????????DQDQD_???????1@QDQG???L3L3<P@QDQ??L3ADL3D@@QD_?3L0P3L1DQDQG?L3MCP3L1DQDQ?3QCQCMCP??1D_<4P4QDL4O?<QG?L4QDL3MD??DQ?3L3QCL3PO?1D_<3L4QDL4O?<QG?<3QDQCMO??DQ??L4QDP4S??1D_??=D@@S???<QG???????????DQ???????????1DQDQDQDQDQDQDQDQDQDQDQDQDQDP@a') ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9977 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9977 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9977); add:(Color red:0.0 green:49.9977 blue:49.9977); add:(Color red:49.9977 green:49.9977 blue:0.0); add:(Color red:49.9977 green:0.0 blue:49.9977); add:(Color grey:49.9977); add:(Color grey:66.9978); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]!

imageFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#imageFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow imageFileIcon'
        ifAbsentPut:[(Depth4Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@DQDQDQDQ@@@@@ADQDQDQDPD@@@@QDQDQDQDAD@@@DQDQDQDQ@QD@@ADQDQDQDP@@@@@TQG]4)G50@@@@EDQ7^$+W4QDP@AQD]7R$_WDQD@@SL6Y#$61!!DQ@@D3M&ZS''F0QDP@AL3Y&NS[FDQD@@RH%UR %-QDQ@@D"IUVB"5,QDP@AH"UUJBV5DQD@@QDQDQDQDQDQ@@DQDQDQDQDQDP@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9977 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9977 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9977); add:(Color red:0.0 green:49.9977 blue:49.9977); add:(Color red:49.9977 green:49.9977 blue:0.0); add:(Color red:49.9977 green:0.0 blue:49.9977); add:(Color grey:49.9977); add:(Color grey:66.9978); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]!

imgFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#imgFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow imgFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8  @0 @@0!!-F0 **0 **0 **0&**;&*&4 @B0 @N0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]
!

linkedFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#linkedFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow linkedFileIcon'
        ifAbsentPut:[(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUU@@@@UUT@@@AEUP@@@DEU@@@@PET@@@AUUP@@@AUU@@@@@AT@@@@ EP@@@B U@@@**!!T@@J**EP@B B UB*(@HATJ*@@@EP@@@@@U@@@@@AUUUUUUUUUUUUUTb') ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]!

lockedFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#lockedFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow lockedFileIcon'
        ifAbsentPut:[(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUU(@@@UUT(@@AEUP(@@DEU@(@@PET@(@IUUP@(B!!UU@@((@AT@@*@@EP@B(@@U@@((@AT@J@(@EPB @(@U@(@@(ATJ@@@(ER @@@(U(@@@@)UUUUUUUUUUUUUTb') ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]!

protoFileIcon

    ^self MakefileIcon
!

rcFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#rcFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow rcFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 ) 0 2P0 "@0 "@0&"P;&!! 4 @@0 @@0???0???0') ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]!

sFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#sFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow sFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 X@0  @0 0@0 X@0&H@;&0@4 @@0 @@0???0???0') ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]!

stFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#stFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow stFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 A@0 A@0 [00 !!@0 1@0 Y@0&I@;&004 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]!

stcFileIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#stcFileIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'DirectoryView::FileRow stcFileIcon'
        ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 B@0 B@0 _L0 "R0 2P0 ZP0&JR;&3L4 @@0 @@0???0???0') ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0') ; yourself); yourself]! !

!DirectoryView::FileRow methodsFor:'accessing'!

baseName

    ^baseName ? (baseName := fileName baseName)







!

fileName

    ^fileName
!

fileName: aFileName

    fileName := aFileName
!

group

    ^group
!

iconOn:aGC

    |icon|
    iconKey isNil 
    ifTrue: 
    [
        self validateAttributes.
        (imageFromFile isNil and: [iconKey == #imageFileIcon])
            ifTrue:  [icon := self retrieveImageFromFileAndRegisterOn: aGC]
    ].
    imageFromFile == true
        ifFalse: [icon := aGC registerImage: (self class perform: iconKey) key: iconKey]
        ifTrue:  [icon := aGC registeredImageAt: iconKey].
    ^icon

    "Modified: / 18.2.1998 / 18:01:52 / cg"
!

modified

    ^modified
!

owner

    ^owner
!

permissions

    ^permissions
!

retrieveImageFromFileAndRegisterOn: aGC

    |image|
    imageFromFile := false.       
    (image := aGC registeredImageAt: fileName name asSymbol) isNil
    ifTrue:
    [            
        size < 5000
        ifTrue:
        [     
            Object errorSignal handle: [:ex|]
            do:
            [   
                (image := Image fromFile: fileName name) notNil
                ifTrue:
                [
                    image extent y > 22
                    ifTrue:
                    [         
                        image := image magnifiedBy: 22/image extent y
                    ].
                    image := aGC registerImage: image key: fileName name asSymbol.
                ]
            ] 
        ].
    ].
    image notNil ifTrue: [imageFromFile := true. iconKey := fileName name asSymbol].
    ^image



!

size
    size isNumber ifFalse:[^ size].
    size < 1000        ifTrue: [^ size printString].
    size < (100*1024)  ifTrue: [^(((size/1024) * 10) asInteger/10) asFloat printString, ' Kb'].
    size < (1000*1024) ifTrue: [^(((size/1024)) asInteger) printString, ' Kb'].
    ^(((size/1048576) * 10) asInteger/10) asFloat printString, ' Mb'

    "Modified: / 6.2.1998 / 03:38:45 / cg"
! !

!DirectoryView::FileRow methodsFor:'private'!

validateAttributes

    |info mode| 

    permissions := String new:9 withAll:$-.

    (info := fileName info) isNil
    ifTrue:
    [
        iconKey := #lockedFileIcon.
        size    := owner := group := '?'.
      ^ self
    ].        
    size   := info size.
    modified := info modified printString.
    owner  := OperatingSystem getUserNameFromID: info uid.
    group  := OperatingSystem getGroupNameFromID: info gid.
    mode   := info mode.

    1 to:9 by:3 do:[:i|
        #((0 $x) (1 $w) (2 $r)) do:
        [:m|
            (mode bitAt:i + m first) == 1 ifTrue:[permissions at: 10 - m first - i put: m last]
        ]
    ].

    fileName isReadable
    ifTrue:
    [
        info type == #symbolicLink
        ifTrue:
        [
            ^iconKey := #linkedFileIcon
        ]
        ifFalse:
        [       
            ((DirectoryView::FileRow class implements: (iconKey := (fileName suffix, 'FileIcon') asSymbol))
            or:
            [DirectoryView::FileRow class implements: (iconKey := (fileName baseName, 'Icon') asSymbol)])
            ifFalse:
            [
                iconKey := #fileIcon.
                (Image isImageFileSuffix:fileName suffix)
                ifTrue:
                [
                    ^iconKey := #imageFileIcon
                ].
                (fileName suffix = 'o') | (fileName suffix = 'so')
                ifTrue:
                [
                    ^iconKey := #binaryFileIcon
                ].

                fileName isExecutableProgram
                ifTrue:
                [
                    ^iconKey := #exeFileIcon
                ]
            ]
        ]
    ] 
    ifFalse:
    [
        ^iconKey := #lockedFileIcon
    ].


! !

!DirectoryView class methodsFor:'documentation'!

version
    ^ '$Header$'
! !