author | Claus Gittinger <cg@exept.de> |
Fri, 25 Sep 1998 17:56:19 +0200 | |
changeset 1005 | 0b2b698bc4f3 |
parent 1003 | 7880fc48f0bb |
child 1011 | b3be5697d26f |
permissions | -rw-r--r-- |
404 | 1 |
" |
502 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
404 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
14 |
||
15 |
SelectionBrowser subclass:#FileSelectionBrowser |
|
16 |
instanceVariableNames:'selectedFileFilter directoryView listOfFileFilters directory' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
619 | 19 |
category:'Interface-Dialogs' |
404 | 20 |
! |
21 |
||
22 |
!FileSelectionBrowser class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
502 | 26 |
COPYRIGHT (c) 1997 by eXept Software AG |
404 | 27 |
All Rights Reserved |
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
745 | 42 |
The FileSelectionBrowser allows you to browse in file directories |
43 |
and to select files in order to load file contents or to save |
|
44 |
something to files. |
|
45 |
||
46 |
[start with:] |
|
47 |
FileSelectionBrowser open |
|
502 | 48 |
|
49 |
[author:] |
|
745 | 50 |
Thomas Zwick, eXept Software AG |
404 | 51 |
" |
52 |
! ! |
|
53 |
||
54 |
!FileSelectionBrowser class methodsFor:'instance creation'! |
|
55 |
||
56 |
request: aTitle fileName: aFileName inDirectory: dir withFileFilters: fileFilters |
|
957 | 57 |
^self new |
58 |
title: aTitle; |
|
59 |
fileName: aFileName; |
|
60 |
directory: dir; |
|
61 |
listOfFileFilters: fileFilters; |
|
62 |
open |
|
63 |
||
745 | 64 |
" |
65 |
self |
|
404 | 66 |
request: 'Select Your Profile File' |
67 |
fileName: '.profile' |
|
68 |
inDirectory: Filename homeDirectory |
|
745 | 69 |
withFileFilters: #('.*') |
70 |
" |
|
404 | 71 |
|
957 | 72 |
"Modified: / 17.8.1998 / 10:15:50 / cg" |
73 |
! |
|
74 |
||
75 |
request: aTitle fileName: aFileName withFileFilters: fileFilters |
|
404 | 76 |
^self new |
77 |
title: aTitle; |
|
78 |
fileName: aFileName; |
|
79 |
listOfFileFilters: fileFilters; |
|
80 |
open |
|
81 |
||
745 | 82 |
" |
83 |
self |
|
84 |
request: 'Select Your Profile File' |
|
85 |
fileName: '/etc/fstab' |
|
86 |
withFileFilters: #('*') |
|
87 |
" |
|
462 | 88 |
|
957 | 89 |
"Modified: / 17.8.1998 / 10:15:50 / cg" |
745 | 90 |
! |
91 |
||
92 |
request: aTitle pathName: aPath withFileFilters: fileFilters |
|
957 | 93 |
^self new |
94 |
title: aTitle; |
|
95 |
directory: aPath; |
|
96 |
listOfFileFilters: fileFilters; |
|
97 |
open |
|
98 |
||
745 | 99 |
" |
871 | 100 |
self |
101 |
request: 'Select A File' |
|
102 |
pathName: '/etc' |
|
103 |
withFileFilters: #('*.conf') |
|
745 | 104 |
" |
105 |
||
957 | 106 |
"Modified: / 17.8.1998 / 10:15:50 / cg" |
745 | 107 |
! |
108 |
||
109 |
request: aTitle withFileFilters: fileFilters |
|
957 | 110 |
^self new |
111 |
title: aTitle; |
|
112 |
listOfFileFilters: fileFilters; |
|
113 |
open |
|
745 | 114 |
" |
115 |
self request: 'Select A File' fileFilters: #('.*') |
|
116 |
" |
|
117 |
||
957 | 118 |
"Modified: / 17.8.1998 / 10:15:49 / cg" |
462 | 119 |
! |
120 |
||
404 | 121 |
requestFileName |
957 | 122 |
^self new title: 'Select A File'; open |
745 | 123 |
" |
124 |
self requestFileName |
|
125 |
" |
|
404 | 126 |
|
957 | 127 |
"Modified: / 17.8.1998 / 10:15:48 / cg" |
404 | 128 |
! ! |
129 |
||
130 |
!FileSelectionBrowser class methodsFor:'accessing'! |
|
131 |
||
132 |
loadImageFileNameFilters |
|
992 | 133 |
^ OrderedCollection |
134 |
withAll: #( |
|
135 |
'*.xpm ; *.xbm ; *.gif ; *.tif ; *.tiff ; *.bmp ; *.jpeg ; *.jpg' |
|
136 |
'*' |
|
137 |
) |
|
404 | 138 |
|
992 | 139 |
"Modified: / 12.9.1998 / 17:23:42 / cg" |
404 | 140 |
! |
141 |
||
142 |
projectFileNameFilters |
|
992 | 143 |
^Array withAll: #( |
144 |
'*.st ; *.*o ; *.s ; *.c ; Make* ; *.project' |
|
145 |
'*' |
|
146 |
) |
|
404 | 147 |
|
992 | 148 |
"Modified: / 12.9.1998 / 17:23:22 / cg" |
404 | 149 |
! |
150 |
||
151 |
saveImageFileNameFilters |
|
992 | 152 |
^ OrderedCollection |
153 |
withAll: #( |
|
154 |
'*.xpm ; *.xbm ; *.gif ; *.tif ; *.tiff ; *.bmp' |
|
155 |
'*' |
|
156 |
) |
|
404 | 157 |
|
992 | 158 |
"Modified: / 12.9.1998 / 17:23:54 / cg" |
404 | 159 |
! ! |
160 |
||
161 |
!FileSelectionBrowser class methodsFor:'interface specs'! |
|
162 |
||
163 |
windowSpec |
|
745 | 164 |
"This resource specification was automatically generated |
165 |
by the UIPainter of ST/X." |
|
404 | 166 |
|
745 | 167 |
"Do not manually edit this!! If it is corrupted, |
168 |
the UIPainter may not be able to read the specification." |
|
404 | 169 |
|
170 |
" |
|
171 |
UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec |
|
172 |
FileSelectionBrowser new openInterface:#windowSpec |
|
745 | 173 |
FileSelectionBrowser open |
404 | 174 |
" |
175 |
||
176 |
<resource: #canvas> |
|
177 |
||
178 |
^ |
|
179 |
||
180 |
#(#FullSpec |
|
745 | 181 |
#window: |
404 | 182 |
#(#WindowSpec |
745 | 183 |
#name: 'File Selection Browser' |
184 |
#layout: #(#LayoutFrame 379 0 259 0 978 0 608 0) |
|
185 |
#label: 'File Selection Browser' |
|
186 |
#min: #(#Point 10 10) |
|
187 |
#max: #(#Point 1152 900) |
|
188 |
#bounds: #(#Rectangle 379 259 979 609) |
|
189 |
#usePreferredExtent: false |
|
404 | 190 |
) |
745 | 191 |
#component: |
404 | 192 |
#(#SpecCollection |
745 | 193 |
#collection: |
404 | 194 |
#( |
195 |
#(#VariableHorizontalPanelSpec |
|
745 | 196 |
#name: 'panel' |
197 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0) |
|
198 |
#component: |
|
404 | 199 |
#(#SpecCollection |
745 | 200 |
#collection: |
404 | 201 |
#( |
202 |
#(#ViewSpec |
|
745 | 203 |
#name: 'view1' |
204 |
#component: |
|
404 | 205 |
#(#SpecCollection |
745 | 206 |
#collection: |
404 | 207 |
#( |
208 |
#(#FileSelectionTreeSpec |
|
745 | 209 |
#name: 'directoryTreeView' |
210 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0) |
|
211 |
#model: #selectionOfDirectory |
|
212 |
#hasHorizontalScrollBar: true |
|
213 |
#hasVerticalScrollBar: true |
|
214 |
#miniScrollerHorizontal: true |
|
215 |
#showDirectoryIndicatorForRoot: false |
|
216 |
#showDirectoryIndicator: true |
|
217 |
#valueChangeSelector: #readDirectory |
|
218 |
#hierarchicalList: #rootOfDirectory |
|
219 |
#itemClass: 'Directory' |
|
404 | 220 |
) |
592 | 221 |
#(#InputFieldSpec |
745 | 222 |
#name: 'directoryInputField' |
223 |
#layout: #(#LayoutFrame 2 0.0 -22 1 0 1.0 0 1) |
|
224 |
#model: #selectionOfDirectory |
|
225 |
#immediateAccept: false |
|
592 | 226 |
) |
404 | 227 |
) |
228 |
) |
|
229 |
) |
|
230 |
#(#ViewSpec |
|
745 | 231 |
#name: 'view2' |
232 |
#component: |
|
404 | 233 |
#(#SpecCollection |
745 | 234 |
#collection: |
404 | 235 |
#( |
236 |
#(#InputFieldSpec |
|
745 | 237 |
#name: 'EditField' |
238 |
#layout: #(#LayoutFrame 1 0.0 -22 1 -2 1.0 0 1) |
|
239 |
#model: #valueOfFileName |
|
240 |
#acceptOnReturn: false |
|
241 |
#acceptOnTab: false |
|
404 | 242 |
) |
243 |
#(#SubCanvasSpec |
|
745 | 244 |
#name: 'subCanvas1' |
245 |
#layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -25 1.0) |
|
246 |
#clientHolder: #directoryView |
|
404 | 247 |
) |
248 |
) |
|
249 |
) |
|
250 |
) |
|
251 |
) |
|
252 |
) |
|
745 | 253 |
#handles: #(#Any 0.5 1.0) |
404 | 254 |
) |
426
b8110a424326
commit buttons replaced by subSpec in ToolApplicationModel
tz
parents:
404
diff
changeset
|
255 |
#(#UISubSpecification |
745 | 256 |
#name: 'SubSpecification' |
257 |
#layout: #(#LayoutFrame 2 0.0 -32 1 0 1.0 -8 1.0) |
|
258 |
#majorKey: #ToolApplicationModel |
|
259 |
#minorKey: #windowSpecForCommitWithoutChannels |
|
404 | 260 |
) |
261 |
) |
|
262 |
) |
|
263 |
) |
|
264 |
! ! |
|
265 |
||
266 |
!FileSelectionBrowser methodsFor:'accessing'! |
|
267 |
||
268 |
directory: aDirectory |
|
269 |
||
957 | 270 |
directory := (aDirectory ? Filename currentDirectory) asFilename asAbsoluteFilename pathName |
745 | 271 |
|
957 | 272 |
"Modified: / 17.8.1998 / 10:15:53 / cg" |
404 | 273 |
! |
274 |
||
275 |
directoryView |
|
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
276 |
"return the directory view on the right side (a subcanvas)" |
404 | 277 |
|
278 |
^directoryView ? (directoryView := DirectoryView new) |
|
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
279 |
|
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
280 |
"Modified: / 23.9.1998 / 16:46:50 / cg" |
404 | 281 |
! |
282 |
||
283 |
fileName: aFileName |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
284 |
|prevDir| |
404 | 285 |
|
286 |
self valueOfFileName value: (aFileName ? '') asFilename baseName. |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
287 |
prevDir := directory. |
957 | 288 |
directory := directory ? ((aFileName ? '') asFilename asAbsoluteFilename directoryName). |
289 |
||
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
290 |
"/ on systems with volumes, we might have to update |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
291 |
"/ the root here. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
292 |
(prevDir isNil |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
293 |
or:[directory asFilename volume ~= prevDir asFilename volume]) ifTrue:[ |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
294 |
self setRootForFile:directory asFilename. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
295 |
]. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
296 |
|
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
297 |
"Modified: / 24.9.1998 / 23:41:08 / cg" |
404 | 298 |
! |
299 |
||
300 |
listOfFileFilters: anArray |
|
301 |
||
302 |
listOfFileFilters := anArray |
|
303 |
! ! |
|
304 |
||
305 |
!FileSelectionBrowser methodsFor:'accessing - views'! |
|
306 |
||
592 | 307 |
directoryInputField |
308 |
||
309 |
^builder componentAt: #directoryInputField |
|
310 |
||
311 |
! |
|
312 |
||
404 | 313 |
directoryTreeView |
314 |
||
315 |
^builder componentAt: #directoryTreeView |
|
316 |
||
317 |
! ! |
|
318 |
||
319 |
!FileSelectionBrowser methodsFor:'aspects'! |
|
320 |
||
321 |
rootOfDirectory |
|
322 |
||
323 |
|holder| |
|
324 |
(holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[ |
|
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
325 |
builder |
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
326 |
aspectAt:#rootOfDirectory |
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
327 |
put: (holder := Filename rootDirectory name asValue). |
404 | 328 |
]. |
329 |
^ holder |
|
330 |
||
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
331 |
"Modified: / 23.9.1998 / 16:34:59 / cg" |
404 | 332 |
! |
333 |
||
334 |
selectionOfDirectory |
|
335 |
||
336 |
|holder| |
|
337 |
(holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[ |
|
338 |
builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new) |
|
339 |
]. |
|
340 |
^ holder |
|
341 |
||
342 |
! |
|
343 |
||
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
344 |
setRootForFile:aFilename |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
345 |
|f root d parent| |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
346 |
|
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
347 |
f := aFilename asFilename. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
348 |
root := Filename rootDirectoryOnVolume:f volume. |
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
349 |
self directory:aFilename. |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
350 |
|
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
351 |
"/ on some systems, the root itself is not readable, |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
352 |
"/ but subdirs are (WIN32-network drives and VMS) |
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
353 |
"/ to avoid trouble in the treeView, search for the |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
354 |
"/ last readable directory and fake that as the trees root. |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
355 |
|
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
356 |
(root exists and:[root isDirectory and:[root isReadable]]) |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
357 |
ifFalse:[ |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
358 |
"/ search backward from aFilename for the last readable dir. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
359 |
root := f. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
360 |
parent := root directory. |
1005
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
361 |
[parent ~= root |
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
362 |
and:[parent exists |
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
363 |
and:[parent isDirectory |
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
364 |
and:[parent isReadable]]]] |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
365 |
whileTrue:[ |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
366 |
root := parent. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
367 |
parent := root directory. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
368 |
]. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
369 |
]. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
370 |
|
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
371 |
self rootOfDirectory |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
372 |
value:root pathName |
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
373 |
|
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
374 |
"Created: / 23.9.1998 / 16:36:28 / cg" |
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
375 |
"Modified: / 24.9.1998 / 22:26:01 / cg" |
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
376 |
! |
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
377 |
|
404 | 378 |
valueOfFileName |
379 |
||
380 |
|holder| |
|
381 |
(holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[ |
|
382 |
builder aspectAt:#valueOfFileName put:(holder := ValueHolder new). |
|
383 |
]. |
|
384 |
^ holder |
|
385 |
! ! |
|
386 |
||
387 |
!FileSelectionBrowser methodsFor:'callbacks'! |
|
388 |
||
389 |
fileDoubleClicked: aFileName |
|
390 |
||
391 |
self valueOfFileName value: aFileName. |
|
392 |
accept value: true. |
|
393 |
self close |
|
394 |
! |
|
395 |
||
396 |
readDirectory |
|
397 |
||
592 | 398 |
self directoryTreeView selection notNil |
399 |
ifTrue: |
|
400 |
[ |
|
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
401 |
directoryView directory: self selectionOfDirectory value. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
402 |
directoryView readDirectory. |
745 | 403 |
self class lastSelection notNil ifTrue: [self class lastSelection: self selectionOfDirectory value] |
592 | 404 |
] |
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
405 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
406 |
"Modified: / 24.9.1998 / 21:58:50 / cg" |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
407 |
! ! |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
408 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
409 |
!FileSelectionBrowser methodsFor:'misc'! |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
410 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
411 |
entryCompletion |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
412 |
|completedDirectory f dir treeView inputField| |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
413 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
414 |
treeView := self directoryTreeView. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
415 |
inputField := self directoryInputField. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
416 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
417 |
f := inputField contents. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
418 |
dir := f asFilename directoryName. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
419 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
420 |
(completedDirectory := Filename |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
421 |
filenameCompletionFor:f |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
422 |
directory:dir |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
423 |
directoriesOnly:true |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
424 |
filesOnly:false |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
425 |
ifMultiple: |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
426 |
[:dir | |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
427 |
treeView selection notNil ifTrue:[ |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
428 |
treeView selectedNodeExpand: true |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
429 |
] |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
430 |
]) asFilename exists |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
431 |
ifTrue: |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
432 |
[ |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
433 |
"/ volume changed ... (win32 or VMS) |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
434 |
completedDirectory asFilename volume ~= directory asFilename volume ifTrue:[ |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
435 |
self setRootForFile:completedDirectory asFilename. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
436 |
]. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
437 |
treeView selectPathname: completedDirectory. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
438 |
inputField contents: completedDirectory. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
439 |
"/ self directoryTreeView selectPathname: completedDirectory. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
440 |
self readDirectory |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
441 |
] ifFalse: [ |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
442 |
inputField flash |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
443 |
] |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
444 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
445 |
"Created: / 24.9.1998 / 21:33:37 / cg" |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
446 |
"Modified: / 24.9.1998 / 22:20:23 / cg" |
404 | 447 |
! ! |
448 |
||
449 |
!FileSelectionBrowser methodsFor:'startup / release'! |
|
450 |
||
451 |
closeCancel |
|
452 |
||
453 |
directoryView release. |
|
454 |
super closeCancel |
|
455 |
! |
|
456 |
||
457 |
closeRequest |
|
458 |
||
459 |
directoryView release. |
|
460 |
super closeRequest |
|
461 |
||
462 |
! |
|
463 |
||
464 |
open |
|
465 |
||
466 |
super open. |
|
515 | 467 |
accept value ifTrue:[ |
468 |
^ (self selectionOfDirectory value ? '') asFilename |
|
469 |
constructString:(self valueOfFileName value ? '') |
|
404 | 470 |
]. |
515 | 471 |
^ nil |
957 | 472 |
|
473 |
"Modified: / 17.8.1998 / 10:15:55 / cg" |
|
404 | 474 |
! |
475 |
||
476 |
postBuildWith:aBuilder |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
477 |
|nm file| |
404 | 478 |
|
479 |
directoryView listOfFileFilters: listOfFileFilters ? #('*'). |
|
462 | 480 |
directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName asFilename baseName]. |
481 |
directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName asFilename baseName]. |
|
404 | 482 |
directoryView fileFilterSelectAction: [:fileFilter| |
992 | 483 |
"/ CG: obscure code - isn't the code below the same as ? |
484 |
"/ self valueOfFileName value:((self valueOfFileName value ? 'unknown') |
|
485 |
"/ asFilename |
|
486 |
"/ withSuffix:(fileFilter asFilename suffix)) |
|
487 |
self valueOfFileName value: ( |
|
488 |
((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.', |
|
489 |
(fileFilter copy reverse readStream upTo: $.) reverse) |
|
490 |
]. |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
491 |
nm := directory. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
492 |
nm isNil ifTrue:[ |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
493 |
nm := self class lastSelection. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
494 |
nm isNil ifTrue:[ |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
495 |
nm := Filename currentDirectory asAbsoluteFilename name. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
496 |
]. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
497 |
]. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
498 |
|
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
499 |
self directoryTreeView selectPathname:nm. |
592 | 500 |
|
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
501 |
self directoryInputField |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
502 |
entryCompletionBlock:[:f| self entryCompletion]. |
404 | 503 |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
504 |
file := self valueOfFileName value. |
626 | 505 |
directoryView selectionOfFile value: |
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
506 |
(directoryView listOfFiles |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
507 |
detect: [:row | row baseName = file] |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
508 |
ifNone: nil). |
626 | 509 |
|
404 | 510 |
^super postBuildWith:aBuilder |
969 | 511 |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
512 |
"Modified: / 24.9.1998 / 23:41:29 / cg" |
404 | 513 |
! ! |
514 |
||
515 |
!FileSelectionBrowser class methodsFor:'documentation'! |
|
516 |
||
517 |
version |
|
518 |
^ '$Header$' |
|
519 |
! ! |