FileSelectionBrowser.st
author tz
Sat, 10 Jan 1998 11:53:03 +0100
changeset 404 35982cf1482f
child 426 b8110a424326
permissions -rw-r--r--
initial checkin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
404
35982cf1482f initial checkin
tz
parents:
diff changeset
     1
"
35982cf1482f initial checkin
tz
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG / Thomas Zwick
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:''
35982cf1482f initial checkin
tz
parents:
diff changeset
    19
	category:'Interface-Advanced-Tools'
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
"
35982cf1482f initial checkin
tz
parents:
diff changeset
    26
 COPYRIGHT (c) 1997 by eXept Software AG / Thomas Zwick
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.
35982cf1482f initial checkin
tz
parents:
diff changeset
    43
"
35982cf1482f initial checkin
tz
parents:
diff changeset
    44
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    45
35982cf1482f initial checkin
tz
parents:
diff changeset
    46
history
35982cf1482f initial checkin
tz
parents:
diff changeset
    47
    "Created: / 10.1.1998 / 11:00:06 / tz"
35982cf1482f initial checkin
tz
parents:
diff changeset
    48
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
    49
35982cf1482f initial checkin
tz
parents:
diff changeset
    50
!FileSelectionBrowser class methodsFor:'instance creation'!
35982cf1482f initial checkin
tz
parents:
diff changeset
    51
35982cf1482f initial checkin
tz
parents:
diff changeset
    52
request: aTitle fileFilters: fileFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
    53
35982cf1482f initial checkin
tz
parents:
diff changeset
    54
    "self request: 'Select A File' fileFilters: #('.*')"
35982cf1482f initial checkin
tz
parents:
diff changeset
    55
35982cf1482f initial checkin
tz
parents:
diff changeset
    56
    ^self new
35982cf1482f initial checkin
tz
parents:
diff changeset
    57
        title: aTitle;
35982cf1482f initial checkin
tz
parents:
diff changeset
    58
        listOfFileFilters: fileFilters;
35982cf1482f initial checkin
tz
parents:
diff changeset
    59
        open
35982cf1482f initial checkin
tz
parents:
diff changeset
    60
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    61
35982cf1482f initial checkin
tz
parents:
diff changeset
    62
request: aTitle fileName: aFileName fileFilters: fileFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
    63
35982cf1482f initial checkin
tz
parents:
diff changeset
    64
    "self request: 'Select A File' fileName: '' fileFilters: #('.*')"
35982cf1482f initial checkin
tz
parents:
diff changeset
    65
    
35982cf1482f initial checkin
tz
parents:
diff changeset
    66
    ^self new
35982cf1482f initial checkin
tz
parents:
diff changeset
    67
        title: aTitle;
35982cf1482f initial checkin
tz
parents:
diff changeset
    68
        fileName: aFileName;
35982cf1482f initial checkin
tz
parents:
diff changeset
    69
        listOfFileFilters: fileFilters;
35982cf1482f initial checkin
tz
parents:
diff changeset
    70
        open
35982cf1482f initial checkin
tz
parents:
diff changeset
    71
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    72
35982cf1482f initial checkin
tz
parents:
diff changeset
    73
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
    74
35982cf1482f initial checkin
tz
parents:
diff changeset
    75
    "self 
35982cf1482f initial checkin
tz
parents:
diff changeset
    76
        request: 'Select Your Profile File' 
35982cf1482f initial checkin
tz
parents:
diff changeset
    77
        fileName: '.profile' 
35982cf1482f initial checkin
tz
parents:
diff changeset
    78
        inDirectory: Filename homeDirectory 
35982cf1482f initial checkin
tz
parents:
diff changeset
    79
        withFileFilters: #('.*')"
35982cf1482f initial checkin
tz
parents:
diff changeset
    80
35982cf1482f initial checkin
tz
parents:
diff changeset
    81
    ^self new
35982cf1482f initial checkin
tz
parents:
diff changeset
    82
        title: aTitle;
35982cf1482f initial checkin
tz
parents:
diff changeset
    83
        fileName: aFileName;
35982cf1482f initial checkin
tz
parents:
diff changeset
    84
        directory: dir;
35982cf1482f initial checkin
tz
parents:
diff changeset
    85
        listOfFileFilters: fileFilters;
35982cf1482f initial checkin
tz
parents:
diff changeset
    86
        open
35982cf1482f initial checkin
tz
parents:
diff changeset
    87
!
35982cf1482f initial checkin
tz
parents:
diff changeset
    88
35982cf1482f initial checkin
tz
parents:
diff changeset
    89
requestFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
    90
35982cf1482f initial checkin
tz
parents:
diff changeset
    91
    "self requestFileName"
35982cf1482f initial checkin
tz
parents:
diff changeset
    92
35982cf1482f initial checkin
tz
parents:
diff changeset
    93
    ^self new title: 'Select A File'; open
35982cf1482f initial checkin
tz
parents:
diff changeset
    94
35982cf1482f initial checkin
tz
parents:
diff changeset
    95
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
    96
35982cf1482f initial checkin
tz
parents:
diff changeset
    97
!FileSelectionBrowser class methodsFor:'accessing'!
35982cf1482f initial checkin
tz
parents:
diff changeset
    98
35982cf1482f initial checkin
tz
parents:
diff changeset
    99
loadImageFileNameFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
   100
    ^self saveImageFileNameFilters addAll: #('*.jpeg' '*.jpg'); yourself
35982cf1482f initial checkin
tz
parents:
diff changeset
   101
35982cf1482f initial checkin
tz
parents:
diff changeset
   102
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   103
35982cf1482f initial checkin
tz
parents:
diff changeset
   104
projectFileNameFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
   105
    ^Array withAll: #('*.st' '*.*o'  '*.s' '*.c' 'Make*' '*.project')
35982cf1482f initial checkin
tz
parents:
diff changeset
   106
35982cf1482f initial checkin
tz
parents:
diff changeset
   107
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   108
35982cf1482f initial checkin
tz
parents:
diff changeset
   109
saveImageFileNameFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
   110
    ^Array withAll: #('*.xpm' '*.xbm' '*.gif' '*.tif' '*.tiff' '*.bmp')
35982cf1482f initial checkin
tz
parents:
diff changeset
   111
35982cf1482f initial checkin
tz
parents:
diff changeset
   112
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   113
35982cf1482f initial checkin
tz
parents:
diff changeset
   114
!FileSelectionBrowser class methodsFor:'interface specs'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   115
35982cf1482f initial checkin
tz
parents:
diff changeset
   116
windowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   117
    "this window spec was automatically generated by the ST/X UIPainter"
35982cf1482f initial checkin
tz
parents:
diff changeset
   118
35982cf1482f initial checkin
tz
parents:
diff changeset
   119
    "do not manually edit this - the painter/builder may not be able to
35982cf1482f initial checkin
tz
parents:
diff changeset
   120
     handle the specification if its corrupted."
35982cf1482f initial checkin
tz
parents:
diff changeset
   121
35982cf1482f initial checkin
tz
parents:
diff changeset
   122
    "
35982cf1482f initial checkin
tz
parents:
diff changeset
   123
     UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   124
     FileSelectionBrowser new openInterface:#windowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   125
    "
35982cf1482f initial checkin
tz
parents:
diff changeset
   126
    "FileSelectionBrowser open"
35982cf1482f initial checkin
tz
parents:
diff changeset
   127
35982cf1482f initial checkin
tz
parents:
diff changeset
   128
    <resource: #canvas>
35982cf1482f initial checkin
tz
parents:
diff changeset
   129
35982cf1482f initial checkin
tz
parents:
diff changeset
   130
    ^
35982cf1482f initial checkin
tz
parents:
diff changeset
   131
     
35982cf1482f initial checkin
tz
parents:
diff changeset
   132
       #(#FullSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   133
          #'window:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   134
           #(#WindowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   135
              #'name:' 'File Selection Browser'
35982cf1482f initial checkin
tz
parents:
diff changeset
   136
              #'layout:' #(#LayoutFrame 130 0 174 0 529 0 473 0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   137
              #'label:' 'File Selection Browser'
35982cf1482f initial checkin
tz
parents:
diff changeset
   138
              #'min:' #(#Point 10 10)
35982cf1482f initial checkin
tz
parents:
diff changeset
   139
              #'max:' #(#Point 1152 900)
35982cf1482f initial checkin
tz
parents:
diff changeset
   140
              #'bounds:' #(#Rectangle 130 174 530 474)
35982cf1482f initial checkin
tz
parents:
diff changeset
   141
              #'usePreferredExtent:' false
35982cf1482f initial checkin
tz
parents:
diff changeset
   142
          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   143
          #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   144
           #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   145
              #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   146
               #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   147
                 #(#VariableHorizontalPanelSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   148
                    #'name:' 'panel'
35982cf1482f initial checkin
tz
parents:
diff changeset
   149
                    #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   150
                    #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   151
                     #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   152
                        #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   153
                         #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   154
                           #(#ViewSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   155
                              #'name:' 'view1'
35982cf1482f initial checkin
tz
parents:
diff changeset
   156
                              #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   157
                               #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   158
                                  #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   159
                                   #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   160
                                     #(#FileSelectionTreeSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   161
                                        #'name:' 'directoryTreeView'
35982cf1482f initial checkin
tz
parents:
diff changeset
   162
                                        #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   163
                                        #'model:' #selectionOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   164
                                        #'hasHorizontalScrollBar:' true
35982cf1482f initial checkin
tz
parents:
diff changeset
   165
                                        #'hasVerticalScrollBar:' true
35982cf1482f initial checkin
tz
parents:
diff changeset
   166
                                        #'miniScrollerHorizontal:' true
35982cf1482f initial checkin
tz
parents:
diff changeset
   167
                                        #'showRoot:' false
35982cf1482f initial checkin
tz
parents:
diff changeset
   168
                                        #'showDirectoryIndicator:' true
35982cf1482f initial checkin
tz
parents:
diff changeset
   169
                                        #'valueChangeSelector:' #readDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   170
                                        #'hierarchicalList:' #rootOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   171
                                        #'itemClass:' 'Directory'
35982cf1482f initial checkin
tz
parents:
diff changeset
   172
                                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   173
                                  )
35982cf1482f initial checkin
tz
parents:
diff changeset
   174
                              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   175
                              #'level:' -1
35982cf1482f initial checkin
tz
parents:
diff changeset
   176
                          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   177
                           #(#ViewSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   178
                              #'name:' 'view2'
35982cf1482f initial checkin
tz
parents:
diff changeset
   179
                              #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   180
                               #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   181
                                  #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   182
                                   #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   183
                                     #(#InputFieldSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   184
                                        #'name:' 'EditField'
35982cf1482f initial checkin
tz
parents:
diff changeset
   185
                                        #'layout:' #(#LayoutFrame 1 0.0 -22 1 0 1.0 0 1)
35982cf1482f initial checkin
tz
parents:
diff changeset
   186
                                        #'model:' #valueOfFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   187
                                        #'acceptOnReturn:' false
35982cf1482f initial checkin
tz
parents:
diff changeset
   188
                                        #'acceptOnTab:' false
35982cf1482f initial checkin
tz
parents:
diff changeset
   189
                                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   190
                                     #(#SubCanvasSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   191
                                        #'name:' 'subCanvas1'
35982cf1482f initial checkin
tz
parents:
diff changeset
   192
                                        #'layout:' #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -22 1.0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   193
                                        #'clientHolder:' #directoryView
35982cf1482f initial checkin
tz
parents:
diff changeset
   194
                                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   195
                                  )
35982cf1482f initial checkin
tz
parents:
diff changeset
   196
                              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   197
                              #'level:' -1
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
                    #'handles:' #(#Any 0.5 1.0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   202
                )
35982cf1482f initial checkin
tz
parents:
diff changeset
   203
                 #(#HorizontalPanelViewSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   204
                    #'name:' 'horizontalPanelView'
35982cf1482f initial checkin
tz
parents:
diff changeset
   205
                    #'layout:' #(#LayoutFrame 0 0.0 -40 1 0 1.0 0 1.0)
35982cf1482f initial checkin
tz
parents:
diff changeset
   206
                    #'component:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   207
                     #(#SpecCollection
35982cf1482f initial checkin
tz
parents:
diff changeset
   208
                        #'collection:' 
35982cf1482f initial checkin
tz
parents:
diff changeset
   209
                         #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   210
                           #(#ActionButtonSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   211
                              #'name:' 'cancelButton'
35982cf1482f initial checkin
tz
parents:
diff changeset
   212
                              #'label:' 'Cancel'
35982cf1482f initial checkin
tz
parents:
diff changeset
   213
                              #'model:' #cancel
35982cf1482f initial checkin
tz
parents:
diff changeset
   214
                              #'extent:' #(#Point 100 22)
35982cf1482f initial checkin
tz
parents:
diff changeset
   215
                          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   216
                           #(#ActionButtonSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   217
                              #'name:' 'okButton'
35982cf1482f initial checkin
tz
parents:
diff changeset
   218
                              #'label:' 'OK'
35982cf1482f initial checkin
tz
parents:
diff changeset
   219
                              #'model:' #accept
35982cf1482f initial checkin
tz
parents:
diff changeset
   220
                              #'extent:' #(#Point 100 22)
35982cf1482f initial checkin
tz
parents:
diff changeset
   221
                          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   222
                        )
35982cf1482f initial checkin
tz
parents:
diff changeset
   223
                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   224
                    #'level:' 1
35982cf1482f initial checkin
tz
parents:
diff changeset
   225
                    #'horizontalLayout:' #center
35982cf1482f initial checkin
tz
parents:
diff changeset
   226
                    #'verticalLayout:' #center
35982cf1482f initial checkin
tz
parents:
diff changeset
   227
                    #'horizontalSpace:' 3
35982cf1482f initial checkin
tz
parents:
diff changeset
   228
                    #'verticalSpace:' 3
35982cf1482f initial checkin
tz
parents:
diff changeset
   229
                )
35982cf1482f initial checkin
tz
parents:
diff changeset
   230
              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   231
          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   232
      )
35982cf1482f initial checkin
tz
parents:
diff changeset
   233
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   234
35982cf1482f initial checkin
tz
parents:
diff changeset
   235
!FileSelectionBrowser methodsFor:'accessing'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   236
35982cf1482f initial checkin
tz
parents:
diff changeset
   237
directory: aDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   238
35982cf1482f initial checkin
tz
parents:
diff changeset
   239
    directory := aDirectory asFilename asAbsoluteFilename name
35982cf1482f initial checkin
tz
parents:
diff changeset
   240
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   241
35982cf1482f initial checkin
tz
parents:
diff changeset
   242
directoryView
35982cf1482f initial checkin
tz
parents:
diff changeset
   243
35982cf1482f initial checkin
tz
parents:
diff changeset
   244
    ^directoryView ? (directoryView := DirectoryView new)
35982cf1482f initial checkin
tz
parents:
diff changeset
   245
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   246
35982cf1482f initial checkin
tz
parents:
diff changeset
   247
fileName: aFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   248
35982cf1482f initial checkin
tz
parents:
diff changeset
   249
    self valueOfFileName value: (aFileName ? '') asFilename baseName.
35982cf1482f initial checkin
tz
parents:
diff changeset
   250
    directory := directory ? ((aFileName ? '') asFilename directoryName).
35982cf1482f initial checkin
tz
parents:
diff changeset
   251
35982cf1482f initial checkin
tz
parents:
diff changeset
   252
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   253
35982cf1482f initial checkin
tz
parents:
diff changeset
   254
listOfFileFilters: anArray
35982cf1482f initial checkin
tz
parents:
diff changeset
   255
35982cf1482f initial checkin
tz
parents:
diff changeset
   256
    listOfFileFilters := anArray
35982cf1482f initial checkin
tz
parents:
diff changeset
   257
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   258
35982cf1482f initial checkin
tz
parents:
diff changeset
   259
!FileSelectionBrowser methodsFor:'accessing - views'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   260
35982cf1482f initial checkin
tz
parents:
diff changeset
   261
directoryTreeView
35982cf1482f initial checkin
tz
parents:
diff changeset
   262
35982cf1482f initial checkin
tz
parents:
diff changeset
   263
    ^builder componentAt: #directoryTreeView
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
!FileSelectionBrowser methodsFor:'aspects'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   268
35982cf1482f initial checkin
tz
parents:
diff changeset
   269
rootOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   270
35982cf1482f initial checkin
tz
parents:
diff changeset
   271
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   272
    (holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   273
        builder aspectAt:#rootOfDirectory put: (holder :=  Filename rootDirectory name asValue).
35982cf1482f initial checkin
tz
parents:
diff changeset
   274
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   275
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   276
35982cf1482f initial checkin
tz
parents:
diff changeset
   277
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   278
35982cf1482f initial checkin
tz
parents:
diff changeset
   279
selectionOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   280
35982cf1482f initial checkin
tz
parents:
diff changeset
   281
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   282
    (holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   283
        builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new)
35982cf1482f initial checkin
tz
parents:
diff changeset
   284
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   285
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   286
35982cf1482f initial checkin
tz
parents:
diff changeset
   287
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   288
35982cf1482f initial checkin
tz
parents:
diff changeset
   289
valueOfFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   290
35982cf1482f initial checkin
tz
parents:
diff changeset
   291
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   292
    (holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   293
        builder aspectAt:#valueOfFileName put:(holder :=  ValueHolder new).
35982cf1482f initial checkin
tz
parents:
diff changeset
   294
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   295
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   296
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   297
35982cf1482f initial checkin
tz
parents:
diff changeset
   298
!FileSelectionBrowser methodsFor:'callbacks'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   299
35982cf1482f initial checkin
tz
parents:
diff changeset
   300
fileDoubleClicked: aFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   301
35982cf1482f initial checkin
tz
parents:
diff changeset
   302
    self valueOfFileName value: aFileName.
35982cf1482f initial checkin
tz
parents:
diff changeset
   303
    accept value: true.
35982cf1482f initial checkin
tz
parents:
diff changeset
   304
    self close
35982cf1482f initial checkin
tz
parents:
diff changeset
   305
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   306
35982cf1482f initial checkin
tz
parents:
diff changeset
   307
readDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   308
    "Diesen Mist musste ich machen, weil ztk es nicht fertig bringt,
35982cf1482f initial checkin
tz
parents:
diff changeset
   309
    seine Models upzudaten, bevor er die Callbacks aufruft!!!!!!"
35982cf1482f initial checkin
tz
parents:
diff changeset
   310
35982cf1482f initial checkin
tz
parents:
diff changeset
   311
    |dir|
35982cf1482f initial checkin
tz
parents:
diff changeset
   312
    directoryView listOfFiles removeAll.
35982cf1482f initial checkin
tz
parents:
diff changeset
   313
    directoryView directory: 
35982cf1482f initial checkin
tz
parents:
diff changeset
   314
        (dir := (self directoryTreeView model list at:
35982cf1482f initial checkin
tz
parents:
diff changeset
   315
        self directoryTreeView model selection) contents name);   
35982cf1482f initial checkin
tz
parents:
diff changeset
   316
        readDirectory.
35982cf1482f initial checkin
tz
parents:
diff changeset
   317
    directory isNil ifTrue: [self class lastSelection: dir]
35982cf1482f initial checkin
tz
parents:
diff changeset
   318
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   319
35982cf1482f initial checkin
tz
parents:
diff changeset
   320
!FileSelectionBrowser methodsFor:'startup / release'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   321
35982cf1482f initial checkin
tz
parents:
diff changeset
   322
closeCancel
35982cf1482f initial checkin
tz
parents:
diff changeset
   323
35982cf1482f initial checkin
tz
parents:
diff changeset
   324
    directoryView release.
35982cf1482f initial checkin
tz
parents:
diff changeset
   325
    super closeCancel
35982cf1482f initial checkin
tz
parents:
diff changeset
   326
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   327
35982cf1482f initial checkin
tz
parents:
diff changeset
   328
closeRequest
35982cf1482f initial checkin
tz
parents:
diff changeset
   329
35982cf1482f initial checkin
tz
parents:
diff changeset
   330
    directoryView release.
35982cf1482f initial checkin
tz
parents:
diff changeset
   331
    super closeRequest
35982cf1482f initial checkin
tz
parents:
diff changeset
   332
35982cf1482f initial checkin
tz
parents:
diff changeset
   333
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   334
35982cf1482f initial checkin
tz
parents:
diff changeset
   335
open
35982cf1482f initial checkin
tz
parents:
diff changeset
   336
35982cf1482f initial checkin
tz
parents:
diff changeset
   337
    super open.
35982cf1482f initial checkin
tz
parents:
diff changeset
   338
    accept value
35982cf1482f initial checkin
tz
parents:
diff changeset
   339
    ifTrue:
35982cf1482f initial checkin
tz
parents:
diff changeset
   340
    [
35982cf1482f initial checkin
tz
parents:
diff changeset
   341
        ^(self selectionOfDirectory value ? '') , Filename separator, (self valueOfFileName value ? '')
35982cf1482f initial checkin
tz
parents:
diff changeset
   342
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   343
    ^nil
35982cf1482f initial checkin
tz
parents:
diff changeset
   344
35982cf1482f initial checkin
tz
parents:
diff changeset
   345
35982cf1482f initial checkin
tz
parents:
diff changeset
   346
35982cf1482f initial checkin
tz
parents:
diff changeset
   347
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   348
35982cf1482f initial checkin
tz
parents:
diff changeset
   349
postBuildWith:aBuilder
35982cf1482f initial checkin
tz
parents:
diff changeset
   350
35982cf1482f initial checkin
tz
parents:
diff changeset
   351
    directoryView listOfFileFilters: listOfFileFilters ? #('*').
35982cf1482f initial checkin
tz
parents:
diff changeset
   352
    directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName].
35982cf1482f initial checkin
tz
parents:
diff changeset
   353
    directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName].
35982cf1482f initial checkin
tz
parents:
diff changeset
   354
    directoryView fileFilterSelectAction: [:fileFilter|
35982cf1482f initial checkin
tz
parents:
diff changeset
   355
    self valueOfFileName value: (
35982cf1482f initial checkin
tz
parents:
diff changeset
   356
        ((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.',
35982cf1482f initial checkin
tz
parents:
diff changeset
   357
        (fileFilter copy reverse readStream upTo: $.) reverse)].
35982cf1482f initial checkin
tz
parents:
diff changeset
   358
    self directoryTreeView selectPathname: directory ? self class lastSelection.
35982cf1482f initial checkin
tz
parents:
diff changeset
   359
    self directoryTreeView monitoring: true.
35982cf1482f initial checkin
tz
parents:
diff changeset
   360
35982cf1482f initial checkin
tz
parents:
diff changeset
   361
    ^super postBuildWith:aBuilder
35982cf1482f initial checkin
tz
parents:
diff changeset
   362
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   363
35982cf1482f initial checkin
tz
parents:
diff changeset
   364
!FileSelectionBrowser class methodsFor:'documentation'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   365
35982cf1482f initial checkin
tz
parents:
diff changeset
   366
version
35982cf1482f initial checkin
tz
parents:
diff changeset
   367
    ^ '$Header$'
35982cf1482f initial checkin
tz
parents:
diff changeset
   368
! !