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