DirectoryView.st
author tz
Thu, 29 Jan 1998 19:44:04 +0100
changeset 526 7a4749b25748
parent 516 d336effde882
child 590 c2f5cd223be2
permissions -rw-r--r--
style revised

"
 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-Advanced-Tools'
!

Object subclass:#FileRow
	instanceVariableNames:'fileName size modified iconKey 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
"
!

history
    "Created: / 10.1.1998 / 10:59:49 / tz"
! !

!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 194 0 152 0 593 0 451 0)
              #'label:' 'Directory View'
              #'min:' #(#Point 10 10)
              #'max:' #(#Point 1152 900)
              #'bounds:' #(#Rectangle 194 152 594 452)
              #'usePreferredExtent:' false
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#DataSetSpec
                    #'name:' 'filesDataSetView'
                    #'layout:' #(#LayoutFrame 0 0.0 22 0.0 0 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 0 0.0 0 0 0 1.0 22 0)
                    #'model:' #selectionOfFileFilter
                    #'immediateAccept:' false
                    #'acceptOnTab:' false
                    #'comboList:' #listOfFileFilters
                )
              )
          )
      )
!

windowSpecOfFileAttributeColumns

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

! !

!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
!

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').
    self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]).

! !

!DirectoryView methodsFor:'private'!

readDirectory

    |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
    "ImageEditor openOnClass:self andSelector:#MakefileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 0 48 128 0 48 128 0 48 164 149 176 189 89 48 165 217 176 165 85 59 165 85 180 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

binaryFileIcon
    "ImageEditor openOnClass:self andSelector:#binaryFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 243 128 7 247 128 5 244 142 100 240 155 100 112 155 103 243 155 99 245 155 96 48 142 96 57 128 0 48 153 192 50 155 96 48 155 96 48 155 96 49 155 96 56 153 192 48 128 0 48 255 255 240 255 255 241]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

cFileIcon
    "ImageEditor openOnClass:self andSelector:#cFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 0 48 128 0 48 129 192 48 130 32 48 130 0 48 130 0 48 154 32 59 153 192 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

exeFileIcon
    "ImageEditor openOnClass:self andSelector:#exefileIcon"

    <resource: #image>
    ^(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[85 85 85 85 85 64 0 0 21 85 64 0 0 17 85 64 0 0 16 85 64 0 0 16 21 65 85 85 85 85 65 170 170 165 85 65 85 85 85 5 65 255 255 253 5 65 255 255 253 5 65 255 255 253 5 65 255 255 253 5 65 255 255 253 5 65 255 255 253 5 65 85 85 85 5 64 0 0 0 5 64 0 0 0 5 85 85 85 85 85 85 85 85 85 85]) ; colorMap:(((Array new:4) at:1 put:((Color white)); at:2 put:((Color black)); at:3 put:((Color red:0.0 green:49.9992 blue:49.9992)); at:4 put:((Color grey:66.9993)); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself
!

fileIcon
    "ImageEditor openOnClass:self andSelector:#fileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 0 48 128 0 48 128 0 48 128 0 48 128 0 48 128 0 48 128 0 59 128 0 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

hFileIcon
    "ImageEditor openOnClass:self andSelector:#hFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 130 0 48 130 0 48 130 192 48 131 32 48 130 32 48 130 32 48 154 32 59 154 32 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

imageFileIcon
    "ImageEditor openOnClass:self andSelector:#imageFileIcon"

    <resource: #image>
    ^(Depth4Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(#[0 0 0 0 0 0 0 0 0 0 1 17 17 17 17 17 16 0 0 0 1 17 17 17 17 17 16 16 0 0 1 17 17 17 17 17 16 17 0 0 1 17 17 17 17 17 16 17 16 0 1 17 17 17 17 17 16 0 0 0 1 68 71 119 74 71 215 0 0 0 1 68 71 119 164 173 125 17 17 0 1 68 71 119 74 71 215 17 17 0 1 51 54 102 57 54 198 17 17 0 1 51 54 102 147 156 108 17 17 0 1 51 54 102 57 54 198 17 17 0 1 34 37 85 40 37 181 17 17 0 1 34 37 85 130 139 91 17 17 0 1 34 37 85 40 37 181 17 17 0 1 17 17 17 17 17 17 17 17 0 1 17 17 17 17 17 17 17 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) ; 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.9992 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9992 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9992); add:(Color red:0.0 green:49.9992 blue:49.9992); add:(Color red:49.9992 green:49.9992 blue:0.0); add:(Color red:49.9992 green:0.0 blue:49.9992); add:(Color grey:49.9992); add:(Color grey:66.9993); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

imgFileIcon
    "ImageEditor openOnClass:self andSelector:#imgFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 130 0 48 128 0 48 134 209 176 130 170 176 130 170 176 130 170 176 154 170 187 154 169 180 128 0 176 128 3 176 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

linkedFileIcon
    "ImageEditor openOnClass:self andSelector:#linkedFileIcon"

    <resource: #image>
    ^(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[85 85 85 85 85 64 0 0 21 85 64 0 0 17 85 64 0 0 16 85 64 0 0 16 21 64 0 0 21 85 64 0 0 5 85 64 0 0 0 5 64 0 0 8 5 64 0 0 10 5 64 0 10 170 133 64 0 42 170 133 64 0 160 10 5 66 170 128 8 5 66 170 0 0 5 64 0 0 0 5 64 0 0 0 5 85 85 85 85 85 85 85 85 85 85]) ; 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:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

lockedFileIcon
    "ImageEditor openOnClass:self andSelector:#lockedFileIcon"

    <resource: #image>
    ^(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[85 85 85 85 85 104 0 0 21 85 74 0 0 17 85 66 128 0 16 85 64 160 0 16 21 64 40 0 149 85 64 10 2 133 85 64 2 138 0 5 64 0 168 0 5 64 0 168 0 5 64 2 138 0 5 64 10 2 128 5 64 40 0 160 5 64 160 0 40 5 66 128 0 10 5 74 0 0 2 133 104 0 0 0 165 85 85 85 85 85 85 85 85 85 85]) ; 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:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

protoFileIcon

    ^self MakefileIcon
!

rcFileIcon
    "ImageEditor openOnClass:self andSelector:#rcFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 0 48 128 0 48 130 152 48 131 36 48 130 32 48 130 32 48 154 36 59 154 24 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

sFileIcon
    "ImageEditor openOnClass:self andSelector:#sFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 0 48 128 0 48 129 128 48 130 0 48 131 0 48 129 128 48 152 128 59 155 0 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

stFileIcon
    "ImageEditor openOnClass:self andSelector:#stFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 16 48 128 16 48 129 188 48 130 16 48 131 16 48 129 144 48 152 144 59 155 12 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself!

stcFileIcon
    "ImageEditor openOnClass:self andSelector:#stcFileIcon"

    <resource: #image>
    ^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 32 48 128 32 48 129 243 48 130 36 176 131 36 48 129 164 48 152 164 187 155 51 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself! !

!DirectoryView::FileRow methodsFor:'accessing'!

baseName

    ^baseName ? (baseName := fileName baseName)







!

fileName

    ^fileName
!

fileName: aFileName

    fileName := aFileName.
    self validateAttributes
!

group

    ^group
!

iconOn:aGC

    (aGC registeredImageAt:iconKey) isNil
    ifTrue:
    [
        ((iconKey == #imageFileIcon) and: [size < 5000])
        ifTrue:
        [
            Object errorSignal handle: [:ex|]
            do:
            [   
                |image|
                (image := Image fromFile: fileName name) notNil
                ifTrue:
                [
                    image extent y > 22
                    ifTrue:
                    [         
                        image := image magnifiedBy: 22/image extent y
                    ].
                    (aGC registeredImageAt: (iconKey := fileName name asSymbol)) isNil
                    ifTrue:
                    [
                        aGC registerImage: image key: iconKey
                    ]
                ]
            ] 
        ]
        ifFalse:
        [  
            aGC registerImage: (self class perform: iconKey) key: iconKey
        ]
    ].
    ^aGC registeredImageAt: iconKey




!

modified

    ^modified
!

owner

    ^owner
!

permissions

    ^permissions
!

size

    ^size
! !

!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$'
! !