DirectoryView.st
author Claus Gittinger <cg@exept.de>
Tue, 14 May 2019 09:46:21 +0200
changeset 3663 9d49ecf8661a
parent 3634 b97f51aaa9ac
child 3669 650468354956
permissions -rw-r--r--
#UI_ENHANCEMENT by cg
class: TabListEditor class
changed:
#canvasSpec
#menu
#windowSpec
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
          #bounds: #(#Rectangle 13 23 413 323)
cg@1346
   102
        )
cg@1346
   103
        #component: 
cg@1346
   104
       #(#SpecCollection
cg@1346
   105
          #collection: #(
cg@1346
   106
           #(#DataSetSpec
cg@1346
   107
              #name: 'filesDataSetView'
cg@1346
   108
              #layout: #(#LayoutFrame 0 0.0 24 0.0 -2 1.0 0 1.0)
cg@1346
   109
              #model: #selectionOfFile
cg@1346
   110
              #menu: #fileListMenu
cg@1346
   111
              #hasHorizontalScrollBar: true
cg@1346
   112
              #hasVerticalScrollBar: true
cg@1346
   113
              #miniScrollerHorizontal: true
cg@1346
   114
              #dataList: #listOfFiles
cg@1346
   115
              #useIndex: false
cg@1346
   116
              #has3Dsepartors: false
cg@1346
   117
              #doubleClickSelector: #fileDoubleClicked
cg@1346
   118
              #columnHolder: #fileAttributeColumns
cg@1346
   119
              #valueChangeSelector: #fileSelected
cg@1346
   120
              #verticalSpacing: 1
cg@1346
   121
            )
cg@1346
   122
           #(#ComboBoxSpec
cg@1346
   123
              #name: 'formatComboBox'
cg@1346
   124
              #layout: #(#LayoutFrame 63 0.0 0 0 0 1.0 22 0)
cg@1346
   125
              #model: #selectionOfFileFilter
cg@1346
   126
              #immediateAccept: false
cg@1346
   127
              #acceptOnTab: false
cg@1346
   128
              #acceptOnPointerLeave: false
cg@1346
   129
              #comboList: #listOfFileFilters
cg@1346
   130
            )
cg@1346
   131
           #(#LabelSpec
cg@1346
   132
              #label: 'Filter: '
cg@1346
   133
              #name: 'filterLabel'
cg@1346
   134
              #layout: #(#LayoutFrame 0 0 0 0 62 0 22 0)
cg@1346
   135
              #adjust: #right
cg@1346
   136
            )
cg@1346
   137
           )
cg@1346
   138
         
cg@1346
   139
        )
tz@424
   140
      )
cg@1346
   141
cg@1346
   142
    "Modified: / 11.2.2000 / 00:11:43 / cg"
tz@424
   143
! !
tz@424
   144
tz@823
   145
!DirectoryView class methodsFor:'list specs'!
tz@823
   146
tz@823
   147
tableColumnsForFileAttributes
tz@823
   148
    "This resource specification was automatically generated
tz@823
   149
     by the DataSetBuilder of ST/X."
tz@823
   150
tz@823
   151
    "Do not manually edit this!! If it is corrupted,
tz@823
   152
     the DataSetBuilder may not be able to read the specification."
tz@823
   153
tz@823
   154
    "
tz@823
   155
     DataSetBuilder new openOnClass:DirectoryView andSelector:#tableColumnsForFileAttributes
tz@823
   156
    "
tz@823
   157
tz@823
   158
    <resource: #tableColumns>
tz@823
   159
tz@823
   160
tz@823
   161
    ^ #(
tz@823
   162
        #(#DataSetColumnSpec
tz@823
   163
           #label: ''
tz@823
   164
           #width: 30
tz@823
   165
           #height: 22
tz@823
   166
           #printSelector: #iconOn:
tz@823
   167
           #canSelect: false
tz@823
   168
       )
tz@823
   169
        #(#DataSetColumnSpec
tz@823
   170
           #label: 'File name'
tz@823
   171
           #labelAlignment: #left
tz@823
   172
           #minWidth: 150
tz@823
   173
           #model: #baseName
tz@823
   174
           #canSelect: false
tz@823
   175
       )
tz@823
   176
        #(#DataSetColumnSpec
tz@823
   177
           #label: 'Size'
tz@823
   178
           #labelAlignment: #left
tz@823
   179
           #width: 70
tz@823
   180
           #model: #size
tz@823
   181
           #canSelect: false
tz@823
   182
       )
tz@823
   183
        #(#DataSetColumnSpec
tz@823
   184
           #label: 'Modified'
tz@823
   185
           #labelAlignment: #left
tz@823
   186
           #model: #modified
tz@823
   187
           #canSelect: false
tz@823
   188
       )
tz@823
   189
        #(#DataSetColumnSpec
tz@823
   190
           #label: 'Permissions'
tz@823
   191
           #labelAlignment: #left
tz@823
   192
           #width: 85
tz@823
   193
           #model: #permissions
tz@823
   194
           #canSelect: false
tz@823
   195
       )
tz@823
   196
        #(#DataSetColumnSpec
tz@823
   197
           #label: 'Owner'
tz@823
   198
           #labelAlignment: #left
tz@823
   199
           #width: 50
tz@823
   200
           #model: #owner
tz@823
   201
           #canSelect: false
tz@823
   202
       )
tz@823
   203
        #(#DataSetColumnSpec
tz@823
   204
           #label: 'Group'
tz@823
   205
           #labelAlignment: #left
tz@823
   206
           #width: 50
tz@823
   207
           #model: #group
tz@823
   208
           #canSelect: false
tz@823
   209
       )
tz@823
   210
     )
tz@823
   211
! !
tz@823
   212
cg@1346
   213
!DirectoryView class methodsFor:'menu specs'!
cg@1346
   214
cg@1346
   215
fileListMenu
cg@1346
   216
    "This resource specification was automatically generated
cg@1346
   217
     by the MenuEditor of ST/X."
cg@1346
   218
cg@1346
   219
    "Do not manually edit this!! If it is corrupted,
cg@1346
   220
     the MenuEditor may not be able to read the specification."
cg@1346
   221
cg@1346
   222
    "
cg@1346
   223
     MenuEditor new openOnClass:DirectoryView andSelector:#fileListMenu
cg@1346
   224
     (Menu new fromLiteralArrayEncoding:(DirectoryView fileListMenu)) startUp
cg@1346
   225
    "
cg@1346
   226
cg@1346
   227
    <resource: #menu>
cg@1346
   228
cg@1346
   229
    ^ 
cg@1346
   230
     #(#Menu
cg@1346
   231
        #(
cg@1346
   232
         #(#MenuItem
cg@1346
   233
            #label: 'Update'
cg@1346
   234
            #translateLabel: true
cg@1346
   235
            #value: #updateFileList
cg@1346
   236
          )
cg@1346
   237
         )
cg@1346
   238
        nil
cg@1346
   239
        nil
cg@1346
   240
      )
cg@1346
   241
cg@1346
   242
    "Created: / 11.2.2000 / 00:11:39 / cg"
cg@1346
   243
! !
cg@1346
   244
tz@424
   245
!DirectoryView methodsFor:'accessing'!
tz@424
   246
tz@424
   247
directory: aDirectory
tz@424
   248
tz@424
   249
    directory := aDirectory asFilename asAbsoluteFilename name
tz@424
   250
!
tz@424
   251
tz@424
   252
fileAttributes: anArray
tz@424
   253
tz@424
   254
    fileAttributes := anArray
tz@424
   255
!
tz@424
   256
tz@424
   257
fileDoubleClickAction: anActionBlock
tz@424
   258
tz@424
   259
    fileDoubleClickAction := anActionBlock
tz@424
   260
!
tz@424
   261
tz@424
   262
fileFilterSelectAction: anActionBlock
tz@424
   263
tz@424
   264
    fileFilterSelectAction := anActionBlock
tz@424
   265
!
tz@424
   266
tz@424
   267
fileSelectAction: anActionBlock
tz@424
   268
tz@424
   269
    fileSelectAction := anActionBlock
tz@424
   270
!
tz@424
   271
tz@424
   272
listOfFileFilters: aCollection
tz@424
   273
tz@424
   274
    self listOfFileFilters contents: aCollection.
tz@424
   275
    self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]).
tz@424
   276
!
tz@424
   277
tz@424
   278
monitoring: aBoolean
tz@424
   279
tz@424
   280
    aBoolean
tz@424
   281
    ifTrue:
tz@424
   282
    [
tz@424
   283
        monitoringTimeBlock := [self readDirectory].
tz@424
   284
        self readDirectory.
tz@424
   285
    ]
tz@424
   286
    ifFalse:
tz@424
   287
    [
tz@424
   288
        monitoring ifTrue:
tz@424
   289
        [
tz@424
   290
            Processor removeTimedBlock:monitoringTimeBlock.
tz@424
   291
            monitoringTimeBlock := nil
tz@424
   292
        ]
tz@424
   293
    ].
tz@424
   294
tz@424
   295
    monitoring := aBoolean.
tz@424
   296
tz@424
   297
! !
tz@424
   298
tz@424
   299
!DirectoryView methodsFor:'aspects'!
tz@424
   300
tz@424
   301
fileAttributeColumns
tz@424
   302
tz@424
   303
    |holder|
tz@424
   304
    (holder := builder bindingAt:#fileAttributeColumns) isNil ifTrue:[
tz@424
   305
        |fileAttributeColumns|
tz@424
   306
        builder aspectAt:#fileAttributeColumns put:(holder := List new).
tz@820
   307
        fileAttributeColumns := self class tableColumnsForFileAttributes collect: [:i| i decodeAsLiteralArray].
tz@424
   308
        holder add: fileAttributeColumns first.
tz@424
   309
        fileAttributeColumns do:
tz@424
   310
        [:col|
tz@424
   311
            (fileAttributes includes: col label) ifTrue: [holder add: col]
tz@424
   312
        ].
tz@591
   313
        holder do: [:col| col label: ' ', col label]
tz@424
   314
    ].
tz@424
   315
    ^ holder
tz@424
   316
!
tz@424
   317
tz@424
   318
listOfFileFilters
tz@424
   319
tz@424
   320
    |holder|          
tz@424
   321
    (holder := builder bindingAt:#listOfFileFilters) isNil ifTrue:[
tz@424
   322
        builder aspectAt:#listOfFileFilters put:(holder :=  List with: '*').
tz@424
   323
    ].
tz@424
   324
    ^ holder
tz@424
   325
!
tz@424
   326
tz@424
   327
listOfFiles
tz@424
   328
tz@424
   329
    |holder|
tz@424
   330
    (holder := builder bindingAt:#listOfFiles) isNil ifTrue:[
tz@424
   331
        builder aspectAt:#listOfFiles put:(holder :=  List new).
tz@424
   332
    ].
tz@424
   333
    ^ holder
tz@424
   334
!
tz@424
   335
tz@424
   336
selectionOfFile
tz@424
   337
tz@424
   338
    |holder|
tz@424
   339
    (holder := builder bindingAt:#selectionOfFile) isNil ifTrue:[
tz@424
   340
        builder aspectAt:#selectionOfFile put:(holder :=  ValueHolder new).
tz@424
   341
    ].
tz@424
   342
    ^ holder
tz@424
   343
tz@424
   344
!
tz@424
   345
tz@424
   346
selectionOfFileFilter
tz@424
   347
tz@424
   348
    |holder|
tz@424
   349
    (holder := builder bindingAt:#selectionOfFileFilter) isNil ifTrue:[
tz@424
   350
        builder aspectAt:#selectionOfFileFilter put:
tz@424
   351
        (holder := AspectAdaptor new subject:self; forAspect:#selectedFileFilter).
tz@424
   352
        selectedFileFilter := '*'.
tz@424
   353
    ].
tz@424
   354
    ^ holder
tz@424
   355
! !
tz@424
   356
tz@424
   357
!DirectoryView methodsFor:'callbacks'!
tz@424
   358
tz@424
   359
fileDoubleClicked
tz@424
   360
      
tz@473
   361
    (fileDoubleClickAction notNil and: [self selectionOfFile value notNil]) 
tz@424
   362
    ifTrue: 
tz@424
   363
    [
tz@424
   364
        fileDoubleClickAction numArgs = 0
tz@424
   365
        ifTrue:
tz@424
   366
        [
tz@424
   367
            fileDoubleClickAction value
tz@424
   368
        ].
tz@424
   369
        fileDoubleClickAction numArgs = 1
tz@424
   370
        ifTrue:
tz@451
   371
        [                
tz@451
   372
            fileDoubleClickAction value: (directory asFilename construct: self selectionOfFile value baseName) name
tz@424
   373
        ]
tz@424
   374
    ]
tz@424
   375
!
tz@424
   376
tz@424
   377
fileSelected
tz@424
   378
      
tz@473
   379
    (fileSelectAction notNil and: [self selectionOfFile value notNil]) 
tz@424
   380
    ifTrue: 
tz@424
   381
    [
tz@424
   382
        fileSelectAction numArgs = 0
tz@424
   383
        ifTrue:
tz@424
   384
        [
tz@424
   385
            fileSelectAction value
tz@424
   386
        ].
tz@424
   387
        fileSelectAction numArgs = 1
tz@424
   388
        ifTrue:
tz@424
   389
        [
tz@451
   390
            fileSelectAction value: (directory asFilename construct: self selectionOfFile value baseName) name
tz@424
   391
        ]
tz@424
   392
    ]
tz@424
   393
! !
tz@424
   394
tz@424
   395
!DirectoryView methodsFor:'initialization'!
tz@424
   396
tz@424
   397
initialize
tz@424
   398
tz@424
   399
    super initialize.
cg@874
   400
    self createBuilder.
tz@424
   401
cg@3044
   402
    directory :=  (directory ? '.') asFilename asAbsoluteFilename directoryName.
tz@424
   403
    monitoring := false.
tz@593
   404
    fileAttributes := #('File name' 'Size' 'Modified').
tz@424
   405
    self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]).
tz@424
   406
cg@874
   407
    "Modified: / 20.6.1998 / 14:46:10 / cg"
tz@424
   408
! !
tz@424
   409
cg@2878
   410
!DirectoryView methodsFor:'initialize-release'!
cg@2878
   411
cg@2878
   412
release
cg@2878
   413
cg@2878
   414
    monitoring ifTrue:
cg@2878
   415
    [
cg@2878
   416
        Processor removeTimedBlock:monitoringTimeBlock.
cg@2878
   417
        monitoringTimeBlock := nil
cg@2878
   418
    ].
cg@2878
   419
cg@2878
   420
    super release
cg@2878
   421
cg@2878
   422
! !
cg@2878
   423
cg@1346
   424
!DirectoryView methodsFor:'menu actions'!
cg@1346
   425
cg@1346
   426
updateFileList
cg@1346
   427
    DirectoryContents flushCache.
cg@1346
   428
    self readDirectory
cg@1346
   429
cg@1346
   430
    "Created: / 11.2.2000 / 00:12:46 / cg"
cg@1346
   431
    "Modified: / 11.2.2000 / 00:14:32 / cg"
cg@1346
   432
! !
cg@1346
   433
tz@424
   434
!DirectoryView methodsFor:'private'!
tz@424
   435
tz@424
   436
readDirectory
cg@2439
   437
    |allDirectories allFiles foundFiles filterList dir newContents|    
tz@424
   438
cg@2439
   439
    allFiles := OrderedCollection new.
cg@2439
   440
    allDirectories := OrderedCollection new.
cg@2439
   441
    foundFiles := OrderedCollection new.
cg@991
   442
    "/ filterList := self listOfFileFilters value.
cg@991
   443
    filterList := self selectedFileFilter asCollectionOfSubstringsSeparatedBy:$;.
cg@991
   444
    filterList := filterList collect:[:pattern | pattern withoutSeparators].
tz@614
   445
cg@999
   446
    self withCursor:Cursor read do:[ 
cg@828
   447
        (dir := DirectoryContents directoryNamed: directory) notNil ifTrue:[
cg@979
   448
"/            dir filesAndBasenamesDo:[:file :name|      
cg@979
   449
"/                filterList do:[:filter|
cg@979
   450
"/                    ((filter match:name) and:[(foundFiles includes: name) not])
cg@979
   451
"/                    ifTrue:[
cg@979
   452
"/                        foundFiles add: name
cg@979
   453
"/                    ].
cg@979
   454
"/                ].
cg@979
   455
"/            ].
cg@979
   456
            dir filesAndBasenamesDo:[:file :name|      
cg@979
   457
                allFiles add: name
tz@590
   458
            ].
cg@2439
   459
            dir directoriesAndBasenamesDo:[:file :name|      
cg@2439
   460
                allDirectories add: name
cg@2439
   461
            ].
cg@991
   462
cg@999
   463
            Filename isCaseSensitive ifFalse:[
cg@999
   464
                filterList do:[:filter|
cg@999
   465
                    |lcFilter|
cg@999
   466
cg@999
   467
                    lcFilter := filter asLowercase.
cg@999
   468
                    foundFiles
cg@999
   469
                        addAll:(allFiles 
cg@999
   470
                                    select:[:name | lcFilter match:name asLowercase]
cg@999
   471
                                ).
cg@999
   472
                ]
cg@999
   473
            ] ifTrue:[
cg@999
   474
                filterList do:[:filter|
cg@999
   475
                    foundFiles
cg@999
   476
                        addAll:(allFiles 
cg@999
   477
                                    select:[:name | filter match:name]
cg@999
   478
                                ).
cg@999
   479
                ]
cg@979
   480
            ].
cg@979
   481
cg@2439
   482
            foundFiles sort.
cg@2439
   483
            allDirectories sort.
cg@2439
   484
cg@979
   485
            dir := directory asFilename.
cg@2439
   486
cg@2439
   487
            newContents := OrderedCollection new.
cg@2439
   488
            newContents addAll:(allDirectories collect:[:name| FileRow new fileName:(dir construct:name)]).
cg@2439
   489
            newContents addAll:(foundFiles collect:[:name| FileRow new fileName:(dir construct:name)]).
cg@2439
   490
cg@2439
   491
            self listOfFiles contents:newContents
cg@828
   492
        ]
tz@590
   493
    ]
tz@614
   494
cg@999
   495
    "Modified: / 23.9.1998 / 17:00:42 / cg"
tz@590
   496
!
tz@590
   497
tz@590
   498
readMonitoringDirectory
sv@3597
   499
    <resource: #obsolete>
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
cg@3563
   611
    "/ is this needed? - I think release is sent anyway by super...
tz@424
   612
    self release.
tz@424
   613
tz@424
   614
    super closeRequest
tz@424
   615
cg@3563
   616
    "Modified (comment): / 28-05-2018 / 09:50:20 / Claus Gittinger"
tz@424
   617
! !
tz@424
   618
tz@424
   619
!DirectoryView::FileRow class methodsFor:'resources'!
tz@424
   620
tz@424
   621
HFileIcon
tz@424
   622
tz@424
   623
    ^self hFileIcon
tz@424
   624
!
tz@424
   625
tz@424
   626
MakefileIcon
cg@3298
   627
    "This resource specification was automatically generated
cg@3298
   628
     by the ImageEditor of ST/X."
cg@3298
   629
cg@3298
   630
    "Do not manually edit this!! If it is corrupted,
cg@3298
   631
     the ImageEditor may not be able to read the specification."
cg@3298
   632
tz@590
   633
    "
cg@3298
   634
     self MakefileIcon inspect
cg@3298
   635
     ImageEditor openOnClass:self andSelector:#MakefileIcon
cg@3298
   636
     Icon flushCachedIcons
tz@590
   637
    "
tz@424
   638
tz@424
   639
    <resource: #image>
tz@590
   640
tz@590
   641
    ^Icon
cg@3298
   642
        constantNamed:'DirectoryView::FileRow MakefileIcon'
cg@3298
   643
        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
   644
            colorMapFromArray:#[255 255 255 0 0 0]
cg@3298
   645
            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
   646
!
tz@424
   647
tz@424
   648
binaryFileIcon
cg@3298
   649
    "This resource specification was automatically generated
cg@3298
   650
     by the ImageEditor of ST/X."
cg@3298
   651
cg@3298
   652
    "Do not manually edit this!! If it is corrupted,
cg@3298
   653
     the ImageEditor may not be able to read the specification."
cg@3298
   654
tz@590
   655
    "
cg@3298
   656
     self binaryFileIcon inspect
cg@3298
   657
     ImageEditor openOnClass:self andSelector:#binaryFileIcon
cg@3298
   658
     Icon flushCachedIcons
tz@590
   659
    "
tz@424
   660
tz@424
   661
    <resource: #image>
tz@590
   662
tz@590
   663
    ^Icon
cg@3298
   664
        constantNamed:'DirectoryView::FileRow binaryFileIcon'
cg@3298
   665
        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
   666
            colorMapFromArray:#[255 255 255 0 0 0]
cg@3298
   667
            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
   668
!
tz@424
   669
tz@424
   670
cFileIcon
cg@3298
   671
    "This resource specification was automatically generated
cg@3298
   672
     by the ImageEditor of ST/X."
cg@3298
   673
cg@3298
   674
    "Do not manually edit this!! If it is corrupted,
cg@3298
   675
     the ImageEditor may not be able to read the specification."
cg@3298
   676
tz@590
   677
    "
cg@3298
   678
     self cFileIcon inspect
cg@3298
   679
     ImageEditor openOnClass:self andSelector:#cFileIcon
cg@3298
   680
     Icon flushCachedIcons
tz@590
   681
    "
tz@424
   682
tz@424
   683
    <resource: #image>
tz@590
   684
tz@590
   685
    ^Icon
cg@3298
   686
        constantNamed:'DirectoryView::FileRow cFileIcon'
cg@3298
   687
        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
   688
            colorMapFromArray:#[255 255 255 0 0 0]
cg@3298
   689
            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
   690
!
tz@424
   691
tz@424
   692
exeFileIcon
cg@3298
   693
    "This resource specification was automatically generated
cg@3298
   694
     by the ImageEditor of ST/X."
cg@3298
   695
cg@3298
   696
    "Do not manually edit this!! If it is corrupted,
cg@3298
   697
     the ImageEditor may not be able to read the specification."
cg@3298
   698
tz@590
   699
    "
cg@3298
   700
     self exeFileIcon inspect
cg@3298
   701
     ImageEditor openOnClass:self andSelector:#exeFileIcon
cg@3298
   702
     Icon flushCachedIcons
tz@590
   703
    "
tz@424
   704
tz@424
   705
    <resource: #image>
tz@590
   706
tz@590
   707
    ^Icon
cg@3298
   708
        constantNamed:'DirectoryView::FileRow exeFileIcon'
cg@3298
   709
        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
   710
UUUUUUTb')
cg@3298
   711
            colorMapFromArray:#[255 255 255 0 0 0 0 127 127 170 170 170]
cg@3298
   712
            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
   713
!
tz@424
   714
tz@424
   715
fileIcon
tz@590
   716
    "Generated by the Image Editor"
tz@590
   717
    "
tz@590
   718
    ImageEditor openOnClass:self andSelector:#fileIcon
tz@590
   719
    "
tz@424
   720
tz@424
   721
    <resource: #image>
tz@590
   722
tz@590
   723
    ^Icon
tz@590
   724
        constantNamed:#'DirectoryView::FileRow fileIcon'
penk@1627
   725
        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
   726
!
tz@424
   727
tz@424
   728
hFileIcon
tz@590
   729
    "Generated by the Image Editor"
tz@590
   730
    "
tz@590
   731
    ImageEditor openOnClass:self andSelector:#hFileIcon
tz@590
   732
    "
tz@424
   733
tz@424
   734
    <resource: #image>
tz@590
   735
tz@590
   736
    ^Icon
tz@590
   737
        constantNamed:#'DirectoryView::FileRow hFileIcon'
penk@1627
   738
        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
   739
!
tz@424
   740
tz@644
   741
htmlFileIcon
cg@3298
   742
    "This resource specification was automatically generated
cg@3298
   743
     by the ImageEditor of ST/X."
cg@3298
   744
cg@3298
   745
    "Do not manually edit this!! If it is corrupted,
cg@3298
   746
     the ImageEditor may not be able to read the specification."
cg@3298
   747
tz@644
   748
    "
cg@3298
   749
     self htmlFileIcon inspect
cg@3298
   750
     ImageEditor openOnClass:self andSelector:#htmlFileIcon
cg@3298
   751
     Icon flushCachedIcons
tz@644
   752
    "
tz@424
   753
tz@424
   754
    <resource: #image>
tz@644
   755
tz@644
   756
    ^Icon
cg@3298
   757
        constantNamed:'DirectoryView::FileRow htmlFileIcon'
cg@3298
   758
        ifAbsentPut:[(Depth4Image width:20 height:19) bits:(ByteArray fromPackedString:'
cg@3298
   759
DQDQDQDQDQDQDQ????????DQDQD_???????1@QDQG???L3L3<P@QDQ??L3=DL3D@@QD_?3L?P3L1DQDQG?L3MCP3L1DQDQ?3QCQCMCP??1D_<4P4QDL4O?<Q
cg@3298
   760
G?L4QDL3MD??DQ?3L3QCL3S??1D_<3L4QDL4O?<QG?<3QDQCMO??DQ??L4QDP4S??1D_??=D??S???<QG???????????DQ???????????1DQDQDQDQDQDQDQ
cg@3298
   761
DQDQDQDQDQDQDP@a')
cg@3298
   762
            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
   763
            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
   764
!
tz@644
   765
tz@644
   766
imageFileIcon
cg@3298
   767
    "This resource specification was automatically generated
cg@3298
   768
     by the ImageEditor of ST/X."
cg@3298
   769
cg@3298
   770
    "Do not manually edit this!! If it is corrupted,
cg@3298
   771
     the ImageEditor may not be able to read the specification."
cg@3298
   772
tz@644
   773
    "
cg@3298
   774
     self imageFileIcon inspect
cg@3298
   775
     ImageEditor openOnClass:self andSelector:#imageFileIcon
cg@3298
   776
     Icon flushCachedIcons
tz@644
   777
    "
tz@644
   778
tz@644
   779
    <resource: #image>
tz@644
   780
tz@644
   781
    ^Icon
cg@3298
   782
        constantNamed:'DirectoryView::FileRow imageFileIcon'
cg@3298
   783
        ifAbsentPut:[(Depth4Image width:20 height:19) bits:(ByteArray fromPackedString:'
cg@3298
   784
@@@@@@@@@@@@@@DQDQDQDQ@@@@@ADQDQDQDPD@@@@QDQDQDQDAD@@@DQDQDQDQ@QD@@ADQDQDQDP@@@@@TQG]4)G50@@@@EDQ7^$+W4QDP@AQD]7R$_WDQD@
cg@3298
   785
@SL6Y#$61!!DQ@@D3M&ZS''F0QDP@AL3Y&NS[FDQD@@RH%UR %-QDQ@@D"IUVB"5,QDP@AH"UUJBV5DQD@@QDQDQDQDQDQ@@DQDQDQDQDQDP@@@@@@@@@@@@@@
cg@3298
   786
@@@@@@@@@@@@@@@a')
cg@3298
   787
            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
   788
            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
   789
!
tz@424
   790
tz@424
   791
imgFileIcon
tz@590
   792
    "Generated by the Image Editor"
tz@590
   793
    "
tz@590
   794
    ImageEditor openOnClass:self andSelector:#imgFileIcon
tz@590
   795
    "
tz@424
   796
tz@424
   797
    <resource: #image>
tz@590
   798
tz@590
   799
    ^Icon
tz@590
   800
        constantNamed:#'DirectoryView::FileRow imgFileIcon'
tz@644
   801
        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
   802
!
tz@424
   803
tz@424
   804
linkedFileIcon
tz@644
   805
    "Generated by the Image Editor"
tz@644
   806
    "
tz@644
   807
    ImageEditor openOnClass:self andSelector:#linkedFileIcon
tz@644
   808
    "
tz@424
   809
tz@424
   810
    <resource: #image>
tz@644
   811
tz@644
   812
    ^Icon
tz@644
   813
        constantNamed:#'DirectoryView::FileRow linkedFileIcon'
penk@1627
   814
        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
   815
!
tz@424
   816
tz@424
   817
lockedFileIcon
tz@644
   818
    "Generated by the Image Editor"
tz@644
   819
    "
tz@644
   820
    ImageEditor openOnClass:self andSelector:#lockedFileIcon
tz@644
   821
    "
tz@424
   822
tz@424
   823
    <resource: #image>
tz@644
   824
tz@644
   825
    ^Icon
tz@644
   826
        constantNamed:#'DirectoryView::FileRow lockedFileIcon'
penk@1627
   827
        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
   828
!
tz@424
   829
tz@424
   830
protoFileIcon
tz@424
   831
tz@424
   832
    ^self MakefileIcon
tz@424
   833
!
tz@424
   834
tz@424
   835
rcFileIcon
tz@644
   836
    "Generated by the Image Editor"
tz@644
   837
    "
tz@644
   838
    ImageEditor openOnClass:self andSelector:#rcFileIcon
tz@644
   839
    "
tz@424
   840
tz@424
   841
    <resource: #image>
tz@644
   842
tz@644
   843
    ^Icon
tz@644
   844
        constantNamed:#'DirectoryView::FileRow rcFileIcon'
penk@1627
   845
        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
   846
!
tz@424
   847
tz@424
   848
sFileIcon
cg@3298
   849
    "This resource specification was automatically generated
cg@3298
   850
     by the ImageEditor of ST/X."
cg@3298
   851
cg@3298
   852
    "Do not manually edit this!! If it is corrupted,
cg@3298
   853
     the ImageEditor may not be able to read the specification."
cg@3298
   854
tz@644
   855
    "
cg@3298
   856
     self sFileIcon inspect
cg@3298
   857
     ImageEditor openOnClass:self andSelector:#sFileIcon
cg@3298
   858
     Icon flushCachedIcons
tz@644
   859
    "
tz@424
   860
tz@424
   861
    <resource: #image>
tz@644
   862
tz@644
   863
    ^Icon
cg@3298
   864
        constantNamed:'DirectoryView::FileRow sFileIcon'
cg@3298
   865
        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
   866
            colorMapFromArray:#[255 255 255 0 0 0]
cg@3298
   867
            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
   868
!
tz@424
   869
tz@424
   870
stFileIcon
cg@3298
   871
    "This resource specification was automatically generated
cg@3298
   872
     by the ImageEditor of ST/X."
cg@3298
   873
cg@3298
   874
    "Do not manually edit this!! If it is corrupted,
cg@3298
   875
     the ImageEditor may not be able to read the specification."
cg@3298
   876
tz@590
   877
    "
cg@3298
   878
     self stFileIcon inspect
cg@3298
   879
     ImageEditor openOnClass:self andSelector:#stFileIcon
cg@3298
   880
     Icon flushCachedIcons
tz@590
   881
    "
tz@424
   882
tz@424
   883
    <resource: #image>
tz@590
   884
tz@590
   885
    ^Icon
cg@3298
   886
        constantNamed:'DirectoryView::FileRow stFileIcon'
cg@3298
   887
        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
   888
            colorMapFromArray:#[255 255 255 0 0 0]
cg@3298
   889
            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
   890
!
tz@424
   891
tz@424
   892
stcFileIcon
cg@3298
   893
    "This resource specification was automatically generated
cg@3298
   894
     by the ImageEditor of ST/X."
cg@3298
   895
cg@3298
   896
    "Do not manually edit this!! If it is corrupted,
cg@3298
   897
     the ImageEditor may not be able to read the specification."
cg@3298
   898
tz@644
   899
    "
cg@3298
   900
     self stcFileIcon inspect
cg@3298
   901
     ImageEditor openOnClass:self andSelector:#stcFileIcon
cg@3298
   902
     Icon flushCachedIcons
tz@644
   903
    "
tz@424
   904
tz@424
   905
    <resource: #image>
tz@644
   906
tz@644
   907
    ^Icon
cg@3298
   908
        constantNamed:'DirectoryView::FileRow stcFileIcon'
cg@3298
   909
        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
   910
            colorMapFromArray:#[255 255 255 0 0 0]
cg@3298
   911
            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
   912
! !
tz@424
   913
tz@424
   914
!DirectoryView::FileRow methodsFor:'accessing'!
tz@424
   915
tz@424
   916
baseName
tz@424
   917
tz@424
   918
    ^baseName ? (baseName := fileName baseName)
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
tz@424
   928
fileName
tz@424
   929
tz@424
   930
    ^fileName
tz@424
   931
!
tz@424
   932
tz@424
   933
fileName: aFileName
tz@424
   934
tz@614
   935
    fileName := aFileName
tz@424
   936
!
tz@424
   937
tz@424
   938
group
tz@424
   939
tz@424
   940
    ^group
tz@424
   941
!
tz@424
   942
tz@424
   943
iconOn:aGC
cg@3491
   944
    |icon|
cg@3491
   945
    
cg@3491
   946
    iconKey isNil ifTrue: [
cg@3491
   947
        self validateAttributes.
cg@3491
   948
        (imageFromFile isNil and: [iconKey == #imageFileIcon]) ifTrue:  [
cg@3491
   949
            icon := self retrieveImageFromFileAndRegisterOn: aGC
cg@3491
   950
        ]
cg@3491
   951
    ].
cg@3491
   952
    imageFromFile == true ifFalse: [
cg@3491
   953
        icon := aGC registerImage: (self class perform: iconKey) key: iconKey
cg@3491
   954
    ] ifTrue:  [
cg@3491
   955
        icon := aGC registeredImageAt: iconKey
cg@3491
   956
    ].
cg@3491
   957
    ^ icon
tz@424
   958
cg@3491
   959
    "Modified: / 18-02-1998 / 18:01:52 / cg"
cg@3491
   960
    "Modified (format): / 13-09-2017 / 09:57:53 / cg"
tz@424
   961
!
tz@424
   962
tz@424
   963
modified
tz@424
   964
tz@424
   965
    ^modified
tz@424
   966
!
tz@424
   967
tz@424
   968
owner
tz@424
   969
tz@424
   970
    ^owner
tz@424
   971
!
tz@424
   972
tz@424
   973
permissions
tz@424
   974
tz@424
   975
    ^permissions
tz@424
   976
!
tz@424
   977
tz@638
   978
retrieveImageFromFileAndRegisterOn: aGC
cg@1385
   979
    "retrieve a bitmap image - but only if it is smaller than some limit (currently 20k)"
tz@638
   980
cg@1385
   981
    |image maxImageFileSize|
cg@1385
   982
cg@1385
   983
    maxImageFileSize := MaxImageFileSize ? 20000.
cg@1385
   984
tz@638
   985
    imageFromFile := false.       
cg@3491
   986
    (image := aGC registeredImageAt: fileName name asSymbol) isNil ifTrue:[            
cg@1385
   987
        size < maxImageFileSize ifTrue:[     
cg@2999
   988
            Error handle: [:ex|]
cg@1385
   989
            do:[   
cg@1385
   990
                (image := Image fromFile: fileName name) notNil ifTrue:[
cg@1385
   991
                    image extent y > 22 ifTrue:[         
tz@638
   992
                        image := image magnifiedBy: 22/image extent y
tz@638
   993
                    ].
tz@638
   994
                    image := aGC registerImage: image key: fileName name asSymbol.
tz@638
   995
                ]
tz@638
   996
            ] 
tz@638
   997
        ].
tz@638
   998
    ].
tz@638
   999
    image notNil ifTrue: [imageFromFile := true. iconKey := fileName name asSymbol].
tz@638
  1000
    ^image
cg@3491
  1001
cg@3491
  1002
    "Modified (format): / 13-09-2017 / 09:58:19 / cg"
tz@638
  1003
!
tz@638
  1004
tz@424
  1005
size
cg@3491
  1006
    size isNil ifTrue:[
cg@3491
  1007
        self validateAttributes.
cg@3491
  1008
    ].
cg@3491
  1009
    
cg@607
  1010
    size isNumber ifFalse:[^ size].
cg@3491
  1011
cg@3491
  1012
    "/ ^ UnitConverter fileSizeStringFor:size.
cg@3491
  1013
    
cg@607
  1014
    size < 1000        ifTrue: [^ size printString].
cg@607
  1015
    size < (100*1024)  ifTrue: [^(((size/1024) * 10) asInteger/10) asFloat printString, ' Kb'].
cg@607
  1016
    size < (1000*1024) ifTrue: [^(((size/1024)) asInteger) printString, ' Kb'].
cg@607
  1017
    ^(((size/1048576) * 10) asInteger/10) asFloat printString, ' Mb'
tz@424
  1018
cg@3491
  1019
    "Modified: / 13-09-2017 / 09:58:42 / cg"
tz@424
  1020
! !
tz@424
  1021
tz@424
  1022
!DirectoryView::FileRow methodsFor:'private'!
tz@424
  1023
tz@424
  1024
validateAttributes
cg@2938
  1025
    |info mode suffix| 
tz@638
  1026
sv@3366
  1027
    permissions := '---------' copy.
tz@424
  1028
cg@2938
  1029
    (info := fileName info) isNil ifTrue:[
tz@424
  1030
        iconKey := #lockedFileIcon.
tz@424
  1031
        size    := owner := group := '?'.
cg@2938
  1032
        ^ self
tz@424
  1033
    ].        
cg@3491
  1034
    size   := info fileSize.
penk@1627
  1035
    modified := info modificationTime printString.
tz@424
  1036
    owner  := OperatingSystem getUserNameFromID: info uid.
tz@424
  1037
    group  := OperatingSystem getGroupNameFromID: info gid.
tz@424
  1038
    mode   := info mode.
tz@424
  1039
tz@424
  1040
    1 to:9 by:3 do:[:i|
tz@424
  1041
        #((0 $x) (1 $w) (2 $r)) do:
tz@424
  1042
        [:m|
tz@424
  1043
            (mode bitAt:i + m first) == 1 ifTrue:[permissions at: 10 - m first - i put: m last]
tz@424
  1044
        ]
tz@424
  1045
    ].
tz@424
  1046
cg@2938
  1047
    fileName isReadable ifFalse:[
sv@3366
  1048
        ^ iconKey := #lockedFileIcon
tz@424
  1049
    ].
cg@2938
  1050
    info type == #symbolicLink ifTrue:[
cg@2938
  1051
        ^ iconKey := #linkedFileIcon
cg@2938
  1052
    ].
cg@2938
  1053
    suffix := fileName suffix.
cg@2938
  1054
cg@3634
  1055
    ((suffix asSingleByteStringIfPossible isSingleByteCollection
cg@3634
  1056
     and:[ (self class respondsTo:(iconKey := (suffix, 'FileIcon') asSymbol))])
cg@3634
  1057
        or: [fileName baseName asSingleByteStringIfPossible isSingleByteCollection 
cg@3634
  1058
             and:[self class respondsTo: (iconKey := (fileName baseName, 'Icon') asSymbol)]]
cg@2938
  1059
    ) ifFalse:[
cg@2938
  1060
        iconKey := #fileIcon.
cg@2938
  1061
        ((suffix = 'o') or:[suffix = 'so']) ifTrue: [
sv@3366
  1062
            ^ iconKey := #binaryFileIcon
cg@2938
  1063
        ].
cg@2938
  1064
        (Image isImageFileSuffix:suffix) ifTrue: [
sv@3366
  1065
            ^ iconKey := #imageFileIcon
cg@2938
  1066
        ].
cg@2938
  1067
cg@2938
  1068
        fileName isExecutableProgram ifTrue:[
sv@3366
  1069
            ^ iconKey := #exeFileIcon
cg@2938
  1070
        ]
cg@2938
  1071
    ]
cg@3491
  1072
cg@3491
  1073
    "Modified: / 13-09-2017 / 10:00:42 / cg"
cg@3634
  1074
    "Modified: / 01-01-2019 / 15:23:11 / Claus Gittinger"
tz@424
  1075
! !
tz@424
  1076
tz@424
  1077
!DirectoryView class methodsFor:'documentation'!
tz@424
  1078
tz@424
  1079
version
tz@424
  1080
    ^ '$Header$'
cg@3299
  1081
!
cg@3299
  1082
cg@3299
  1083
version_CVS
cg@3299
  1084
    ^ '$Header$'
tz@424
  1085
! !
cg@2999
  1086