DirectoryView.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3366 70c6139984a6
child 3491 c1333ee85336
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present

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