FileSelectionBrowser.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3252 b5b2f185aa98
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@404
     1
"
tz@502
     2
 COPYRIGHT (c) 1997 by eXept Software AG
tz@404
     3
              All Rights Reserved
tz@404
     4
tz@404
     5
 This software is furnished under a license and may be used
tz@404
     6
 only in accordance with the terms of that license and with the
tz@404
     7
 inclusion of the above copyright notice. This software may not
tz@404
     8
 be provided or otherwise made available to, or used by, any
tz@404
     9
 other person. No title to or ownership of the software is
tz@404
    10
 hereby transferred.
tz@404
    11
"
cg@1379
    12
"{ Package: 'stx:libtool2' }"
cg@1379
    13
cg@3197
    14
"{ NameSpace: Smalltalk }"
cg@3197
    15
tz@404
    16
SelectionBrowser subclass:#FileSelectionBrowser
tz@404
    17
	instanceVariableNames:'selectedFileFilter directoryView listOfFileFilters directory'
tz@404
    18
	classVariableNames:''
tz@404
    19
	poolDictionaries:''
tz@619
    20
	category:'Interface-Dialogs'
tz@404
    21
!
tz@404
    22
tz@404
    23
!FileSelectionBrowser class methodsFor:'documentation'!
tz@404
    24
tz@404
    25
copyright
tz@404
    26
"
tz@502
    27
 COPYRIGHT (c) 1997 by eXept Software AG
tz@404
    28
              All Rights Reserved
tz@404
    29
tz@404
    30
 This software is furnished under a license and may be used
tz@404
    31
 only in accordance with the terms of that license and with the
tz@404
    32
 inclusion of the above copyright notice. This software may not
tz@404
    33
 be provided or otherwise made available to, or used by, any
tz@404
    34
 other person. No title to or ownership of the software is
tz@404
    35
 hereby transferred.
tz@404
    36
"
tz@404
    37
tz@404
    38
tz@404
    39
!
tz@404
    40
tz@404
    41
documentation
tz@404
    42
"
tz@745
    43
    The FileSelectionBrowser allows you to browse in file directories
tz@745
    44
    and to select files in order to load file contents or to save
tz@745
    45
    something to files.
tz@745
    46
tz@745
    47
    [start with:]
tz@745
    48
        FileSelectionBrowser open
tz@502
    49
tz@502
    50
    [author:]
tz@745
    51
        Thomas Zwick, eXept Software AG
tz@404
    52
"
tz@404
    53
! !
tz@404
    54
tz@404
    55
!FileSelectionBrowser class methodsFor:'instance creation'!
tz@404
    56
tz@404
    57
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
cg@1353
    58
    "ask for a file in some directory,
cg@1353
    59
     using a fileFilter (list of mathcPatterns).
cg@1353
    60
     Initial selection is aFileName.
cg@1353
    61
     return the pathName or nil if canceled."
cg@1353
    62
cg@957
    63
    ^self new
cg@957
    64
        title: aTitle;
cg@957
    65
        fileName: aFileName;
cg@957
    66
        directory: dir;
cg@957
    67
        listOfFileFilters: fileFilters;
cg@957
    68
        open
cg@957
    69
tz@745
    70
    "
cg@1353
    71
     self 
cg@1353
    72
         request: 'Select Your Profile File' 
cg@1353
    73
         fileName: '.profile' 
cg@1353
    74
         inDirectory: Filename homeDirectory 
cg@1353
    75
         withFileFilters: #('.*')
tz@745
    76
    "
tz@404
    77
cg@957
    78
    "Modified: / 17.8.1998 / 10:15:50 / cg"
cg@957
    79
!
cg@957
    80
cg@1353
    81
request:aTitle fileName:aFileName withFileFilters:fileFilters
cg@1353
    82
    "ask for a file in some directory,
cg@1353
    83
     using a fileFilter (list of mathcPatterns).
cg@1353
    84
     Initial selection is aFileName.
cg@1353
    85
     return the pathName or nil if canceled."
cg@1353
    86
cg@1353
    87
    ^ self new
tz@404
    88
        title: aTitle;
tz@404
    89
        fileName: aFileName;
tz@404
    90
        listOfFileFilters: fileFilters;
tz@404
    91
        open
tz@404
    92
tz@745
    93
    "
cg@1353
    94
     self 
cg@1353
    95
         request: 'Select Your Profile File' 
cg@1353
    96
         fileName: '/etc/fstab' 
cg@1353
    97
         withFileFilters: #('*')  
tz@745
    98
    "
tz@462
    99
cg@957
   100
    "Modified: / 17.8.1998 / 10:15:50 / cg"
tz@745
   101
!
tz@745
   102
cg@1353
   103
request:aTitle inDirectory:aPath withFileFilters:fileFilters 
cg@1353
   104
    "ask for a file in some directory,
cg@1353
   105
     using a fileFilter (list of mathcPatterns)
cg@1353
   106
     return the pathName or nil if canceled."
cg@1353
   107
cg@1353
   108
    ^ (self new)
cg@1353
   109
        title:aTitle;
cg@1353
   110
        directory:aPath;
cg@1353
   111
        listOfFileFilters:fileFilters;
cg@957
   112
        open
cg@957
   113
tz@745
   114
    "
cg@1353
   115
     self 
cg@1353
   116
         request: 'Select A File' 
cg@1353
   117
         inDirectory: '/etc' 
cg@1353
   118
         withFileFilters: #('*.conf')
tz@745
   119
    "
tz@745
   120
cg@957
   121
    "Modified: / 17.8.1998 / 10:15:50 / cg"
tz@745
   122
!
tz@745
   123
cg@1353
   124
request:aTitle pathName:aPath withFileFilters:fileFilters 
cg@1353
   125
    "ask for a file in some directory,
cg@1353
   126
     using a fileFilter (list of mathcPatterns)
cg@1353
   127
     return the pathName or nil if canceled.
cg@1353
   128
     Obsolete - for backward compatibility."
cg@1353
   129
cg@1353
   130
    ^ self
cg@1353
   131
        request:aTitle inDirectory:aPath withFileFilters:fileFilters
cg@1353
   132
cg@1353
   133
    "
cg@1353
   134
     self 
cg@1353
   135
         request: 'Select A File' 
cg@1353
   136
         pathName: '/etc' 
cg@1353
   137
         withFileFilters: #('*.conf')
cg@1353
   138
    "
cg@1353
   139
cg@1353
   140
    "Modified: / 17.8.1998 / 10:15:50 / cg"
cg@1353
   141
!
cg@1353
   142
cg@1353
   143
request:aTitle withFileFilters:fileFilters 
cg@1353
   144
    "ask for a file in the current directory,
cg@1353
   145
     using a fileFilter (list of mathcPatterns)
cg@1353
   146
     return the pathName or nil if canceled"
cg@1353
   147
cg@1353
   148
    ^ (self new)
cg@1353
   149
        title:aTitle;
cg@1353
   150
        listOfFileFilters:fileFilters;
cg@957
   151
        open
cg@1353
   152
tz@745
   153
    "
cg@1353
   154
     self request:'Select A File' withFileFilters:#('.*')
cg@1353
   155
     self request:'Select A File' withFileFilters:#('*.mak;*.st')
tz@745
   156
    "
tz@745
   157
cg@957
   158
    "Modified: / 17.8.1998 / 10:15:49 / cg"
tz@462
   159
!
tz@462
   160
tz@404
   161
requestFileName
cg@1353
   162
    "ask for a file in the current directory;
cg@1353
   163
     return the pathName or nil if canceled"
cg@1353
   164
cg@1353
   165
    ^ self new 
cg@1353
   166
        title:'Select A File';
cg@1353
   167
        open
cg@1353
   168
tz@745
   169
    "
cg@1353
   170
     self requestFileName
cg@1353
   171
    "
cg@1353
   172
cg@1353
   173
    "Modified: / 17.8.1998 / 10:15:48 / cg"
cg@1353
   174
!
cg@1353
   175
cg@1353
   176
requestFileNameInDirectory:aPath
cg@1353
   177
    "ask for a file in a directory;
cg@1353
   178
     return the pathName or nil if canceled"
cg@1353
   179
cg@1353
   180
    ^ self new 
cg@1353
   181
        title:'Select A File'; 
cg@1353
   182
        directory:aPath; 
cg@1353
   183
        open
cg@1353
   184
cg@1353
   185
    "
cg@1353
   186
     self requestFileNameInDirectory:'/etc' 
tz@745
   187
    "
tz@404
   188
cg@957
   189
    "Modified: / 17.8.1998 / 10:15:48 / cg"
tz@404
   190
! !
tz@404
   191
tz@404
   192
!FileSelectionBrowser class methodsFor:'accessing'!
tz@404
   193
tz@404
   194
loadImageFileNameFilters
cg@992
   195
    ^ OrderedCollection 
cg@992
   196
        withAll: #(
cg@2594
   197
                    '*.png ; *.gif ; *.bmp ; *.tif ; *.tiff ; *.xpm ; *.xbm ; *.jpeg ; *.jpg'
cg@992
   198
                    '*'
cg@992
   199
                  )
tz@404
   200
cg@992
   201
    "Modified: / 12.9.1998 / 17:23:42 / cg"
tz@404
   202
!
tz@404
   203
tz@404
   204
projectFileNameFilters
cg@992
   205
    ^Array withAll: #(
cg@992
   206
                      '*.st ; *.*o ; *.s ; *.c ; Make* ; *.project'
cg@992
   207
                      '*'
cg@992
   208
                     )
tz@404
   209
cg@992
   210
    "Modified: / 12.9.1998 / 17:23:22 / cg"
tz@404
   211
!
tz@404
   212
tz@404
   213
saveImageFileNameFilters
cg@992
   214
    ^ OrderedCollection 
cg@992
   215
        withAll: #(
cg@3252
   216
                    '*.png ; *.gif ; *.jpg ; *.bmp ; *.tif ; *.tiff ; *.xpm ; *.xbm'
cg@992
   217
                    '*'
cg@992
   218
                  )
tz@404
   219
cg@992
   220
    "Modified: / 12.9.1998 / 17:23:54 / cg"
tz@404
   221
! !
tz@404
   222
tz@404
   223
!FileSelectionBrowser class methodsFor:'interface specs'!
tz@404
   224
tz@404
   225
windowSpec
tz@745
   226
    "This resource specification was automatically generated
tz@745
   227
     by the UIPainter of ST/X."
tz@404
   228
tz@745
   229
    "Do not manually edit this!! If it is corrupted,
tz@745
   230
     the UIPainter may not be able to read the specification."
tz@404
   231
tz@404
   232
    "
tz@404
   233
     UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec
tz@404
   234
     FileSelectionBrowser new openInterface:#windowSpec
tz@745
   235
     FileSelectionBrowser open
tz@404
   236
    "
tz@404
   237
tz@404
   238
    <resource: #canvas>
tz@404
   239
cg@1260
   240
    ^ 
cg@1260
   241
     #(#FullSpec
cg@1260
   242
        #name: #windowSpec
cg@1260
   243
        #window: 
cg@1260
   244
       #(#WindowSpec
cg@1260
   245
          #label: 'File Selection Browser'
cg@1260
   246
          #name: 'File Selection Browser'
cg@1260
   247
          #min: #(#Point 10 10)
cg@1260
   248
          #bounds: #(#Rectangle 18 51 618 401)
cg@1260
   249
        )
cg@1260
   250
        #component: 
cg@1260
   251
       #(#SpecCollection
cg@1260
   252
          #collection: #(
cg@1260
   253
           #(#VariableHorizontalPanelSpec
cg@1260
   254
              #name: 'panel'
cg@1260
   255
              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0)
cg@1260
   256
              #component: 
cg@1260
   257
             #(#SpecCollection
cg@1260
   258
                #collection: #(
cg@1260
   259
                 #(#ViewSpec
cg@1260
   260
                    #name: 'view1'
tz@745
   261
                    #component: 
cg@1260
   262
                   #(#SpecCollection
cg@1260
   263
                      #collection: #(
cg@1260
   264
                       #(#FileSelectionTreeSpec
cg@1260
   265
                          #name: 'directoryTreeView'
cg@1260
   266
                          #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0)
cg@1260
   267
                          #model: #selectionOfDirectory
cg@1379
   268
                          #menu: #treeMenu
cg@1260
   269
                          #hasHorizontalScrollBar: true
cg@1260
   270
                          #hasVerticalScrollBar: true
cg@1260
   271
                          #miniScrollerHorizontal: true
cg@1260
   272
                          #showDirectoryIndicatorForRoot: false
cg@1260
   273
                          #showDirectoryIndicator: true
cg@1260
   274
                          #valueChangeSelector: #readDirectory
cg@1260
   275
                          #hierarchicalList: #rootOfDirectory
cg@1260
   276
                          #highlightMode: #line
cg@1260
   277
                          #itemClass: 'Directory'
tz@404
   278
                        )
cg@1260
   279
                       #(#InputFieldSpec
cg@1260
   280
                          #name: 'directoryInputField'
cg@1260
   281
                          #layout: #(#LayoutFrame 2 0.0 -22 1 0 1.0 0 1)
cg@1260
   282
                          #model: #selectionOfDirectory
cg@1260
   283
                          #immediateAccept: false
cg@1260
   284
                          #acceptOnPointerLeave: false
cg@1260
   285
                        )
cg@1260
   286
                       )
cg@1260
   287
                     
tz@404
   288
                    )
cg@1260
   289
                  )
cg@1260
   290
                 #(#ViewSpec
cg@1260
   291
                    #name: 'view2'
cg@1260
   292
                    #component: 
cg@1260
   293
                   #(#SpecCollection
cg@1260
   294
                      #collection: #(
cg@1260
   295
                       #(#InputFieldSpec
cg@1260
   296
                          #name: 'EditField'
cg@1260
   297
                          #layout: #(#LayoutFrame 1 0.0 -22 1 -2 1.0 0 1)
cg@1260
   298
                          #model: #valueOfFileName
cg@1260
   299
                          #acceptOnReturn: false
cg@1260
   300
                          #acceptOnTab: false
cg@1260
   301
                          #acceptOnPointerLeave: false
cg@1260
   302
                        )
cg@1260
   303
                       #(#SubCanvasSpec
cg@1260
   304
                          #name: 'subCanvas1'
cg@1260
   305
                          #layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -25 1.0)
cg@1260
   306
                          #clientHolder: #directoryView
cg@1260
   307
                        )
cg@1260
   308
                       )
cg@1260
   309
                     
cg@1260
   310
                    )
cg@1260
   311
                  )
cg@1260
   312
                 )
cg@1260
   313
               
tz@404
   314
              )
cg@1260
   315
              #handles: #(#Any 0.5 1.0)
cg@1260
   316
            )
cg@1260
   317
           #(#UISubSpecification
cg@1260
   318
              #name: 'SubSpecification'
cg@1260
   319
              #layout: #(#LayoutFrame 2 0.0 -32 1 0 1.0 0 1.0)
cg@1260
   320
              #majorKey: #ToolApplicationModel
cg@1260
   321
              #minorKey: #windowSpecForCommitWithoutChannels
cg@1260
   322
            )
cg@1260
   323
           )
cg@1260
   324
         
cg@1260
   325
        )
tz@404
   326
      )
tz@404
   327
! !
tz@404
   328
cg@1379
   329
!FileSelectionBrowser class methodsFor:'menu specs'!
cg@1379
   330
cg@1379
   331
treeMenu
cg@1379
   332
    "This resource specification was automatically generated
cg@1379
   333
     by the MenuEditor of ST/X."
cg@1379
   334
cg@1379
   335
    "Do not manually edit this!! If it is corrupted,
cg@1379
   336
     the MenuEditor may not be able to read the specification."
cg@1379
   337
cg@1379
   338
    "
cg@1379
   339
     MenuEditor new openOnClass:FileSelectionBrowser andSelector:#treeMenu
cg@1379
   340
     (Menu new fromLiteralArrayEncoding:(FileSelectionBrowser treeMenu)) startUp
cg@1379
   341
    "
cg@1379
   342
cg@1379
   343
    <resource: #menu>
cg@1379
   344
cg@1379
   345
    ^ 
cg@1379
   346
     #(#Menu
cg@1379
   347
        #(
cg@1379
   348
         #(#MenuItem
cg@1458
   349
            #label: 'Goto Home Directory'
cg@1458
   350
            #translateLabel: true
cg@1458
   351
            #value: #menuGotoHomeDirectory
cg@1458
   352
          )
cg@1458
   353
         #(#MenuItem
cg@1458
   354
            #label: 'Goto Default Directory'
cg@1458
   355
            #translateLabel: true
cg@1458
   356
            #value: #menuGotoDefaultDirectory
cg@1458
   357
          )
cg@1458
   358
         #(#MenuItem
cg@1458
   359
            #label: '-'
cg@1458
   360
          )
cg@1458
   361
         #(#MenuItem
cg@1379
   362
            #label: 'Create directory...'
cg@1379
   363
            #translateLabel: true
cg@1379
   364
            #value: #menuCreateDirectory
cg@1379
   365
          )
cg@1379
   366
         #(#MenuItem
cg@1379
   367
            #label: '-'
cg@1379
   368
          )
cg@1379
   369
         #(#MenuItem
cg@1379
   370
            #label: 'Update'
cg@1379
   371
            #translateLabel: true
cg@1379
   372
            #value: #menuUpdate
cg@1379
   373
          )
cg@1379
   374
         )
cg@1379
   375
        nil
cg@1379
   376
        nil
cg@1379
   377
      )
cg@1379
   378
! !
cg@1379
   379
tz@404
   380
!FileSelectionBrowser methodsFor:'accessing'!
tz@404
   381
tz@404
   382
directory: aDirectory
tz@404
   383
cg@957
   384
    directory := (aDirectory ? Filename currentDirectory) asFilename asAbsoluteFilename pathName
tz@745
   385
cg@957
   386
    "Modified: / 17.8.1998 / 10:15:53 / cg"
tz@404
   387
!
tz@404
   388
tz@404
   389
directoryView
cg@998
   390
    "return the directory view on the right side (a subcanvas)"
tz@404
   391
tz@404
   392
    ^directoryView ? (directoryView := DirectoryView new)
cg@998
   393
cg@998
   394
    "Modified: / 23.9.1998 / 16:46:50 / cg"
tz@404
   395
!
tz@404
   396
tz@404
   397
fileName: aFileName
cg@1003
   398
    |prevDir|
tz@404
   399
tz@404
   400
    self valueOfFileName value: (aFileName ? '') asFilename baseName.
cg@1003
   401
    prevDir := directory.
cg@957
   402
    directory := directory ? ((aFileName ? '') asFilename asAbsoluteFilename directoryName).
cg@957
   403
cg@2445
   404
    "/ on systems with volumes, we might have to update the root here.
cg@1003
   405
    (prevDir isNil
cg@1003
   406
    or:[directory asFilename volume ~= prevDir asFilename volume]) ifTrue:[
cg@1003
   407
        self setRootForFile:directory asFilename.
cg@1003
   408
    ].
cg@1003
   409
cg@1003
   410
    "Modified: / 24.9.1998 / 23:41:08 / cg"
tz@404
   411
!
tz@404
   412
tz@404
   413
listOfFileFilters: anArray
tz@404
   414
tz@404
   415
    listOfFileFilters := anArray
tz@404
   416
! !
tz@404
   417
cg@1398
   418
!FileSelectionBrowser methodsFor:'accessing-views'!
tz@404
   419
tz@592
   420
directoryInputField
tz@592
   421
cg@1597
   422
    ^self componentAt: #directoryInputField
tz@592
   423
!
tz@592
   424
tz@404
   425
directoryTreeView
tz@404
   426
cg@1597
   427
    ^self componentAt: #directoryTreeView
tz@404
   428
! !
tz@404
   429
tz@404
   430
!FileSelectionBrowser methodsFor:'aspects'!
tz@404
   431
tz@404
   432
rootOfDirectory
tz@404
   433
tz@404
   434
    |holder|
tz@404
   435
    (holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[
cg@998
   436
        builder 
cg@998
   437
            aspectAt:#rootOfDirectory 
cg@998
   438
            put: (holder :=  Filename rootDirectory name asValue).
tz@404
   439
    ].
tz@404
   440
    ^ holder
tz@404
   441
cg@1011
   442
    "Modified: / 5.10.1998 / 12:46:10 / cg"
tz@404
   443
!
tz@404
   444
tz@404
   445
selectionOfDirectory
tz@404
   446
tz@404
   447
    |holder|
tz@404
   448
    (holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[
tz@404
   449
        builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new)
tz@404
   450
    ].
tz@404
   451
    ^ holder
tz@404
   452
tz@404
   453
!
tz@404
   454
cg@998
   455
setRootForFile:aFilename
cg@1144
   456
    |f root parent|
cg@1000
   457
cg@1000
   458
    f := aFilename asFilename.
cg@1000
   459
    root := Filename rootDirectoryOnVolume:f volume.
cg@1001
   460
    self directory:aFilename.
cg@1000
   461
cg@1000
   462
    "/ on some systems, the root itself is not readable,
cg@1000
   463
    "/ but subdirs are (WIN32-network drives and VMS)
cg@1001
   464
    "/ to avoid trouble in the treeView, search for the
cg@1001
   465
    "/ last readable directory and fake that as the trees root.
cg@1000
   466
cg@1000
   467
    (root exists and:[root isDirectory and:[root isReadable]])
cg@1000
   468
    ifFalse:[
cg@1000
   469
        "/ search backward from aFilename for the last readable dir.
cg@1000
   470
        root := f.
cg@1000
   471
        parent := root directory.
cg@1005
   472
        [parent ~= root
cg@1005
   473
         and:[parent exists 
cg@1005
   474
         and:[parent isDirectory 
cg@1005
   475
         and:[parent isReadable]]]]
cg@1000
   476
        whileTrue:[
cg@1000
   477
            root := parent.
cg@1000
   478
            parent := root directory.
cg@1000
   479
        ].
cg@1000
   480
    ].
cg@1000
   481
cg@1011
   482
    self rootOfDirectory value:root pathName
cg@998
   483
cg@998
   484
    "Created: / 23.9.1998 / 16:36:28 / cg"
cg@1011
   485
    "Modified: / 5.10.1998 / 12:46:06 / cg"
cg@998
   486
!
cg@998
   487
tz@404
   488
valueOfFileName
tz@404
   489
tz@404
   490
    |holder|
tz@404
   491
    (holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[
tz@404
   492
        builder aspectAt:#valueOfFileName put:(holder :=  ValueHolder new).
tz@404
   493
    ].
tz@404
   494
    ^ holder
tz@404
   495
! !
tz@404
   496
tz@404
   497
!FileSelectionBrowser methodsFor:'callbacks'!
tz@404
   498
tz@404
   499
fileDoubleClicked: aFileName
tz@404
   500
tz@404
   501
    self valueOfFileName value: aFileName.
tz@404
   502
    accept value: true.
cg@1035
   503
    self closeRequest
tz@404
   504
!
tz@404
   505
cg@1379
   506
menuCreateDirectory
cg@1379
   507
    |newSubDirName currentDir|
cg@1379
   508
cg@1379
   509
    currentDir := self selectionOfDirectory value.
cg@1379
   510
    currentDir isNil ifTrue:[
cg@1379
   511
        self warn:'No directory selected.'.
cg@1379
   512
        ^ self
cg@1379
   513
    ].
cg@1492
   514
    newSubDirName := Dialog 
cg@1492
   515
                        request:(resources 
cg@1915
   516
                                    stringWithCRs:'Create new directory in\\%1: ' 
cg@1915
   517
                                    with:(currentDir asFilename pathName allBold)).
cg@1379
   518
    (currentDir asFilename construct:newSubDirName) makeDirectory.
cg@1379
   519
    self menuUpdate
cg@1379
   520
!
cg@1379
   521
cg@1458
   522
menuGotoDefaultDirectory
cg@1458
   523
    self selectionOfDirectory value:(Filename defaultDirectory pathName)
cg@1458
   524
!
cg@1458
   525
cg@1458
   526
menuGotoHomeDirectory
cg@1458
   527
    self selectionOfDirectory value:(Filename homeDirectory pathName)
cg@1458
   528
!
cg@1458
   529
cg@1379
   530
menuUpdate
cg@1597
   531
    (self componentAt:#directoryTreeView) monitorCycle.
cg@1379
   532
!
cg@1379
   533
tz@404
   534
readDirectory
cg@2440
   535
    self directoryTreeView selection notNil ifTrue: [
cg@1001
   536
        directoryView directory: self selectionOfDirectory value.
cg@1001
   537
        directoryView readDirectory.  
tz@745
   538
        self class lastSelection notNil ifTrue: [self class lastSelection: self selectionOfDirectory value]
tz@592
   539
    ]
cg@1001
   540
cg@1001
   541
    "Modified: / 24.9.1998 / 21:58:50 / cg"
cg@1001
   542
! !
cg@1001
   543
cg@1001
   544
!FileSelectionBrowser methodsFor:'misc'!
cg@1001
   545
cg@1001
   546
entryCompletion
cg@1001
   547
    |completedDirectory f dir treeView inputField|
cg@1001
   548
cg@1001
   549
    treeView := self directoryTreeView.
cg@1001
   550
    inputField := self directoryInputField.
cg@1001
   551
cg@1001
   552
    f := inputField contents.
cg@2450
   553
    f asFilename isRootDirectory ifTrue:[
cg@2450
   554
        dir := f.
cg@2450
   555
    ] ifFalse:[
cg@2450
   556
        dir := f asFilename directoryName.
cg@2450
   557
    ].
cg@1001
   558
cg@2440
   559
    completedDirectory := Filename 
cg@1001
   560
        filenameCompletionFor:f
cg@1001
   561
        directory:dir
cg@1001
   562
        directoriesOnly:true 
cg@1001
   563
        filesOnly:false 
cg@1001
   564
        ifMultiple:
cg@2440
   565
            [:dir | 
cg@2440
   566
                treeView selection notNil ifTrue:[
cg@2440
   567
                    treeView selectedNodeExpand: true
cg@2440
   568
                ]
cg@2440
   569
            ].
cg@2440
   570
cg@2440
   571
    completedDirectory asFilename exists ifTrue:[
cg@1001
   572
        "/ volume changed ... (win32 or VMS)
cg@2440
   573
"/        completedDirectory asFilename volume ~= directory asFilename volume ifTrue:[
cg@2440
   574
"/        ].
cg@2440
   575
        completedDirectory asFilename volume ~= treeView scrolledView directory asFilename volume ifTrue:[
cg@2440
   576
            treeView scrolledView directory:completedDirectory asFilename volume
cg@1001
   577
        ].
cg@1001
   578
        treeView selectPathname: completedDirectory.
cg@1001
   579
        inputField contents: completedDirectory.
cg@1001
   580
        self readDirectory
cg@1001
   581
    ] ifFalse: [
cg@1001
   582
        inputField flash
cg@1001
   583
    ]
cg@1001
   584
cg@1001
   585
    "Created: / 24.9.1998 / 21:33:37 / cg"
cg@1001
   586
    "Modified: / 24.9.1998 / 22:20:23 / cg"
tz@404
   587
! !
tz@404
   588
cg@1716
   589
!FileSelectionBrowser methodsFor:'startup & release'!
tz@404
   590
tz@404
   591
closeCancel
tz@404
   592
tz@404
   593
    directoryView release.
tz@404
   594
    super closeCancel
tz@404
   595
!
tz@404
   596
tz@404
   597
closeRequest
tz@404
   598
tz@404
   599
    directoryView release.
tz@404
   600
    super closeRequest
tz@404
   601
tz@404
   602
!
tz@404
   603
tz@404
   604
open
cg@1353
   605
    super open.
tz@404
   606
cg@1353
   607
    "return the selected file or nil"
sv@515
   608
    accept value ifTrue:[
sv@515
   609
        ^ (self selectionOfDirectory value ? '') asFilename 
sv@515
   610
                constructString:(self valueOfFileName value ? '')
tz@404
   611
    ].
sv@515
   612
    ^ nil
cg@957
   613
cg@957
   614
    "Modified: / 17.8.1998 / 10:15:55 / cg"
tz@404
   615
!
tz@404
   616
tz@404
   617
postBuildWith:aBuilder
cg@1003
   618
    |nm file|
tz@404
   619
tz@404
   620
    directoryView listOfFileFilters: listOfFileFilters ? #('*').
tz@462
   621
    directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName asFilename baseName].
tz@462
   622
    directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName asFilename baseName].
tz@404
   623
    directoryView fileFilterSelectAction: [:fileFilter|
cg@992
   624
"/        CG: obscure code - isn't the code below the same as ?
cg@992
   625
"/        self valueOfFileName value:((self valueOfFileName value ? 'unknown') 
cg@992
   626
"/                                    asFilename
cg@992
   627
"/                                        withSuffix:(fileFilter asFilename suffix))
cg@992
   628
        self valueOfFileName value: (
cg@992
   629
            ((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.',
cg@3197
   630
            (fileFilter reversed readStream upTo: $.) reverse)
cg@992
   631
    ]. 
cg@1003
   632
    nm := directory.
cg@1003
   633
    nm isNil ifTrue:[
cg@1003
   634
        nm := self class lastSelection.
cg@1003
   635
        nm isNil ifTrue:[
cg@1003
   636
            nm := Filename currentDirectory asAbsoluteFilename name.
cg@1003
   637
        ].
cg@1003
   638
    ].
cg@2445
   639
cg@1003
   640
    self directoryTreeView selectPathname:nm.
tz@592
   641
cg@1001
   642
    self directoryInputField 
cg@1001
   643
        entryCompletionBlock:[:f| self entryCompletion].
tz@404
   644
cg@1003
   645
    file := self valueOfFileName value.
tz@626
   646
    directoryView selectionOfFile value: 
cg@1003
   647
        (directoryView listOfFiles 
cg@1003
   648
            detect: [:row | row baseName = file] 
cg@1003
   649
            ifNone: nil).
tz@626
   650
cg@2027
   651
    super postBuildWith:aBuilder
cg@969
   652
cg@1003
   653
    "Modified: / 24.9.1998 / 23:41:29 / cg"
tz@404
   654
! !
tz@404
   655
tz@404
   656
!FileSelectionBrowser class methodsFor:'documentation'!
tz@404
   657
tz@404
   658
version
tz@404
   659
    ^ '$Header$'
cg@2594
   660
!
cg@2594
   661
cg@2594
   662
version_CVS
cg@2594
   663
    ^ '$Header$'
tz@404
   664
! !
cg@3197
   665