FileSelectionBrowser.st
author Claus Gittinger <cg@exept.de>
Fri, 31 Jul 1998 02:10:02 +0200
changeset 933 f090206aadff
parent 923 32fafd49c100
child 957 c09018dc6954
permissions -rw-r--r--
disable some menu items if no class/selector is defined
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
"
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    42
    The FileSelectionBrowser allows you to browse in file directories
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    43
    and to select files in order to load file contents or to save
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    44
    something to files.
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    45
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    46
    [start with:]
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    47
        FileSelectionBrowser open
502
624dc714fd69 copyright changed
tz
parents: 468
diff changeset
    48
624dc714fd69 copyright changed
tz
parents: 468
diff changeset
    49
    [author:]
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    50
        Thomas Zwick, eXept Software AG
404
35982cf1482f initial checkin
tz
parents:
diff changeset
    51
"
35982cf1482f initial checkin
tz
parents:
diff changeset
    52
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
    53
35982cf1482f initial checkin
tz
parents:
diff changeset
    54
!FileSelectionBrowser class methodsFor:'instance creation'!
35982cf1482f initial checkin
tz
parents:
diff changeset
    55
35982cf1482f initial checkin
tz
parents:
diff changeset
    56
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    57
    "
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    58
    self 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
    59
        request: 'Select Your Profile File' 
35982cf1482f initial checkin
tz
parents:
diff changeset
    60
        fileName: '.profile' 
35982cf1482f initial checkin
tz
parents:
diff changeset
    61
        inDirectory: Filename homeDirectory 
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    62
        withFileFilters: #('.*')
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    63
    "
404
35982cf1482f initial checkin
tz
parents:
diff changeset
    64
35982cf1482f initial checkin
tz
parents:
diff changeset
    65
    ^self new
35982cf1482f initial checkin
tz
parents:
diff changeset
    66
        title: aTitle;
35982cf1482f initial checkin
tz
parents:
diff changeset
    67
        fileName: aFileName;
35982cf1482f initial checkin
tz
parents:
diff changeset
    68
        directory: dir;
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
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    73
request: aTitle fileName: aFileName withFileFilters: fileFilters
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    74
    "
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    75
    self 
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    76
        request: 'Select Your Profile File' 
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    77
        fileName: '/etc/fstab' 
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    78
        withFileFilters: #('*')  
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    79
    "
462
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;
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    83
        fileName: aFileName;
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    84
        listOfFileFilters: fileFilters;
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    85
        open
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    86
!
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    87
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    88
request: aTitle pathName: aPath withFileFilters: fileFilters
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    89
    "
871
45c6d4418ae6 checkin from browser
tz
parents: 745
diff changeset
    90
    self 
45c6d4418ae6 checkin from browser
tz
parents: 745
diff changeset
    91
        request: 'Select A File' 
45c6d4418ae6 checkin from browser
tz
parents: 745
diff changeset
    92
        pathName: '/etc' 
45c6d4418ae6 checkin from browser
tz
parents: 745
diff changeset
    93
        withFileFilters: #('*.conf')
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    94
    "
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    95
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    96
    ^self new
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    97
        title: aTitle;
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    98
        directory: aPath;
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
    99
        listOfFileFilters: fileFilters;
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   100
        open
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   101
!
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   102
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   103
request: aTitle withFileFilters: fileFilters
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   104
    "
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   105
    self request: 'Select A File' fileFilters: #('.*')
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   106
    "
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   107
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   108
    ^self new
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   109
        title: aTitle;
462
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   110
        listOfFileFilters: fileFilters;
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   111
        open
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   112
!
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   113
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   114
requestFileName
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   115
    "
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   116
    self requestFileName
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   117
    "
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   118
35982cf1482f initial checkin
tz
parents:
diff changeset
   119
    ^self new title: 'Select A File'; open
35982cf1482f initial checkin
tz
parents:
diff changeset
   120
35982cf1482f initial checkin
tz
parents:
diff changeset
   121
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   122
35982cf1482f initial checkin
tz
parents:
diff changeset
   123
!FileSelectionBrowser class methodsFor:'accessing'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   124
35982cf1482f initial checkin
tz
parents:
diff changeset
   125
loadImageFileNameFilters
923
32fafd49c100 load and saveImageFileNameFilters must return an orderedCollection
Claus Gittinger <cg@exept.de>
parents: 871
diff changeset
   126
    ^self saveImageFileNameFilters addAll: #('*.jpeg' '*.jpg' '*'); yourself
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   127
923
32fafd49c100 load and saveImageFileNameFilters must return an orderedCollection
Claus Gittinger <cg@exept.de>
parents: 871
diff changeset
   128
    "Modified: / 29.7.1998 / 00:56:29 / cg"
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   129
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   130
35982cf1482f initial checkin
tz
parents:
diff changeset
   131
projectFileNameFilters
35982cf1482f initial checkin
tz
parents:
diff changeset
   132
    ^Array withAll: #('*.st' '*.*o'  '*.s' '*.c' 'Make*' '*.project')
35982cf1482f initial checkin
tz
parents:
diff changeset
   133
35982cf1482f initial checkin
tz
parents:
diff changeset
   134
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   135
35982cf1482f initial checkin
tz
parents:
diff changeset
   136
saveImageFileNameFilters
923
32fafd49c100 load and saveImageFileNameFilters must return an orderedCollection
Claus Gittinger <cg@exept.de>
parents: 871
diff changeset
   137
    ^ OrderedCollection withAll: #('*.xpm' '*.xbm' '*.gif' '*.tif' '*.tiff' '*.bmp')
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   138
923
32fafd49c100 load and saveImageFileNameFilters must return an orderedCollection
Claus Gittinger <cg@exept.de>
parents: 871
diff changeset
   139
    "Modified: / 29.7.1998 / 00:55:14 / cg"
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   140
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   141
35982cf1482f initial checkin
tz
parents:
diff changeset
   142
!FileSelectionBrowser class methodsFor:'interface specs'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   143
35982cf1482f initial checkin
tz
parents:
diff changeset
   144
windowSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   145
    "This resource specification was automatically generated
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   146
     by the UIPainter of ST/X."
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   147
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   148
    "Do not manually edit this!! If it is corrupted,
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   149
     the UIPainter may not be able to read the specification."
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   150
35982cf1482f initial checkin
tz
parents:
diff changeset
   151
    "
35982cf1482f initial checkin
tz
parents:
diff changeset
   152
     UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec
35982cf1482f initial checkin
tz
parents:
diff changeset
   153
     FileSelectionBrowser new openInterface:#windowSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   154
     FileSelectionBrowser open
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   155
    "
35982cf1482f initial checkin
tz
parents:
diff changeset
   156
35982cf1482f initial checkin
tz
parents:
diff changeset
   157
    <resource: #canvas>
35982cf1482f initial checkin
tz
parents:
diff changeset
   158
35982cf1482f initial checkin
tz
parents:
diff changeset
   159
    ^
35982cf1482f initial checkin
tz
parents:
diff changeset
   160
     
35982cf1482f initial checkin
tz
parents:
diff changeset
   161
       #(#FullSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   162
          #window: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   163
           #(#WindowSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   164
              #name: 'File Selection Browser'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   165
              #layout: #(#LayoutFrame 379 0 259 0 978 0 608 0)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   166
              #label: 'File Selection Browser'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   167
              #min: #(#Point 10 10)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   168
              #max: #(#Point 1152 900)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   169
              #bounds: #(#Rectangle 379 259 979 609)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   170
              #usePreferredExtent: false
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   171
          )
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   172
          #component: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   173
           #(#SpecCollection
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   174
              #collection: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   175
               #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   176
                 #(#VariableHorizontalPanelSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   177
                    #name: 'panel'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   178
                    #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   179
                    #component: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   180
                     #(#SpecCollection
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   181
                        #collection: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   182
                         #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   183
                           #(#ViewSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   184
                              #name: 'view1'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   185
                              #component: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   186
                               #(#SpecCollection
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   187
                                  #collection: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   188
                                   #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   189
                                     #(#FileSelectionTreeSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   190
                                        #name: 'directoryTreeView'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   191
                                        #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   192
                                        #model: #selectionOfDirectory
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   193
                                        #hasHorizontalScrollBar: true
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   194
                                        #hasVerticalScrollBar: true
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   195
                                        #miniScrollerHorizontal: true
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   196
                                        #showDirectoryIndicatorForRoot: false
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   197
                                        #showDirectoryIndicator: true
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   198
                                        #valueChangeSelector: #readDirectory
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   199
                                        #hierarchicalList: #rootOfDirectory
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   200
                                        #itemClass: 'Directory'
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   201
                                    )
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   202
                                     #(#InputFieldSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   203
                                        #name: 'directoryInputField'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   204
                                        #layout: #(#LayoutFrame 2 0.0 -22 1 0 1.0 0 1)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   205
                                        #model: #selectionOfDirectory
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   206
                                        #immediateAccept: false
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   207
                                    )
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   208
                                  )
35982cf1482f initial checkin
tz
parents:
diff changeset
   209
                              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   210
                          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   211
                           #(#ViewSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   212
                              #name: 'view2'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   213
                              #component: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   214
                               #(#SpecCollection
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   215
                                  #collection: 
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   216
                                   #(
35982cf1482f initial checkin
tz
parents:
diff changeset
   217
                                     #(#InputFieldSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   218
                                        #name: 'EditField'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   219
                                        #layout: #(#LayoutFrame 1 0.0 -22 1 -2 1.0 0 1)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   220
                                        #model: #valueOfFileName
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   221
                                        #acceptOnReturn: false
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   222
                                        #acceptOnTab: false
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   223
                                    )
35982cf1482f initial checkin
tz
parents:
diff changeset
   224
                                     #(#SubCanvasSpec
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   225
                                        #name: 'subCanvas1'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   226
                                        #layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -25 1.0)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   227
                                        #clientHolder: #directoryView
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   228
                                    )
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
                    )
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   234
                    #handles: #(#Any 0.5 1.0)
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   235
                )
426
b8110a424326 commit buttons replaced by subSpec in ToolApplicationModel
tz
parents: 404
diff changeset
   236
                 #(#UISubSpecification
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   237
                    #name: 'SubSpecification'
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   238
                    #layout: #(#LayoutFrame 2 0.0 -32 1 0 1.0 -8 1.0)
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   239
                    #majorKey: #ToolApplicationModel
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   240
                    #minorKey: #windowSpecForCommitWithoutChannels
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   241
                )
35982cf1482f initial checkin
tz
parents:
diff changeset
   242
              )
35982cf1482f initial checkin
tz
parents:
diff changeset
   243
          )
35982cf1482f initial checkin
tz
parents:
diff changeset
   244
      )
35982cf1482f initial checkin
tz
parents:
diff changeset
   245
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   246
35982cf1482f initial checkin
tz
parents:
diff changeset
   247
!FileSelectionBrowser methodsFor:'accessing'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   248
35982cf1482f initial checkin
tz
parents:
diff changeset
   249
directory: aDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   250
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   251
    directory := (aDirectory ? Filename currentDirectory) asFilename asAbsoluteFilename name
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   252
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   253
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   254
35982cf1482f initial checkin
tz
parents:
diff changeset
   255
directoryView
35982cf1482f initial checkin
tz
parents:
diff changeset
   256
35982cf1482f initial checkin
tz
parents:
diff changeset
   257
    ^directoryView ? (directoryView := DirectoryView new)
35982cf1482f initial checkin
tz
parents:
diff changeset
   258
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   259
35982cf1482f initial checkin
tz
parents:
diff changeset
   260
fileName: aFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   261
35982cf1482f initial checkin
tz
parents:
diff changeset
   262
    self valueOfFileName value: (aFileName ? '') asFilename baseName.
35982cf1482f initial checkin
tz
parents:
diff changeset
   263
    directory := directory ? ((aFileName ? '') asFilename directoryName).
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   264
                       
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   265
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   266
35982cf1482f initial checkin
tz
parents:
diff changeset
   267
listOfFileFilters: anArray
35982cf1482f initial checkin
tz
parents:
diff changeset
   268
35982cf1482f initial checkin
tz
parents:
diff changeset
   269
    listOfFileFilters := anArray
35982cf1482f initial checkin
tz
parents:
diff changeset
   270
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   271
35982cf1482f initial checkin
tz
parents:
diff changeset
   272
!FileSelectionBrowser methodsFor:'accessing - views'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   273
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   274
directoryInputField
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   275
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   276
    ^builder componentAt: #directoryInputField
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   277
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   278
!
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   279
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   280
directoryTreeView
35982cf1482f initial checkin
tz
parents:
diff changeset
   281
35982cf1482f initial checkin
tz
parents:
diff changeset
   282
    ^builder componentAt: #directoryTreeView
35982cf1482f initial checkin
tz
parents:
diff changeset
   283
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:'aspects'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   287
35982cf1482f initial checkin
tz
parents:
diff changeset
   288
rootOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   289
35982cf1482f initial checkin
tz
parents:
diff changeset
   290
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   291
    (holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   292
        builder aspectAt:#rootOfDirectory put: (holder :=  Filename rootDirectory name asValue).
35982cf1482f initial checkin
tz
parents:
diff changeset
   293
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   294
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   295
35982cf1482f initial checkin
tz
parents:
diff changeset
   296
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   297
35982cf1482f initial checkin
tz
parents:
diff changeset
   298
selectionOfDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   299
35982cf1482f initial checkin
tz
parents:
diff changeset
   300
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   301
    (holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   302
        builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new)
35982cf1482f initial checkin
tz
parents:
diff changeset
   303
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   304
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   305
35982cf1482f initial checkin
tz
parents:
diff changeset
   306
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   307
35982cf1482f initial checkin
tz
parents:
diff changeset
   308
valueOfFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   309
35982cf1482f initial checkin
tz
parents:
diff changeset
   310
    |holder|
35982cf1482f initial checkin
tz
parents:
diff changeset
   311
    (holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[
35982cf1482f initial checkin
tz
parents:
diff changeset
   312
        builder aspectAt:#valueOfFileName put:(holder :=  ValueHolder new).
35982cf1482f initial checkin
tz
parents:
diff changeset
   313
    ].
35982cf1482f initial checkin
tz
parents:
diff changeset
   314
    ^ holder
35982cf1482f initial checkin
tz
parents:
diff changeset
   315
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   316
35982cf1482f initial checkin
tz
parents:
diff changeset
   317
!FileSelectionBrowser methodsFor:'callbacks'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   318
35982cf1482f initial checkin
tz
parents:
diff changeset
   319
fileDoubleClicked: aFileName
35982cf1482f initial checkin
tz
parents:
diff changeset
   320
35982cf1482f initial checkin
tz
parents:
diff changeset
   321
    self valueOfFileName value: aFileName.
35982cf1482f initial checkin
tz
parents:
diff changeset
   322
    accept value: true.
35982cf1482f initial checkin
tz
parents:
diff changeset
   323
    self close
35982cf1482f initial checkin
tz
parents:
diff changeset
   324
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   325
35982cf1482f initial checkin
tz
parents:
diff changeset
   326
readDirectory
35982cf1482f initial checkin
tz
parents:
diff changeset
   327
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   328
    self directoryTreeView selection notNil 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   329
    ifTrue: 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   330
    [
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   331
        directoryView directory: self selectionOfDirectory value; readDirectory.  
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   332
        self class lastSelection notNil ifTrue: [self class lastSelection: self selectionOfDirectory value]
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   333
    ]
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   334
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   335
35982cf1482f initial checkin
tz
parents:
diff changeset
   336
!FileSelectionBrowser methodsFor:'startup / release'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   337
35982cf1482f initial checkin
tz
parents:
diff changeset
   338
closeCancel
35982cf1482f initial checkin
tz
parents:
diff changeset
   339
35982cf1482f initial checkin
tz
parents:
diff changeset
   340
    directoryView release.
35982cf1482f initial checkin
tz
parents:
diff changeset
   341
    super closeCancel
35982cf1482f initial checkin
tz
parents:
diff changeset
   342
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   343
35982cf1482f initial checkin
tz
parents:
diff changeset
   344
closeRequest
35982cf1482f initial checkin
tz
parents:
diff changeset
   345
35982cf1482f initial checkin
tz
parents:
diff changeset
   346
    directoryView release.
35982cf1482f initial checkin
tz
parents:
diff changeset
   347
    super closeRequest
35982cf1482f initial checkin
tz
parents:
diff changeset
   348
35982cf1482f initial checkin
tz
parents:
diff changeset
   349
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   350
35982cf1482f initial checkin
tz
parents:
diff changeset
   351
open
35982cf1482f initial checkin
tz
parents:
diff changeset
   352
35982cf1482f initial checkin
tz
parents:
diff changeset
   353
    super open.
515
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   354
    accept value ifTrue:[
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   355
        ^ (self selectionOfDirectory value ? '') asFilename 
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   356
                constructString:(self valueOfFileName value ? '')
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   357
    ].
515
1b64e990e495 Fix copyright.
Stefan Vogel <sv@exept.de>
parents: 502
diff changeset
   358
    ^ nil
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   359
!
35982cf1482f initial checkin
tz
parents:
diff changeset
   360
35982cf1482f initial checkin
tz
parents:
diff changeset
   361
postBuildWith:aBuilder
35982cf1482f initial checkin
tz
parents:
diff changeset
   362
35982cf1482f initial checkin
tz
parents:
diff changeset
   363
    directoryView listOfFileFilters: listOfFileFilters ? #('*').
462
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   364
    directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName asFilename baseName].
90b8b353cd2f *** empty log message ***
tz
parents: 452
diff changeset
   365
    directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName asFilename baseName].
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   366
    directoryView fileFilterSelectAction: [:fileFilter|
35982cf1482f initial checkin
tz
parents:
diff changeset
   367
    self valueOfFileName value: (
35982cf1482f initial checkin
tz
parents:
diff changeset
   368
        ((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.',
594
75baf3968708 set real directory path
tz
parents: 592
diff changeset
   369
        (fileFilter copy reverse readStream upTo: $.) reverse)]. 
745
d3995881fa13 some changes for instancing
tz
parents: 626
diff changeset
   370
    self directoryTreeView selectPathname: directory ? self class lastSelection ? Filename currentDirectory asAbsoluteFilename name.
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   371
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   372
    self directoryInputField entryCompletionBlock: 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   373
    [:f|
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   374
       |completedDirectory|
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   375
       (completedDirectory := Filename 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   376
            filenameCompletionFor: self directoryInputField contents
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   377
            directory:directory 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   378
            directoriesOnly:true 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   379
            filesOnly:false 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   380
            ifMultiple:
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   381
            [:dir | 
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   382
                self directoryTreeView selection notNil ifTrue: [
622
e5bc12d7af16 using a public method instead a private one
tz
parents: 619
diff changeset
   383
                    self directoryTreeView selectedNodeExpand: true]
592
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   384
            ]) asFilename exists
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   385
        ifTrue:
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   386
        [
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   387
            self directoryInputField contents: completedDirectory.
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   388
            self directoryTreeView selectPathname: completedDirectory.
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   389
            self readDirectory
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   390
        ]
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   391
        ifFalse: [self directoryInputField flash]
0383cd70fe79 dir input field added
tz
parents: 589
diff changeset
   392
    ].
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   393
626
402a50b931d5 select row of file after opening
tz
parents: 622
diff changeset
   394
    directoryView selectionOfFile value: 
402a50b931d5 select row of file after opening
tz
parents: 622
diff changeset
   395
        (directoryView listOfFiles detect: [:row| row baseName = self valueOfFileName value] ifNone: nil).
402a50b931d5 select row of file after opening
tz
parents: 622
diff changeset
   396
404
35982cf1482f initial checkin
tz
parents:
diff changeset
   397
    ^super postBuildWith:aBuilder
35982cf1482f initial checkin
tz
parents:
diff changeset
   398
! !
35982cf1482f initial checkin
tz
parents:
diff changeset
   399
35982cf1482f initial checkin
tz
parents:
diff changeset
   400
!FileSelectionBrowser class methodsFor:'documentation'!
35982cf1482f initial checkin
tz
parents:
diff changeset
   401
35982cf1482f initial checkin
tz
parents:
diff changeset
   402
version
35982cf1482f initial checkin
tz
parents:
diff changeset
   403
    ^ '$Header$'
35982cf1482f initial checkin
tz
parents:
diff changeset
   404
! !