"
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
"
! !
!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 64 0 703 0 463 0 1002 0)
#'label:' 'Directory View'
#'min:' #(#Point 10 10)
#'max:' #(#Point 1152 900)
#'bounds:' #(#Rectangle 64 703 464 1003)
#'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 0 0.0 0 0 0 1.0 22 0)
#'model:' #selectionOfFileFilter
#'immediateAccept:' false
#'acceptOnTab:' false
#'comboList:' #listOfFileFilters
)
)
)
)
"Modified: / 6.2.1998 / 03:42:15 / cg"
!
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)
ifTrue:
[
foundFiles add: (FileRow new fileName: file)
].
].
].
self listOfFiles contents: foundFiles
]
!
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]!
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
"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
"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
"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
"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
!
group
^group
!
iconOn:aGC
(aGC registeredImageAt:iconKey) isNil
ifTrue:
[
self validateAttributes.
((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 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$'
! !