DirectoryView.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Jul 2009 20:02:02 +0200
changeset 2570 4e663bc64364
parent 2439 9f6c2575f2b1
child 2878 241be37ce37b
permissions -rw-r--r--
changed #requestPackage
tz@424
     1
"
tz@502
     2
 COPYRIGHT (c) 1997 by eXept Software AG
tz@424
     3
              All Rights Reserved
tz@424
     4
tz@424
     5
 This software is furnished under a license and may be used
tz@424
     6
 only in accordance with the terms of that license and with the
tz@424
     7
 inclusion of the above copyright notice. This software may not
tz@424
     8
 be provided or otherwise made available to, or used by, any
tz@424
     9
 other person. No title to or ownership of the software is
tz@424
    10
 hereby transferred.
tz@424
    11
"
cg@1385
    12
"{ Package: 'stx:libtool2' }"
cg@1385
    13
tz@424
    14
ApplicationModel subclass:#DirectoryView
tz@424
    15
	instanceVariableNames:'directory selectedFileFilter readTask monitoring
tz@424
    16
		monitoringTimeBlock fileDoubleClickAction fileSelectAction
tz@424
    17
		fileFilterSelectAction fileAttributes'
tz@424
    18
	classVariableNames:''
tz@424
    19
	poolDictionaries:''
cg@2101
    20
	category:'Interface-Dialogs'
tz@424
    21
!
tz@424
    22
tz@424
    23
Object subclass:#FileRow
tz@638
    24
	instanceVariableNames:'fileName size modified iconKey imageFromFile group owner
tz@638
    25
		permissions baseName'
cg@1385
    26
	classVariableNames:'MaxImageFileSize'
tz@424
    27
	poolDictionaries:''
tz@424
    28
	privateIn:DirectoryView
tz@424
    29
!
tz@424
    30
tz@424
    31
!DirectoryView class methodsFor:'documentation'!
tz@424
    32
tz@424
    33
copyright
tz@424
    34
"
tz@502
    35
 COPYRIGHT (c) 1997 by eXept Software AG
tz@424
    36
              All Rights Reserved
tz@424
    37
tz@424
    38
 This software is furnished under a license and may be used
tz@424
    39
 only in accordance with the terms of that license and with the
tz@424
    40
 inclusion of the above copyright notice. This software may not
tz@424
    41
 be provided or otherwise made available to, or used by, any
tz@424
    42
 other person. No title to or ownership of the software is
tz@424
    43
 hereby transferred.
tz@424
    44
"
tz@424
    45
tz@424
    46
!
tz@424
    47
tz@424
    48
documentation
tz@424
    49
"
cg@2351
    50
    this is somewhat outdated. However, it is still used by the image editor and
cg@2351
    51
    some other resource editors.
cg@2351
    52
    It has the advantage of showing the file-contents...
cg@2351
    53
    ...but the disabdvantage of having an ugly layout and user interface.
tz@502
    54
tz@502
    55
    [author:]
tz@502
    56
        Thomas Zwick
tz@424
    57
"
tz@424
    58
! !
tz@424
    59
tz@424
    60
!DirectoryView class methodsFor:'instance creation'!
tz@424
    61
sv@516
    62
openOnDirectory: aDirectoryString
sv@516
    63
    "open a DirectoryView for a aDirectoryString"
tz@424
    64
sv@516
    65
    ^ (self new directory: aDirectoryString) open
tz@424
    66
sv@516
    67
    "
sv@516
    68
     self openOnDirectory: '/etc'
sv@516
    69
    "
tz@424
    70
sv@516
    71
    "Modified: / 28.1.1998 / 15:44:53 / stefan"
tz@424
    72
! !
tz@424
    73
tz@424
    74
!DirectoryView class methodsFor:'interface specs'!
tz@424
    75
tz@424
    76
windowSpec
tz@820
    77
    "This resource specification was automatically generated
tz@820
    78
     by the UIPainter of ST/X."
tz@424
    79
tz@820
    80
    "Do not manually edit this!! If it is corrupted,
tz@820
    81
     the UIPainter may not be able to read the specification."
tz@424
    82
tz@424
    83
    "
tz@424
    84
     UIPainter new openOnClass:DirectoryView andSelector:#windowSpec
tz@424
    85
     DirectoryView new openInterface:#windowSpec
tz@820
    86
     DirectoryView open
tz@424
    87
    "
tz@424
    88
tz@424
    89
    <resource: #canvas>
tz@424
    90
cg@1346
    91
    ^ 
cg@1346
    92
     #(#FullSpec
cg@1346
    93
        #name: #windowSpec
cg@1346
    94
        #window: 
cg@1346
    95
       #(#WindowSpec
cg@1346
    96
          #label: 'Directory View'
cg@1346
    97
          #name: 'Directory View'
cg@1346
    98
          #min: #(#Point 10 10)
cg@1346
    99
          #max: #(#Point 1152 900)
cg@1346
   100
          #bounds: #(#Rectangle 13 23 413 323)
cg@1346
   101
        )
cg@1346
   102
        #component: 
cg@1346
   103
       #(#SpecCollection
cg@1346
   104
          #collection: #(
cg@1346
   105
           #(#DataSetSpec
cg@1346
   106
              #name: 'filesDataSetView'
cg@1346
   107
              #layout: #(#LayoutFrame 0 0.0 24 0.0 -2 1.0 0 1.0)
cg@1346
   108
              #model: #selectionOfFile
cg@1346
   109
              #menu: #fileListMenu
cg@1346
   110
              #hasHorizontalScrollBar: true
cg@1346
   111
              #hasVerticalScrollBar: true
cg@1346
   112
              #miniScrollerHorizontal: true
cg@1346
   113
              #dataList: #listOfFiles
cg@1346
   114
              #useIndex: false
cg@1346
   115
              #has3Dsepartors: false
cg@1346
   116
              #doubleClickSelector: #fileDoubleClicked
cg@1346
   117
              #columnHolder: #fileAttributeColumns
cg@1346
   118
              #valueChangeSelector: #fileSelected
cg@1346
   119
              #verticalSpacing: 1
cg@1346
   120
            )
cg@1346
   121
           #(#ComboBoxSpec
cg@1346
   122
              #name: 'formatComboBox'
cg@1346
   123
              #layout: #(#LayoutFrame 63 0.0 0 0 0 1.0 22 0)
cg@1346
   124
              #model: #selectionOfFileFilter
cg@1346
   125
              #immediateAccept: false
cg@1346
   126
              #acceptOnTab: false
cg@1346
   127
              #acceptOnPointerLeave: false
cg@1346
   128
              #comboList: #listOfFileFilters
cg@1346
   129
            )
cg@1346
   130
           #(#LabelSpec
cg@1346
   131
              #label: 'Filter: '
cg@1346
   132
              #name: 'filterLabel'
cg@1346
   133
              #layout: #(#LayoutFrame 0 0 0 0 62 0 22 0)
cg@1346
   134
              #adjust: #right
cg@1346
   135
            )
cg@1346
   136
           )
cg@1346
   137
         
cg@1346
   138
        )
tz@424
   139
      )
cg@1346
   140
cg@1346
   141
    "Modified: / 11.2.2000 / 00:11:43 / cg"
tz@424
   142
! !
tz@424
   143
tz@823
   144
!DirectoryView class methodsFor:'list specs'!
tz@823
   145
tz@823
   146
tableColumnsForFileAttributes
tz@823
   147
    "This resource specification was automatically generated
tz@823
   148
     by the DataSetBuilder of ST/X."
tz@823
   149
tz@823
   150
    "Do not manually edit this!! If it is corrupted,
tz@823
   151
     the DataSetBuilder may not be able to read the specification."
tz@823
   152
tz@823
   153
    "
tz@823
   154
     DataSetBuilder new openOnClass:DirectoryView andSelector:#tableColumnsForFileAttributes
tz@823
   155
    "
tz@823
   156
tz@823
   157
    <resource: #tableColumns>
tz@823
   158
tz@823
   159
tz@823
   160
    ^ #(
tz@823
   161
        #(#DataSetColumnSpec
tz@823
   162
           #label: ''
tz@823
   163
           #width: 30
tz@823
   164
           #height: 22
tz@823
   165
           #printSelector: #iconOn:
tz@823
   166
           #canSelect: false
tz@823
   167
       )
tz@823
   168
        #(#DataSetColumnSpec
tz@823
   169
           #label: 'File name'
tz@823
   170
           #labelAlignment: #left
tz@823
   171
           #minWidth: 150
tz@823
   172
           #model: #baseName
tz@823
   173
           #canSelect: false
tz@823
   174
       )
tz@823
   175
        #(#DataSetColumnSpec
tz@823
   176
           #label: 'Size'
tz@823
   177
           #labelAlignment: #left
tz@823
   178
           #width: 70
tz@823
   179
           #model: #size
tz@823
   180
           #canSelect: false
tz@823
   181
       )
tz@823
   182
        #(#DataSetColumnSpec
tz@823
   183
           #label: 'Modified'
tz@823
   184
           #labelAlignment: #left
tz@823
   185
           #model: #modified
tz@823
   186
           #canSelect: false
tz@823
   187
       )
tz@823
   188
        #(#DataSetColumnSpec
tz@823
   189
           #label: 'Permissions'
tz@823
   190
           #labelAlignment: #left
tz@823
   191
           #width: 85
tz@823
   192
           #model: #permissions
tz@823
   193
           #canSelect: false
tz@823
   194
       )
tz@823
   195
        #(#DataSetColumnSpec
tz@823
   196
           #label: 'Owner'
tz@823
   197
           #labelAlignment: #left
tz@823
   198
           #width: 50
tz@823
   199
           #model: #owner
tz@823
   200
           #canSelect: false
tz@823
   201
       )
tz@823
   202
        #(#DataSetColumnSpec
tz@823
   203
           #label: 'Group'
tz@823
   204
           #labelAlignment: #left
tz@823
   205
           #width: 50
tz@823
   206
           #model: #group
tz@823
   207
           #canSelect: false
tz@823
   208
       )
tz@823
   209
     )
tz@823
   210
! !
tz@823
   211
cg@1346
   212
!DirectoryView class methodsFor:'menu specs'!
cg@1346
   213
cg@1346
   214
fileListMenu
cg@1346
   215
    "This resource specification was automatically generated
cg@1346
   216
     by the MenuEditor of ST/X."
cg@1346
   217
cg@1346
   218
    "Do not manually edit this!! If it is corrupted,
cg@1346
   219
     the MenuEditor may not be able to read the specification."
cg@1346
   220
cg@1346
   221
    "
cg@1346
   222
     MenuEditor new openOnClass:DirectoryView andSelector:#fileListMenu
cg@1346
   223
     (Menu new fromLiteralArrayEncoding:(DirectoryView fileListMenu)) startUp
cg@1346
   224
    "
cg@1346
   225
cg@1346
   226
    <resource: #menu>
cg@1346
   227
cg@1346
   228
    ^ 
cg@1346
   229
     #(#Menu
cg@1346
   230
        #(
cg@1346
   231
         #(#MenuItem
cg@1346
   232
            #label: 'Update'
cg@1346
   233
            #translateLabel: true
cg@1346
   234
            #value: #updateFileList
cg@1346
   235
          )
cg@1346
   236
         )
cg@1346
   237
        nil
cg@1346
   238
        nil
cg@1346
   239
      )
cg@1346
   240
cg@1346
   241
    "Created: / 11.2.2000 / 00:11:39 / cg"
cg@1346
   242
! !
cg@1346
   243
tz@424
   244
!DirectoryView methodsFor:'accessing'!
tz@424
   245
tz@424
   246
directory: aDirectory
tz@424
   247
tz@424
   248
    directory := aDirectory asFilename asAbsoluteFilename name
tz@424
   249
!
tz@424
   250
tz@424
   251
fileAttributes: anArray
tz@424
   252
tz@424
   253
    fileAttributes := anArray
tz@424
   254
!
tz@424
   255
tz@424
   256
fileDoubleClickAction: anActionBlock
tz@424
   257
tz@424
   258
    fileDoubleClickAction := anActionBlock
tz@424
   259
!
tz@424
   260
tz@424
   261
fileFilterSelectAction: anActionBlock
tz@424
   262
tz@424
   263
    fileFilterSelectAction := anActionBlock
tz@424
   264
!
tz@424
   265
tz@424
   266
fileSelectAction: anActionBlock
tz@424
   267
tz@424
   268
    fileSelectAction := anActionBlock
tz@424
   269
!
tz@424
   270
tz@424
   271
listOfFileFilters: aCollection
tz@424
   272
tz@424
   273
    self listOfFileFilters contents: aCollection.
tz@424
   274
    self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]).
tz@424
   275
!
tz@424
   276
tz@424
   277
monitoring: aBoolean
tz@424
   278
tz@424
   279
    aBoolean
tz@424
   280
    ifTrue:
tz@424
   281
    [
tz@424
   282
        monitoringTimeBlock := [self readDirectory].
tz@424
   283
        self readDirectory.
tz@424
   284
    ]
tz@424
   285
    ifFalse:
tz@424
   286
    [
tz@424
   287
        monitoring ifTrue:
tz@424
   288
        [
tz@424
   289
            Processor removeTimedBlock:monitoringTimeBlock.
tz@424
   290
            monitoringTimeBlock := nil
tz@424
   291
        ]
tz@424
   292
    ].
tz@424
   293
tz@424
   294
    monitoring := aBoolean.
tz@424
   295
tz@424
   296
! !
tz@424
   297
tz@424
   298
!DirectoryView methodsFor:'aspects'!
tz@424
   299
tz@424
   300
fileAttributeColumns
tz@424
   301
tz@424
   302
    |holder|
tz@424
   303
    (holder := builder bindingAt:#fileAttributeColumns) isNil ifTrue:[
tz@424
   304
        |fileAttributeColumns|
tz@424
   305
        builder aspectAt:#fileAttributeColumns put:(holder := List new).
tz@820
   306
        fileAttributeColumns := self class tableColumnsForFileAttributes collect: [:i| i decodeAsLiteralArray].
tz@424
   307
        holder add: fileAttributeColumns first.
tz@424
   308
        fileAttributeColumns do:
tz@424
   309
        [:col|
tz@424
   310
            (fileAttributes includes: col label) ifTrue: [holder add: col]
tz@424
   311
        ].
tz@591
   312
        holder do: [:col| col label: ' ', col label]
tz@424
   313
    ].
tz@424
   314
    ^ holder
tz@424
   315
!
tz@424
   316
tz@424
   317
listOfFileFilters
tz@424
   318
tz@424
   319
    |holder|          
tz@424
   320
    (holder := builder bindingAt:#listOfFileFilters) isNil ifTrue:[
tz@424
   321
        builder aspectAt:#listOfFileFilters put:(holder :=  List with: '*').
tz@424
   322
    ].
tz@424
   323
    ^ holder
tz@424
   324
!
tz@424
   325
tz@424
   326
listOfFiles
tz@424
   327
tz@424
   328
    |holder|
tz@424
   329
    (holder := builder bindingAt:#listOfFiles) isNil ifTrue:[
tz@424
   330
        builder aspectAt:#listOfFiles put:(holder :=  List new).
tz@424
   331
    ].
tz@424
   332
    ^ holder
tz@424
   333
!
tz@424
   334
tz@424
   335
selectionOfFile
tz@424
   336
tz@424
   337
    |holder|
tz@424
   338
    (holder := builder bindingAt:#selectionOfFile) isNil ifTrue:[
tz@424
   339
        builder aspectAt:#selectionOfFile put:(holder :=  ValueHolder new).
tz@424
   340
    ].
tz@424
   341
    ^ holder
tz@424
   342
tz@424
   343
!
tz@424
   344
tz@424
   345
selectionOfFileFilter
tz@424
   346
tz@424
   347
    |holder|
tz@424
   348
    (holder := builder bindingAt:#selectionOfFileFilter) isNil ifTrue:[
tz@424
   349
        builder aspectAt:#selectionOfFileFilter put:
tz@424
   350
        (holder := AspectAdaptor new subject:self; forAspect:#selectedFileFilter).
tz@424
   351
        selectedFileFilter := '*'.
tz@424
   352
    ].
tz@424
   353
    ^ holder
tz@424
   354
! !
tz@424
   355
tz@424
   356
!DirectoryView methodsFor:'callbacks'!
tz@424
   357
tz@424
   358
fileDoubleClicked
tz@424
   359
      
tz@473
   360
    (fileDoubleClickAction notNil and: [self selectionOfFile value notNil]) 
tz@424
   361
    ifTrue: 
tz@424
   362
    [
tz@424
   363
        fileDoubleClickAction numArgs = 0
tz@424
   364
        ifTrue:
tz@424
   365
        [
tz@424
   366
            fileDoubleClickAction value
tz@424
   367
        ].
tz@424
   368
        fileDoubleClickAction numArgs = 1
tz@424
   369
        ifTrue:
tz@451
   370
        [                
tz@451
   371
            fileDoubleClickAction value: (directory asFilename construct: self selectionOfFile value baseName) name
tz@424
   372
        ]
tz@424
   373
    ]
tz@424
   374
!
tz@424
   375
tz@424
   376
fileSelected
tz@424
   377
      
tz@473
   378
    (fileSelectAction notNil and: [self selectionOfFile value notNil]) 
tz@424
   379
    ifTrue: 
tz@424
   380
    [
tz@424
   381
        fileSelectAction numArgs = 0
tz@424
   382
        ifTrue:
tz@424
   383
        [
tz@424
   384
            fileSelectAction value
tz@424
   385
        ].
tz@424
   386
        fileSelectAction numArgs = 1
tz@424
   387
        ifTrue:
tz@424
   388
        [
tz@451
   389
            fileSelectAction value: (directory asFilename construct: self selectionOfFile value baseName) name
tz@424
   390
        ]
tz@424
   391
    ]
tz@424
   392
! !
tz@424
   393
tz@424
   394
!DirectoryView methodsFor:'initialization'!
tz@424
   395
tz@424
   396
initialize
tz@424
   397
tz@424
   398
    super initialize.
cg@874
   399
    self createBuilder.
tz@424
   400
tz@424
   401
    directory :=  directory ? '.' asFilename asAbsoluteFilename directoryName.
tz@424
   402
    monitoring := false.
tz@593
   403
    fileAttributes := #('File name' 'Size' 'Modified').
tz@424
   404
    self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]).
tz@424
   405
cg@874
   406
    "Modified: / 20.6.1998 / 14:46:10 / cg"
tz@424
   407
! !
tz@424
   408
cg@1346
   409
!DirectoryView methodsFor:'menu actions'!
cg@1346
   410
cg@1346
   411
updateFileList
cg@1346
   412
    DirectoryContents flushCache.
cg@1346
   413
    self readDirectory
cg@1346
   414
cg@1346
   415
    "Created: / 11.2.2000 / 00:12:46 / cg"
cg@1346
   416
    "Modified: / 11.2.2000 / 00:14:32 / cg"
cg@1346
   417
! !
cg@1346
   418
tz@424
   419
!DirectoryView methodsFor:'private'!
tz@424
   420
tz@424
   421
readDirectory
cg@2439
   422
    |allDirectories allFiles foundFiles filterList dir newContents|    
tz@424
   423
cg@2439
   424
    allFiles := OrderedCollection new.
cg@2439
   425
    allDirectories := OrderedCollection new.
cg@2439
   426
    foundFiles := OrderedCollection new.
cg@991
   427
    "/ filterList := self listOfFileFilters value.
cg@991
   428
    filterList := self selectedFileFilter asCollectionOfSubstringsSeparatedBy:$;.
cg@991
   429
    filterList := filterList collect:[:pattern | pattern withoutSeparators].
tz@614
   430
cg@999
   431
    self withCursor:Cursor read do:[ 
cg@828
   432
        (dir := DirectoryContents directoryNamed: directory) notNil ifTrue:[
cg@979
   433
"/            dir filesAndBasenamesDo:[:file :name|      
cg@979
   434
"/                filterList do:[:filter|
cg@979
   435
"/                    ((filter match:name) and:[(foundFiles includes: name) not])
cg@979
   436
"/                    ifTrue:[
cg@979
   437
"/                        foundFiles add: name
cg@979
   438
"/                    ].
cg@979
   439
"/                ].
cg@979
   440
"/            ].
cg@979
   441
            dir filesAndBasenamesDo:[:file :name|      
cg@979
   442
                allFiles add: name
tz@590
   443
            ].
cg@2439
   444
            dir directoriesAndBasenamesDo:[:file :name|      
cg@2439
   445
                allDirectories add: name
cg@2439
   446
            ].
cg@991
   447
cg@999
   448
            Filename isCaseSensitive ifFalse:[
cg@999
   449
                filterList do:[:filter|
cg@999
   450
                    |lcFilter|
cg@999
   451
cg@999
   452
                    lcFilter := filter asLowercase.
cg@999
   453
                    foundFiles
cg@999
   454
                        addAll:(allFiles 
cg@999
   455
                                    select:[:name | lcFilter match:name asLowercase]
cg@999
   456
                                ).
cg@999
   457
                ]
cg@999
   458
            ] ifTrue:[
cg@999
   459
                filterList do:[:filter|
cg@999
   460
                    foundFiles
cg@999
   461
                        addAll:(allFiles 
cg@999
   462
                                    select:[:name | filter match:name]
cg@999
   463
                                ).
cg@999
   464
                ]
cg@979
   465
            ].
cg@979
   466
cg@2439
   467
            foundFiles sort.
cg@2439
   468
            allDirectories sort.
cg@2439
   469
cg@979
   470
            dir := directory asFilename.
cg@2439
   471
cg@2439
   472
            newContents := OrderedCollection new.
cg@2439
   473
            newContents addAll:(allDirectories collect:[:name| FileRow new fileName:(dir construct:name)]).
cg@2439
   474
            newContents addAll:(foundFiles collect:[:name| FileRow new fileName:(dir construct:name)]).
cg@2439
   475
cg@2439
   476
            self listOfFiles contents:newContents
cg@828
   477
        ]
tz@590
   478
    ]
tz@614
   479
cg@999
   480
    "Modified: / 23.9.1998 / 17:00:42 / cg"
tz@590
   481
!
tz@590
   482
tz@590
   483
readMonitoringDirectory
tz@590
   484
tz@424
   485
    |readBlock|
tz@424
   486
    readTask notNil ifTrue: [readTask terminate].
tz@424
   487
    readBlock :=
tz@424
   488
    [
tz@424
   489
        |dir currentFilenames oldListOfFiles|
tz@424
   490
        dir := directory asFilename.
tz@424
   491
        currentFilenames := OrderedCollection new.
tz@424
   492
        (dir isReadable and:[dir isExecutable]) ifTrue:
tz@424
   493
        [
tz@424
   494
            self listOfFileFilters value do:
tz@424
   495
            [:filter|
tz@424
   496
                (dir filesMatchingWithoutDotDirs: filter) do:
tz@424
   497
                [:aFileName|
tz@424
   498
                    |file|
tz@424
   499
                    (file := dir construct: aFileName) isDirectory
tz@424
   500
                    ifFalse:
tz@424
   501
                    [
tz@424
   502
                        currentFilenames add: file
tz@424
   503
                    ]
tz@424
   504
                ].
tz@424
   505
            ].
tz@424
   506
        ].
tz@424
   507
        oldListOfFiles := self listOfFiles copy.
tz@424
   508
        (currentFilenames asSortedCollection: [:f1 :f2| f1 baseName < f2 baseName]) asSet do: 
tz@424
   509
        [:fileName| 
tz@424
   510
            (oldListOfFiles detect: [:fileRow| fileRow fileName = fileName] ifNone: nil) isNil
tz@424
   511
            ifTrue:                                                                             
tz@424
   512
            [
tz@424
   513
                |nearestFileRow r|
tz@424
   514
                nearestFileRow := self listOfFiles indexOf: (self listOfFiles detect: [:fileRow| fileRow baseName > fileName baseName] ifNone: nil).
tz@424
   515
                nearestFileRow = 0
tz@424
   516
                ifTrue: [self listOfFiles add: (r := FileRow new fileName: fileName asFilename)]
tz@424
   517
                ifFalse: [self listOfFiles add: (r := FileRow new fileName: fileName asFilename) beforeIndex: nearestFileRow].
tz@424
   518
                monitoring ifTrue: [self selectionOfFile value: r].
tz@424
   519
            ]
tz@424
   520
        ].
tz@424
   521
        self listOfFiles reverseDo:
tz@424
   522
        [:fileRow|
tz@424
   523
            (currentFilenames includes: fileRow fileName)
tz@424
   524
            ifFalse: [self listOfFiles remove: fileRow]
tz@424
   525
        ]
tz@424
   526
    ].
tz@424
   527
tz@424
   528
    monitoring
tz@424
   529
    ifTrue:
tz@424
   530
    [
tz@424
   531
        readTask := readBlock forkAt: Processor userBackgroundPriority.
tz@424
   532
        Processor addTimedBlock: monitoringTimeBlock afterSeconds: 1
tz@424
   533
    ]
tz@424
   534
    ifFalse:
tz@424
   535
    [
tz@424
   536
        Cursor wait showWhile: [readBlock value]
tz@424
   537
    ]
tz@424
   538
! !
tz@424
   539
tz@424
   540
!DirectoryView methodsFor:'selection'!
tz@424
   541
tz@424
   542
selectedFileFilter
tz@424
   543
tz@424
   544
    ^selectedFileFilter
tz@424
   545
tz@424
   546
!
tz@424
   547
cg@999
   548
selectedFileFilter:aString
cg@999
   549
    "change the file filter"
tz@424
   550
cg@999
   551
    |listOfFileFilters nArgs|
cg@999
   552
cg@999
   553
    aString = selectedFileFilter ifTrue:[^ self].
cg@999
   554
cg@999
   555
    listOfFileFilters := self listOfFileFilters.
cg@999
   556
cg@999
   557
    "/ what is this for ?
cg@999
   558
    aString size == 0 ifTrue: [
cg@999
   559
        listOfFileFilters remove: selectedFileFilter ifAbsent: nil
cg@999
   560
    ].
tz@424
   561
    selectedFileFilter := aString.
cg@999
   562
cg@999
   563
    ((listOfFileFilters includes: selectedFileFilter) not
cg@999
   564
    and:[selectedFileFilter notEmpty])
cg@999
   565
    ifTrue: [
cg@999
   566
        listOfFileFilters addFirst: selectedFileFilter
tz@424
   567
    ].
cg@999
   568
    ((listOfFileFilters includes: selectedFileFilter)
cg@999
   569
    and:[fileFilterSelectAction notNil]) 
cg@999
   570
    ifTrue: [
cg@999
   571
        (nArgs := fileFilterSelectAction numArgs) == 0
cg@999
   572
        ifTrue: [
tz@424
   573
            fileFilterSelectAction value
cg@999
   574
        ] ifFalse:[
cg@999
   575
            nArgs == 1 ifTrue:[
cg@999
   576
                fileFilterSelectAction value: selectedFileFilter
cg@999
   577
            ] ifFalse:[
cg@999
   578
                self error:'bad numArgs of fileFilter action block'
cg@999
   579
            ]
tz@424
   580
        ]
tz@424
   581
    ].       
tz@424
   582
    self readDirectory.
cg@999
   583
cg@999
   584
    "Modified: / 23.9.1998 / 16:53:05 / cg"
tz@424
   585
! !
tz@424
   586
tz@424
   587
!DirectoryView methodsFor:'startup / release'!
tz@424
   588
tz@424
   589
closeRequest
tz@424
   590
tz@424
   591
    self release.
tz@424
   592
tz@424
   593
    super closeRequest
tz@424
   594
tz@424
   595
!
tz@424
   596
tz@424
   597
release
tz@424
   598
tz@424
   599
    monitoring ifTrue:
tz@424
   600
    [
tz@424
   601
        Processor removeTimedBlock:monitoringTimeBlock.
tz@424
   602
        monitoringTimeBlock := nil
tz@424
   603
    ].
tz@424
   604
tz@424
   605
    super release
tz@424
   606
tz@424
   607
! !
tz@424
   608
tz@424
   609
!DirectoryView::FileRow class methodsFor:'resources'!
tz@424
   610
tz@424
   611
HFileIcon
tz@424
   612
tz@424
   613
    ^self hFileIcon
tz@424
   614
!
tz@424
   615
tz@424
   616
MakefileIcon
tz@590
   617
    "Generated by the Image Editor"
tz@590
   618
    "
tz@590
   619
    ImageEditor openOnClass:self andSelector:#MakefileIcon
tz@590
   620
    "
tz@424
   621
tz@424
   622
    <resource: #image>
tz@590
   623
tz@590
   624
    ^Icon
tz@590
   625
        constantNamed:#'DirectoryView::FileRow MakefileIcon'
penk@1627
   626
        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]
penk@1627
   627
!
tz@424
   628
tz@424
   629
binaryFileIcon
tz@590
   630
    "Generated by the Image Editor"
tz@590
   631
    "
tz@590
   632
    ImageEditor openOnClass:self andSelector:#binaryFileIcon
tz@590
   633
    "
tz@424
   634
tz@424
   635
    <resource: #image>
tz@590
   636
tz@590
   637
    ^Icon
tz@590
   638
        constantNamed:#'DirectoryView::FileRow binaryFileIcon'
penk@1627
   639
        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]
penk@1627
   640
!
tz@424
   641
tz@424
   642
cFileIcon
tz@590
   643
    "Generated by the Image Editor"
tz@590
   644
    "
tz@590
   645
    ImageEditor openOnClass:self andSelector:#cFileIcon
tz@590
   646
    "
tz@424
   647
tz@424
   648
    <resource: #image>
tz@590
   649
tz@590
   650
    ^Icon
tz@590
   651
        constantNamed:#'DirectoryView::FileRow cFileIcon'
penk@1627
   652
        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]
penk@1627
   653
!
tz@424
   654
tz@424
   655
exeFileIcon
tz@590
   656
    "Generated by the Image Editor"
tz@590
   657
    "
tz@590
   658
    ImageEditor openOnClass:self andSelector:#exeFileIcon
tz@590
   659
    "
tz@424
   660
tz@424
   661
    <resource: #image>
tz@590
   662
tz@590
   663
    ^Icon
tz@590
   664
        constantNamed:#'DirectoryView::FileRow exeFileIcon'
penk@1627
   665
        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]
penk@1627
   666
!
tz@424
   667
tz@424
   668
fileIcon
tz@590
   669
    "Generated by the Image Editor"
tz@590
   670
    "
tz@590
   671
    ImageEditor openOnClass:self andSelector:#fileIcon
tz@590
   672
    "
tz@424
   673
tz@424
   674
    <resource: #image>
tz@590
   675
tz@590
   676
    ^Icon
tz@590
   677
        constantNamed:#'DirectoryView::FileRow fileIcon'
penk@1627
   678
        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]
penk@1627
   679
!
tz@424
   680
tz@424
   681
hFileIcon
tz@590
   682
    "Generated by the Image Editor"
tz@590
   683
    "
tz@590
   684
    ImageEditor openOnClass:self andSelector:#hFileIcon
tz@590
   685
    "
tz@424
   686
tz@424
   687
    <resource: #image>
tz@590
   688
tz@590
   689
    ^Icon
tz@590
   690
        constantNamed:#'DirectoryView::FileRow hFileIcon'
penk@1627
   691
        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]
penk@1627
   692
!
tz@424
   693
tz@644
   694
htmlFileIcon
tz@644
   695
    "Generated by the Image Editor"
tz@644
   696
    "
tz@644
   697
    ImageEditor openOnClass:self andSelector:#htmlFileIcon
tz@644
   698
    "
tz@424
   699
tz@424
   700
    <resource: #image>
tz@644
   701
tz@644
   702
    ^Icon
tz@644
   703
        constantNamed:#'DirectoryView::FileRow htmlFileIcon'
penk@1627
   704
        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]
penk@1627
   705
!
tz@644
   706
tz@644
   707
imageFileIcon
tz@644
   708
    "Generated by the Image Editor"
tz@644
   709
    "
tz@644
   710
    ImageEditor openOnClass:self andSelector:#imageFileIcon
tz@644
   711
    "
tz@644
   712
tz@644
   713
    <resource: #image>
tz@644
   714
tz@644
   715
    ^Icon
tz@644
   716
        constantNamed:#'DirectoryView::FileRow imageFileIcon'
penk@1627
   717
        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]
penk@1627
   718
!
tz@424
   719
tz@424
   720
imgFileIcon
tz@590
   721
    "Generated by the Image Editor"
tz@590
   722
    "
tz@590
   723
    ImageEditor openOnClass:self andSelector:#imgFileIcon
tz@590
   724
    "
tz@424
   725
tz@424
   726
    <resource: #image>
tz@590
   727
tz@590
   728
    ^Icon
tz@590
   729
        constantNamed:#'DirectoryView::FileRow imgFileIcon'
tz@644
   730
        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]
tz@644
   731
!
tz@424
   732
tz@424
   733
linkedFileIcon
tz@644
   734
    "Generated by the Image Editor"
tz@644
   735
    "
tz@644
   736
    ImageEditor openOnClass:self andSelector:#linkedFileIcon
tz@644
   737
    "
tz@424
   738
tz@424
   739
    <resource: #image>
tz@644
   740
tz@644
   741
    ^Icon
tz@644
   742
        constantNamed:#'DirectoryView::FileRow linkedFileIcon'
penk@1627
   743
        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]
penk@1627
   744
!
tz@424
   745
tz@424
   746
lockedFileIcon
tz@644
   747
    "Generated by the Image Editor"
tz@644
   748
    "
tz@644
   749
    ImageEditor openOnClass:self andSelector:#lockedFileIcon
tz@644
   750
    "
tz@424
   751
tz@424
   752
    <resource: #image>
tz@644
   753
tz@644
   754
    ^Icon
tz@644
   755
        constantNamed:#'DirectoryView::FileRow lockedFileIcon'
penk@1627
   756
        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]
penk@1627
   757
!
tz@424
   758
tz@424
   759
protoFileIcon
tz@424
   760
tz@424
   761
    ^self MakefileIcon
tz@424
   762
!
tz@424
   763
tz@424
   764
rcFileIcon
tz@644
   765
    "Generated by the Image Editor"
tz@644
   766
    "
tz@644
   767
    ImageEditor openOnClass:self andSelector:#rcFileIcon
tz@644
   768
    "
tz@424
   769
tz@424
   770
    <resource: #image>
tz@644
   771
tz@644
   772
    ^Icon
tz@644
   773
        constantNamed:#'DirectoryView::FileRow rcFileIcon'
penk@1627
   774
        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]
penk@1627
   775
!
tz@424
   776
tz@424
   777
sFileIcon
tz@644
   778
    "Generated by the Image Editor"
tz@644
   779
    "
tz@644
   780
    ImageEditor openOnClass:self andSelector:#sFileIcon
tz@644
   781
    "
tz@424
   782
tz@424
   783
    <resource: #image>
tz@644
   784
tz@644
   785
    ^Icon
tz@644
   786
        constantNamed:#'DirectoryView::FileRow sFileIcon'
penk@1627
   787
        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]
penk@1627
   788
!
tz@424
   789
tz@424
   790
stFileIcon
tz@590
   791
    "Generated by the Image Editor"
tz@590
   792
    "
tz@590
   793
    ImageEditor openOnClass:self andSelector:#stFileIcon
tz@590
   794
    "
tz@424
   795
tz@424
   796
    <resource: #image>
tz@590
   797
tz@590
   798
    ^Icon
tz@590
   799
        constantNamed:#'DirectoryView::FileRow stFileIcon'
penk@1627
   800
        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]
penk@1627
   801
!
tz@424
   802
tz@424
   803
stcFileIcon
tz@644
   804
    "Generated by the Image Editor"
tz@644
   805
    "
tz@644
   806
    ImageEditor openOnClass:self andSelector:#stcFileIcon
tz@644
   807
    "
tz@424
   808
tz@424
   809
    <resource: #image>
tz@644
   810
tz@644
   811
    ^Icon
tz@644
   812
        constantNamed:#'DirectoryView::FileRow stcFileIcon'
penk@1627
   813
        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]
penk@1627
   814
! !
tz@424
   815
tz@424
   816
!DirectoryView::FileRow methodsFor:'accessing'!
tz@424
   817
tz@424
   818
baseName
tz@424
   819
tz@424
   820
    ^baseName ? (baseName := fileName baseName)
tz@424
   821
tz@424
   822
tz@424
   823
tz@424
   824
tz@424
   825
tz@424
   826
tz@424
   827
tz@424
   828
!
tz@424
   829
tz@424
   830
fileName
tz@424
   831
tz@424
   832
    ^fileName
tz@424
   833
!
tz@424
   834
tz@424
   835
fileName: aFileName
tz@424
   836
tz@614
   837
    fileName := aFileName
tz@424
   838
!
tz@424
   839
tz@424
   840
group
tz@424
   841
tz@424
   842
    ^group
tz@424
   843
!
tz@424
   844
tz@424
   845
iconOn:aGC
tz@424
   846
tz@638
   847
    |icon|
tz@638
   848
    iconKey isNil 
tz@638
   849
    ifTrue: 
tz@424
   850
    [
tz@614
   851
        self validateAttributes.
tz@638
   852
        (imageFromFile isNil and: [iconKey == #imageFileIcon])
tz@638
   853
            ifTrue:  [icon := self retrieveImageFromFileAndRegisterOn: aGC]
tz@424
   854
    ].
cg@645
   855
    imageFromFile == true
tz@638
   856
        ifFalse: [icon := aGC registerImage: (self class perform: iconKey) key: iconKey]
tz@638
   857
        ifTrue:  [icon := aGC registeredImageAt: iconKey].
tz@638
   858
    ^icon
cg@645
   859
cg@645
   860
    "Modified: / 18.2.1998 / 18:01:52 / cg"
tz@424
   861
!
tz@424
   862
tz@424
   863
modified
tz@424
   864
tz@424
   865
    ^modified
tz@424
   866
!
tz@424
   867
tz@424
   868
owner
tz@424
   869
tz@424
   870
    ^owner
tz@424
   871
!
tz@424
   872
tz@424
   873
permissions
tz@424
   874
tz@424
   875
    ^permissions
tz@424
   876
!
tz@424
   877
tz@638
   878
retrieveImageFromFileAndRegisterOn: aGC
cg@1385
   879
    "retrieve a bitmap image - but only if it is smaller than some limit (currently 20k)"
tz@638
   880
cg@1385
   881
    |image maxImageFileSize|
cg@1385
   882
cg@1385
   883
    maxImageFileSize := MaxImageFileSize ? 20000.
cg@1385
   884
tz@638
   885
    imageFromFile := false.       
tz@638
   886
    (image := aGC registeredImageAt: fileName name asSymbol) isNil
cg@1385
   887
    ifTrue:[            
cg@1385
   888
        size < maxImageFileSize ifTrue:[     
tz@638
   889
            Object errorSignal handle: [:ex|]
cg@1385
   890
            do:[   
cg@1385
   891
                (image := Image fromFile: fileName name) notNil ifTrue:[
cg@1385
   892
                    image extent y > 22 ifTrue:[         
tz@638
   893
                        image := image magnifiedBy: 22/image extent y
tz@638
   894
                    ].
tz@638
   895
                    image := aGC registerImage: image key: fileName name asSymbol.
tz@638
   896
                ]
tz@638
   897
            ] 
tz@638
   898
        ].
tz@638
   899
    ].
tz@638
   900
    image notNil ifTrue: [imageFromFile := true. iconKey := fileName name asSymbol].
tz@638
   901
    ^image
tz@638
   902
tz@638
   903
tz@638
   904
tz@638
   905
!
tz@638
   906
tz@424
   907
size
cg@607
   908
    size isNumber ifFalse:[^ size].
cg@607
   909
    size < 1000        ifTrue: [^ size printString].
cg@607
   910
    size < (100*1024)  ifTrue: [^(((size/1024) * 10) asInteger/10) asFloat printString, ' Kb'].
cg@607
   911
    size < (1000*1024) ifTrue: [^(((size/1024)) asInteger) printString, ' Kb'].
cg@607
   912
    ^(((size/1048576) * 10) asInteger/10) asFloat printString, ' Mb'
tz@424
   913
cg@607
   914
    "Modified: / 6.2.1998 / 03:38:45 / cg"
tz@424
   915
! !
tz@424
   916
tz@424
   917
!DirectoryView::FileRow methodsFor:'private'!
tz@424
   918
tz@424
   919
validateAttributes
tz@424
   920
tz@638
   921
    |info mode| 
tz@638
   922
tz@424
   923
    permissions := String new:9 withAll:$-.
tz@424
   924
tz@424
   925
    (info := fileName info) isNil
tz@424
   926
    ifTrue:
tz@424
   927
    [
tz@424
   928
        iconKey := #lockedFileIcon.
tz@424
   929
        size    := owner := group := '?'.
tz@424
   930
      ^ self
tz@424
   931
    ].        
tz@424
   932
    size   := info size.
penk@1627
   933
    modified := info modificationTime printString.
tz@424
   934
    owner  := OperatingSystem getUserNameFromID: info uid.
tz@424
   935
    group  := OperatingSystem getGroupNameFromID: info gid.
tz@424
   936
    mode   := info mode.
tz@424
   937
tz@424
   938
    1 to:9 by:3 do:[:i|
tz@424
   939
        #((0 $x) (1 $w) (2 $r)) do:
tz@424
   940
        [:m|
tz@424
   941
            (mode bitAt:i + m first) == 1 ifTrue:[permissions at: 10 - m first - i put: m last]
tz@424
   942
        ]
tz@424
   943
    ].
tz@424
   944
tz@424
   945
    fileName isReadable
tz@424
   946
    ifTrue:
tz@424
   947
    [
tz@424
   948
        info type == #symbolicLink
tz@424
   949
        ifTrue:
tz@424
   950
        [
tz@424
   951
            ^iconKey := #linkedFileIcon
tz@424
   952
        ]
tz@424
   953
        ifFalse:
tz@424
   954
        [       
tz@424
   955
            ((DirectoryView::FileRow class implements: (iconKey := (fileName suffix, 'FileIcon') asSymbol))
tz@424
   956
            or:
tz@424
   957
            [DirectoryView::FileRow class implements: (iconKey := (fileName baseName, 'Icon') asSymbol)])
tz@424
   958
            ifFalse:
tz@424
   959
            [
tz@424
   960
                iconKey := #fileIcon.
tz@424
   961
                (Image isImageFileSuffix:fileName suffix)
tz@424
   962
                ifTrue:
tz@424
   963
                [
tz@424
   964
                    ^iconKey := #imageFileIcon
tz@424
   965
                ].
tz@424
   966
                (fileName suffix = 'o') | (fileName suffix = 'so')
tz@424
   967
                ifTrue:
tz@424
   968
                [
tz@424
   969
                    ^iconKey := #binaryFileIcon
tz@424
   970
                ].
tz@424
   971
tz@424
   972
                fileName isExecutableProgram
tz@424
   973
                ifTrue:
tz@424
   974
                [
tz@424
   975
                    ^iconKey := #exeFileIcon
tz@424
   976
                ]
tz@424
   977
            ]
tz@424
   978
        ]
tz@424
   979
    ] 
tz@424
   980
    ifFalse:
tz@424
   981
    [
tz@424
   982
        ^iconKey := #lockedFileIcon
tz@424
   983
    ].
tz@424
   984
! !
tz@424
   985
tz@424
   986
!DirectoryView class methodsFor:'documentation'!
tz@424
   987
tz@424
   988
version
tz@424
   989
    ^ '$Header$'
tz@424
   990
! !