FileSelectionBrowser.st
author tz
Thu, 05 Mar 1998 23:30:36 +0100
changeset 700 2aae4f3b6526
parent 626 402a50b931d5
child 745 d3995881fa13
permissions -rw-r--r--
supports merging into existing help specs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
404
35982cf1482f initial checkin
tz
parents:
diff changeset
     1
"
502
624dc714fd69 copyright changed
tz
parents: 468
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
404
35982cf1482f initial checkin
tz
parents:
diff changeset
     3
              All Rights Reserved
35982cf1482f initial checkin
tz
parents:
diff changeset
     4
35982cf1482f initial checkin
tz
parents:
diff changeset
     5
 This software is furnished under a license and may be used
35982cf1482f initial checkin
tz
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
35982cf1482f initial checkin
tz
parents:
diff changeset
     7
 inclusion of the above copyright notice. This software may not
35982cf1482f initial checkin
tz
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
35982cf1482f initial checkin
tz
parents:
diff changeset
     9
 other person. No title to or ownership of the software is
35982cf1482f initial checkin
tz
parents:
diff changeset
    10
 hereby transferred.
35982cf1482f initial checkin
tz
parents:
diff changeset
    11
"
35982cf1482f initial checkin
tz
parents:
diff changeset
    12
35982cf1482f initial checkin
tz
parents:
diff changeset
    13
35982cf1482f initial checkin
tz
parents:
diff changeset
    14
35982cf1482f initial checkin
tz
parents:
diff changeset
    15
SelectionBrowser subclass:#FileSelectionBrowser
35982cf1482f initial checkin
tz
parents:
diff changeset
    16
	instanceVariableNames:'selectedFileFilter directoryView listOfFileFilters directory'
35982cf1482f initial checkin
tz
parents:
diff changeset
    17
	classVariableNames:''
35982cf1482f initial checkin
tz
parents:
diff changeset
    18
	poolDictionaries:''
619
36c9d07f7dc3 class category changed
tz
parents: 615
diff changeset
    19
	category:'Interface-Dialogs'
404
35982cf1482f initial checkin
tz
parents:
diff changeset
    20
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    21
35982cf1482f initial checkin
tz
parents:
diff changeset
    22
!FileSelectionBrowser class methodsFor:'documentation'!
35982cf1482f initial checkin
tz
parents:
diff changeset
    23
35982cf1482f initial checkin
tz
parents:
diff changeset
    24
copyright
35982cf1482f initial checkin
tz
parents:
diff changeset
    25
"
502
624dc714fd69 copyright changed
tz
parents: 468
diff changeset
    26
 COPYRIGHT (c) 1997 by eXept Software AG
404
35982cf1482f initial checkin
tz
parents:
diff changeset
    27
              All Rights Reserved
35982cf1482f initial checkin
tz
parents:
diff changeset
    28
35982cf1482f initial checkin
tz
parents:
diff changeset
    29
 This software is furnished under a license and may be used
35982cf1482f initial checkin
tz
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
35982cf1482f initial checkin
tz
parents:
diff changeset
    31
 inclusion of the above copyright notice. This software may not
35982cf1482f initial checkin
tz
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
35982cf1482f initial checkin
tz
parents:
diff changeset
    33
 other person. No title to or ownership of the software is
35982cf1482f initial checkin
tz
parents:
diff changeset
    34
 hereby transferred.
35982cf1482f initial checkin
tz
parents:
diff changeset
    35
"
35982cf1482f initial checkin
tz
parents:
diff changeset
    36
35982cf1482f initial checkin
tz
parents:
diff changeset
    37
35982cf1482f initial checkin
tz
parents:
diff changeset
    38
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    39
35982cf1482f initial checkin
tz
parents:
diff changeset
    40
documentation
35982cf1482f initial checkin
tz
parents:
diff changeset
    41
"
35982cf1482f initial checkin
tz
parents:
diff changeset
    42
    documentation to be added.
502
624dc714fd69 copyright changed
tz
parents: 468
diff changeset
    43
624dc714fd69 copyright changed
tz
parents: 468
diff changeset
    44
    [author:]
624dc714fd69 copyright changed
tz
parents: 468
diff changeset
    45
        Thomas Zwick
404
35982cf1482f initial checkin
tz
parents:
diff changeset
    46
"
35982cf1482f initial checkin
tz
parents:
diff changeset
    47
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
    48
35982cf1482f initial checkin
tz
parents:
diff changeset
    49
!FileSelectionBrowser class methodsFor:'instance creation'!
35982cf1482f initial checkin
tz
parents:
diff changeset
    50
35982cf1482f initial checkin
tz
parents:
diff changeset
    51
request: aTitle fileFilters: fileFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
    52
35982cf1482f initial checkin
tz
parents:
diff changeset
    53
    "self request: 'Select A File' fileFilters: #('.*')"
35982cf1482f initial checkin
tz
parents:
diff changeset
    54
35982cf1482f initial checkin
tz
parents:
diff changeset
    55
    ^self new
35982cf1482f initial checkin
tz
parents:
diff changeset
    56
        title: aTitle;
35982cf1482f initial checkin
tz
parents:
diff changeset
    57
        listOfFileFilters: fileFilters;
35982cf1482f initial checkin
tz
parents:
diff changeset
    58
        open
35982cf1482f initial checkin
tz
parents:
diff changeset
    59
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    60
35982cf1482f initial checkin
tz
parents:
diff changeset
    61
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
    62
35982cf1482f initial checkin
tz
parents:
diff changeset
    63
    "self 
35982cf1482f initial checkin
tz
parents:
diff changeset
    64
        request: 'Select Your Profile File' 
35982cf1482f initial checkin
tz
parents:
diff changeset
    65
        fileName: '.profile' 
35982cf1482f initial checkin
tz
parents:
diff changeset
    66
        inDirectory: Filename homeDirectory 
35982cf1482f initial checkin
tz
parents:
diff changeset
    67
        withFileFilters: #('.*')"
35982cf1482f initial checkin
tz
parents:
diff changeset
    68
35982cf1482f initial checkin
tz
parents:
diff changeset
    69
    ^self new
35982cf1482f initial checkin
tz
parents:
diff changeset
    70
        title: aTitle;
35982cf1482f initial checkin
tz
parents:
diff changeset
    71
        fileName: aFileName;
35982cf1482f initial checkin
tz
parents:
diff changeset
    72
        directory: dir;
35982cf1482f initial checkin
tz
parents:
diff changeset
    73
        listOfFileFilters: fileFilters;
35982cf1482f initial checkin
tz
parents:
diff changeset
    74
        open
35982cf1482f initial checkin
tz
parents:
diff changeset
    75
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    76
462
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    77
request: aTitle pathName: aPath fileFilters: fileFilters
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    78
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    79
    "self request: 'Select A File' pathName: '' fileFilters: #('.*')"
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    80
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    81
    ^self new
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    82
        title: aTitle;
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    83
        fileName: aPath;
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    84
        listOfFileFilters: fileFilters;
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    85
        open
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    86
!
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
    87
404
35982cf1482f initial checkin
tz
parents:
diff changeset
    88
requestFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
    89
35982cf1482f initial checkin
tz
parents:
diff changeset
    90
    "self requestFileName"
35982cf1482f initial checkin
tz
parents:
diff changeset
    91
35982cf1482f initial checkin
tz
parents:
diff changeset
    92
    ^self new title: 'Select A File'; open
35982cf1482f initial checkin
tz
parents:
diff changeset
    93
35982cf1482f initial checkin
tz
parents:
diff changeset
    94
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
    95
35982cf1482f initial checkin
tz
parents:
diff changeset
    96
!FileSelectionBrowser class methodsFor:'accessing'!
35982cf1482f initial checkin
tz
parents:
diff changeset
    97
35982cf1482f initial checkin
tz
parents:
diff changeset
    98
loadImageFileNameFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
    99
    ^self saveImageFileNameFilters addAll: #('*.jpeg' '*.jpg'); yourself
35982cf1482f initial checkin
tz
parents:
diff changeset
   100
35982cf1482f initial checkin
tz
parents:
diff changeset
   101
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   102
35982cf1482f initial checkin
tz
parents:
diff changeset
   103
projectFileNameFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
   104
    ^Array withAll: #('*.st' '*.*o'  '*.s' '*.c' 'Make*' '*.project')
35982cf1482f initial checkin
tz
parents:
diff changeset
   105
35982cf1482f initial checkin
tz
parents:
diff changeset
   106
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   107
35982cf1482f initial checkin
tz
parents:
diff changeset
   108
saveImageFileNameFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
   109
    ^Array withAll: #('*.xpm' '*.xbm' '*.gif' '*.tif' '*.tiff' '*.bmp')
35982cf1482f initial checkin
tz
parents:
diff changeset
   110
35982cf1482f initial checkin
tz
parents:
diff changeset
   111
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   112
35982cf1482f initial checkin
tz
parents:
diff changeset
   113
!FileSelectionBrowser class methodsFor:'interface specs'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   114
35982cf1482f initial checkin
tz
parents:
diff changeset
   115
windowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   116
    "this window spec was automatically generated by the ST/X UIPainter"
35982cf1482f initial checkin
tz
parents:
diff changeset
   117
35982cf1482f initial checkin
tz
parents:
diff changeset
   118
    "do not manually edit this - the painter/builder may not be able to
35982cf1482f initial checkin
tz
parents:
diff changeset
   119
     handle the specification if its corrupted."
35982cf1482f initial checkin
tz
parents:
diff changeset
   120
35982cf1482f initial checkin
tz
parents:
diff changeset
   121
    "
35982cf1482f initial checkin
tz
parents:
diff changeset
   122
     UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   123
     FileSelectionBrowser new openInterface:#windowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   124
    "
35982cf1482f initial checkin
tz
parents:
diff changeset
   125
    "FileSelectionBrowser open"
35982cf1482f initial checkin
tz
parents:
diff changeset
   126
35982cf1482f initial checkin
tz
parents:
diff changeset
   127
    <resource: #canvas>
35982cf1482f initial checkin
tz
parents:
diff changeset
   128
35982cf1482f initial checkin
tz
parents:
diff changeset
   129
    ^
35982cf1482f initial checkin
tz
parents:
diff changeset
   130
     
35982cf1482f initial checkin
tz
parents:
diff changeset
   131
       #(#FullSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   132
          #'window:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   133
           #(#WindowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   134
              #'name:' 'File Selection Browser'
615
47f5ba2850d1 do not (!) choose an window extent larger than the smallest mon res
tz
parents: 607
diff changeset
   135
              #'layout:' #(#LayoutFrame 248 0 226 0 847 0 575 0)
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   136
              #'label:' 'File Selection Browser'
35982cf1482f initial checkin
tz
parents:
diff changeset
   137
              #'min:' #(#Point 10 10)
35982cf1482f initial checkin
tz
parents:
diff changeset
   138
              #'max:' #(#Point 1152 900)
615
47f5ba2850d1 do not (!) choose an window extent larger than the smallest mon res
tz
parents: 607
diff changeset
   139
              #'bounds:' #(#Rectangle 248 226 848 576)
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   140
              #'usePreferredExtent:' false
35982cf1482f initial checkin
tz
parents:
diff changeset
   141
          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   142
          #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   143
           #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   144
              #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   145
               #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   146
                 #(#VariableHorizontalPanelSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   147
                    #'name:' 'panel'
35982cf1482f initial checkin
tz
parents:
diff changeset
   148
                    #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   149
                    #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   150
                     #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   151
                        #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   152
                         #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   153
                           #(#ViewSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   154
                              #'name:' 'view1'
35982cf1482f initial checkin
tz
parents:
diff changeset
   155
                              #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   156
                               #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   157
                                  #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   158
                                   #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   159
                                     #(#FileSelectionTreeSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   160
                                        #'name:' 'directoryTreeView'
605
62efcf9d43a4 dir input field moved to bottom
tz
parents: 596
diff changeset
   161
                                        #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0)
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   162
                                        #'model:' #selectionOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   163
                                        #'hasHorizontalScrollBar:' true
35982cf1482f initial checkin
tz
parents:
diff changeset
   164
                                        #'hasVerticalScrollBar:' true
35982cf1482f initial checkin
tz
parents:
diff changeset
   165
                                        #'miniScrollerHorizontal:' true
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   166
                                        #'showDirectoryIndicatorForRoot:' false
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   167
                                        #'showDirectoryIndicator:' true
35982cf1482f initial checkin
tz
parents:
diff changeset
   168
                                        #'valueChangeSelector:' #readDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   169
                                        #'hierarchicalList:' #rootOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   170
                                        #'itemClass:' 'Directory'
35982cf1482f initial checkin
tz
parents:
diff changeset
   171
                                    )
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   172
                                     #(#InputFieldSpec
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   173
                                        #'name:' 'directoryInputField'
607
8b6cd53f93b8 geometry
Claus Gittinger <cg@exept.de>
parents: 605
diff changeset
   174
                                        #'layout:' #(#LayoutFrame 2 0.0 -22 1 0 1.0 0 1)
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   175
                                        #'model:' #selectionOfDirectory
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   176
                                        #'immediateAccept:' false
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   177
                                    )
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   178
                                  )
35982cf1482f initial checkin
tz
parents:
diff changeset
   179
                              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   180
                          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   181
                           #(#ViewSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   182
                              #'name:' 'view2'
35982cf1482f initial checkin
tz
parents:
diff changeset
   183
                              #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   184
                               #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   185
                                  #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   186
                                   #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   187
                                     #(#InputFieldSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   188
                                        #'name:' 'EditField'
607
8b6cd53f93b8 geometry
Claus Gittinger <cg@exept.de>
parents: 605
diff changeset
   189
                                        #'layout:' #(#LayoutFrame 1 0.0 -22 1 -2 1.0 0 1)
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   190
                                        #'model:' #valueOfFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   191
                                        #'acceptOnReturn:' false
35982cf1482f initial checkin
tz
parents:
diff changeset
   192
                                        #'acceptOnTab:' false
35982cf1482f initial checkin
tz
parents:
diff changeset
   193
                                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   194
                                     #(#SubCanvasSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   195
                                        #'name:' 'subCanvas1'
605
62efcf9d43a4 dir input field moved to bottom
tz
parents: 596
diff changeset
   196
                                        #'layout:' #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -25 1.0)
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   197
                                        #'clientHolder:' #directoryView
35982cf1482f initial checkin
tz
parents:
diff changeset
   198
                                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   199
                                  )
35982cf1482f initial checkin
tz
parents:
diff changeset
   200
                              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   201
                          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   202
                        )
35982cf1482f initial checkin
tz
parents:
diff changeset
   203
                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   204
                    #'handles:' #(#Any 0.5 1.0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   205
                )
426
b8110a424326 commit buttons replaced by subSpec in ToolApplicationModel
tz
parents: 404
diff changeset
   206
                 #(#UISubSpecification
b8110a424326 commit buttons replaced by subSpec in ToolApplicationModel
tz
parents: 404
diff changeset
   207
                    #'name:' 'SubSpecification'
607
8b6cd53f93b8 geometry
Claus Gittinger <cg@exept.de>
parents: 605
diff changeset
   208
                    #'layout:' #(#LayoutFrame 2 0.0 -32 1 0 1.0 -8 1.0)
426
b8110a424326 commit buttons replaced by subSpec in ToolApplicationModel
tz
parents: 404
diff changeset
   209
                    #'majorKey:' #ToolApplicationModel
452
d6d5eceb23a9 #valueOfFileName now contains complete path
tz
parents: 426
diff changeset
   210
                    #'minorKey:' #windowSpecForCommitWithoutChannels
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   211
                )
35982cf1482f initial checkin
tz
parents:
diff changeset
   212
              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   213
          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   214
      )
35982cf1482f initial checkin
tz
parents:
diff changeset
   215
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   216
35982cf1482f initial checkin
tz
parents:
diff changeset
   217
!FileSelectionBrowser methodsFor:'accessing'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   218
35982cf1482f initial checkin
tz
parents:
diff changeset
   219
directory: aDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   220
595
1bec50c91fcd wrong dir set fixed
tz
parents: 594
diff changeset
   221
    directory := (aDirectory ? Filename homeDirectory) asFilename asAbsoluteFilename name
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   222
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   223
35982cf1482f initial checkin
tz
parents:
diff changeset
   224
directoryView
35982cf1482f initial checkin
tz
parents:
diff changeset
   225
35982cf1482f initial checkin
tz
parents:
diff changeset
   226
    ^directoryView ? (directoryView := DirectoryView new)
35982cf1482f initial checkin
tz
parents:
diff changeset
   227
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   228
35982cf1482f initial checkin
tz
parents:
diff changeset
   229
fileName: aFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   230
35982cf1482f initial checkin
tz
parents:
diff changeset
   231
    self valueOfFileName value: (aFileName ? '') asFilename baseName.
35982cf1482f initial checkin
tz
parents:
diff changeset
   232
    directory := directory ? ((aFileName ? '') asFilename directoryName).
35982cf1482f initial checkin
tz
parents:
diff changeset
   233
35982cf1482f initial checkin
tz
parents:
diff changeset
   234
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   235
35982cf1482f initial checkin
tz
parents:
diff changeset
   236
listOfFileFilters: anArray
35982cf1482f initial checkin
tz
parents:
diff changeset
   237
35982cf1482f initial checkin
tz
parents:
diff changeset
   238
    listOfFileFilters := anArray
35982cf1482f initial checkin
tz
parents:
diff changeset
   239
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   240
35982cf1482f initial checkin
tz
parents:
diff changeset
   241
!FileSelectionBrowser methodsFor:'accessing - views'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   242
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   243
directoryInputField
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   244
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   245
    ^builder componentAt: #directoryInputField
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   246
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   247
!
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   248
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   249
directoryTreeView
35982cf1482f initial checkin
tz
parents:
diff changeset
   250
35982cf1482f initial checkin
tz
parents:
diff changeset
   251
    ^builder componentAt: #directoryTreeView
35982cf1482f initial checkin
tz
parents:
diff changeset
   252
35982cf1482f initial checkin
tz
parents:
diff changeset
   253
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   254
35982cf1482f initial checkin
tz
parents:
diff changeset
   255
!FileSelectionBrowser methodsFor:'aspects'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   256
35982cf1482f initial checkin
tz
parents:
diff changeset
   257
rootOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   258
35982cf1482f initial checkin
tz
parents:
diff changeset
   259
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   260
    (holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   261
        builder aspectAt:#rootOfDirectory put: (holder :=  Filename rootDirectory name asValue).
35982cf1482f initial checkin
tz
parents:
diff changeset
   262
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   263
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   264
35982cf1482f initial checkin
tz
parents:
diff changeset
   265
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   266
35982cf1482f initial checkin
tz
parents:
diff changeset
   267
selectionOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   268
35982cf1482f initial checkin
tz
parents:
diff changeset
   269
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   270
    (holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   271
        builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new)
35982cf1482f initial checkin
tz
parents:
diff changeset
   272
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   273
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   274
35982cf1482f initial checkin
tz
parents:
diff changeset
   275
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   276
35982cf1482f initial checkin
tz
parents:
diff changeset
   277
valueOfFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   278
35982cf1482f initial checkin
tz
parents:
diff changeset
   279
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   280
    (holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   281
        builder aspectAt:#valueOfFileName put:(holder :=  ValueHolder new).
35982cf1482f initial checkin
tz
parents:
diff changeset
   282
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   283
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   284
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   285
35982cf1482f initial checkin
tz
parents:
diff changeset
   286
!FileSelectionBrowser methodsFor:'callbacks'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   287
35982cf1482f initial checkin
tz
parents:
diff changeset
   288
fileDoubleClicked: aFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   289
35982cf1482f initial checkin
tz
parents:
diff changeset
   290
    self valueOfFileName value: aFileName.
35982cf1482f initial checkin
tz
parents:
diff changeset
   291
    accept value: true.
35982cf1482f initial checkin
tz
parents:
diff changeset
   292
    self close
35982cf1482f initial checkin
tz
parents:
diff changeset
   293
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   294
35982cf1482f initial checkin
tz
parents:
diff changeset
   295
readDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   296
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   297
    self directoryTreeView selection notNil 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   298
    ifTrue: 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   299
    [
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   300
        directoryView directory: self selectionOfDirectory value; readDirectory.
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   301
        directory isNil ifTrue: [self class lastSelection: self selectionOfDirectory value]
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   302
    ]
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   303
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   304
35982cf1482f initial checkin
tz
parents:
diff changeset
   305
!FileSelectionBrowser methodsFor:'startup / release'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   306
35982cf1482f initial checkin
tz
parents:
diff changeset
   307
closeCancel
35982cf1482f initial checkin
tz
parents:
diff changeset
   308
35982cf1482f initial checkin
tz
parents:
diff changeset
   309
    directoryView release.
35982cf1482f initial checkin
tz
parents:
diff changeset
   310
    super closeCancel
35982cf1482f initial checkin
tz
parents:
diff changeset
   311
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   312
35982cf1482f initial checkin
tz
parents:
diff changeset
   313
closeRequest
35982cf1482f initial checkin
tz
parents:
diff changeset
   314
35982cf1482f initial checkin
tz
parents:
diff changeset
   315
    directoryView release.
35982cf1482f initial checkin
tz
parents:
diff changeset
   316
    super closeRequest
35982cf1482f initial checkin
tz
parents:
diff changeset
   317
35982cf1482f initial checkin
tz
parents:
diff changeset
   318
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   319
35982cf1482f initial checkin
tz
parents:
diff changeset
   320
open
35982cf1482f initial checkin
tz
parents:
diff changeset
   321
35982cf1482f initial checkin
tz
parents:
diff changeset
   322
    super open.
515
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   323
    accept value ifTrue:[
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   324
        ^ (self selectionOfDirectory value ? '') asFilename 
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   325
                constructString:(self valueOfFileName value ? '')
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   326
    ].
515
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   327
    ^ nil
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   328
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   329
35982cf1482f initial checkin
tz
parents:
diff changeset
   330
postBuildWith:aBuilder
35982cf1482f initial checkin
tz
parents:
diff changeset
   331
35982cf1482f initial checkin
tz
parents:
diff changeset
   332
    directoryView listOfFileFilters: listOfFileFilters ? #('*').
462
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   333
    directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName asFilename baseName].
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   334
    directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName asFilename baseName].
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   335
    directoryView fileFilterSelectAction: [:fileFilter|
35982cf1482f initial checkin
tz
parents:
diff changeset
   336
    self valueOfFileName value: (
35982cf1482f initial checkin
tz
parents:
diff changeset
   337
        ((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.',
594
75baf3968708 set real directory path
tz
parents: 592
diff changeset
   338
        (fileFilter copy reverse readStream upTo: $.) reverse)]. 
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   339
    self directoryTreeView selectPathname: directory ? self class lastSelection ? '/'.
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   340
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   341
    self directoryInputField entryCompletionBlock: 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   342
    [:f|
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   343
       |completedDirectory|
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   344
       (completedDirectory := Filename 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   345
            filenameCompletionFor: self directoryInputField contents
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   346
            directory:directory 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   347
            directoriesOnly:true 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   348
            filesOnly:false 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   349
            ifMultiple:
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   350
            [:dir | 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   351
                self directoryTreeView selection notNil ifTrue: [
622
e5bc12d7af16 using a public method instead a private one
tz
parents: 619
diff changeset
   352
                    self directoryTreeView selectedNodeExpand: true]
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   353
            ]) asFilename exists
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   354
        ifTrue:
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   355
        [
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   356
            self directoryInputField contents: completedDirectory.
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   357
            self directoryTreeView selectPathname: completedDirectory.
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   358
            self readDirectory
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   359
        ]
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   360
        ifFalse: [self directoryInputField flash]
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   361
    ].
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   362
626
402a50b931d5 select row of file after opening
tz
parents: 622
diff changeset
   363
    directoryView selectionOfFile value: 
402a50b931d5 select row of file after opening
tz
parents: 622
diff changeset
   364
        (directoryView listOfFiles detect: [:row| row baseName = self valueOfFileName value] ifNone: nil).
402a50b931d5 select row of file after opening
tz
parents: 622
diff changeset
   365
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   366
    ^super postBuildWith:aBuilder
35982cf1482f initial checkin
tz
parents:
diff changeset
   367
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   368
35982cf1482f initial checkin
tz
parents:
diff changeset
   369
!FileSelectionBrowser class methodsFor:'documentation'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   370
35982cf1482f initial checkin
tz
parents:
diff changeset
   371
version
35982cf1482f initial checkin
tz
parents:
diff changeset
   372
    ^ '$Header$'
35982cf1482f initial checkin
tz
parents:
diff changeset
   373
! !