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