author | Claus Gittinger <cg@exept.de> |
Thu, 17 Feb 2000 16:00:12 +0100 | |
changeset 1359 | ea946edbf5fb |
parent 1353 | 701e41f8ff9f |
child 1379 | 1a2e94a447e1 |
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 |
|
1353 | 57 |
"ask for a file in some directory, |
58 |
using a fileFilter (list of mathcPatterns). |
|
59 |
Initial selection is aFileName. |
|
60 |
return the pathName or nil if canceled." |
|
61 |
||
957 | 62 |
^self new |
63 |
title: aTitle; |
|
64 |
fileName: aFileName; |
|
65 |
directory: dir; |
|
66 |
listOfFileFilters: fileFilters; |
|
67 |
open |
|
68 |
||
745 | 69 |
" |
1353 | 70 |
self |
71 |
request: 'Select Your Profile File' |
|
72 |
fileName: '.profile' |
|
73 |
inDirectory: Filename homeDirectory |
|
74 |
withFileFilters: #('.*') |
|
745 | 75 |
" |
404 | 76 |
|
957 | 77 |
"Modified: / 17.8.1998 / 10:15:50 / cg" |
78 |
! |
|
79 |
||
1353 | 80 |
request:aTitle fileName:aFileName withFileFilters:fileFilters |
81 |
"ask for a file in some directory, |
|
82 |
using a fileFilter (list of mathcPatterns). |
|
83 |
Initial selection is aFileName. |
|
84 |
return the pathName or nil if canceled." |
|
85 |
||
86 |
^ self new |
|
404 | 87 |
title: aTitle; |
88 |
fileName: aFileName; |
|
89 |
listOfFileFilters: fileFilters; |
|
90 |
open |
|
91 |
||
745 | 92 |
" |
1353 | 93 |
self |
94 |
request: 'Select Your Profile File' |
|
95 |
fileName: '/etc/fstab' |
|
96 |
withFileFilters: #('*') |
|
97 |
" |
|
98 |
||
99 |
"Modified: / 17.8.1998 / 10:15:50 / cg" |
|
100 |
! |
|
101 |
||
102 |
request:aTitle inDirectory:aPath withFileFilters:fileFilters |
|
103 |
"ask for a file in some directory, |
|
104 |
using a fileFilter (list of mathcPatterns) |
|
105 |
return the pathName or nil if canceled." |
|
106 |
||
107 |
^ (self new) |
|
108 |
title:aTitle; |
|
109 |
directory:aPath; |
|
110 |
listOfFileFilters:fileFilters; |
|
111 |
open |
|
112 |
||
113 |
" |
|
114 |
self |
|
115 |
request: 'Select A File' |
|
116 |
inDirectory: '/etc' |
|
117 |
withFileFilters: #('*.conf') |
|
745 | 118 |
" |
462 | 119 |
|
957 | 120 |
"Modified: / 17.8.1998 / 10:15:50 / cg" |
745 | 121 |
! |
122 |
||
1353 | 123 |
request:aTitle pathName:aPath withFileFilters:fileFilters |
124 |
"ask for a file in some directory, |
|
125 |
using a fileFilter (list of mathcPatterns) |
|
126 |
return the pathName or nil if canceled. |
|
127 |
Obsolete - for backward compatibility." |
|
128 |
||
129 |
^ self |
|
130 |
request:aTitle inDirectory:aPath withFileFilters:fileFilters |
|
957 | 131 |
|
745 | 132 |
" |
1353 | 133 |
self |
134 |
request: 'Select A File' |
|
135 |
pathName: '/etc' |
|
136 |
withFileFilters: #('*.conf') |
|
745 | 137 |
" |
138 |
||
957 | 139 |
"Modified: / 17.8.1998 / 10:15:50 / cg" |
745 | 140 |
! |
141 |
||
1353 | 142 |
request:aTitle withFileFilters:fileFilters |
143 |
"ask for a file in the current directory, |
|
144 |
using a fileFilter (list of mathcPatterns) |
|
145 |
return the pathName or nil if canceled" |
|
146 |
||
147 |
^ (self new) |
|
148 |
title:aTitle; |
|
149 |
listOfFileFilters:fileFilters; |
|
957 | 150 |
open |
1353 | 151 |
|
745 | 152 |
" |
1353 | 153 |
self request:'Select A File' withFileFilters:#('.*') |
154 |
self request:'Select A File' withFileFilters:#('*.mak;*.st') |
|
745 | 155 |
" |
156 |
||
957 | 157 |
"Modified: / 17.8.1998 / 10:15:49 / cg" |
462 | 158 |
! |
159 |
||
404 | 160 |
requestFileName |
1353 | 161 |
"ask for a file in the current directory; |
162 |
return the pathName or nil if canceled" |
|
163 |
||
164 |
^ self new |
|
165 |
title:'Select A File'; |
|
166 |
open |
|
167 |
||
168 |
" |
|
169 |
self requestFileName |
|
745 | 170 |
" |
1353 | 171 |
|
172 |
"Modified: / 17.8.1998 / 10:15:48 / cg" |
|
173 |
! |
|
174 |
||
175 |
requestFileNameInDirectory:aPath |
|
176 |
"ask for a file in a directory; |
|
177 |
return the pathName or nil if canceled" |
|
178 |
||
179 |
^ self new |
|
180 |
title:'Select A File'; |
|
181 |
directory:aPath; |
|
182 |
open |
|
183 |
||
184 |
" |
|
185 |
self requestFileNameInDirectory:'/etc' |
|
745 | 186 |
" |
404 | 187 |
|
957 | 188 |
"Modified: / 17.8.1998 / 10:15:48 / cg" |
404 | 189 |
! ! |
190 |
||
191 |
!FileSelectionBrowser class methodsFor:'accessing'! |
|
192 |
||
193 |
loadImageFileNameFilters |
|
992 | 194 |
^ OrderedCollection |
195 |
withAll: #( |
|
196 |
'*.xpm ; *.xbm ; *.gif ; *.tif ; *.tiff ; *.bmp ; *.jpeg ; *.jpg' |
|
197 |
'*' |
|
198 |
) |
|
404 | 199 |
|
992 | 200 |
"Modified: / 12.9.1998 / 17:23:42 / cg" |
404 | 201 |
! |
202 |
||
203 |
projectFileNameFilters |
|
992 | 204 |
^Array withAll: #( |
205 |
'*.st ; *.*o ; *.s ; *.c ; Make* ; *.project' |
|
206 |
'*' |
|
207 |
) |
|
404 | 208 |
|
992 | 209 |
"Modified: / 12.9.1998 / 17:23:22 / cg" |
404 | 210 |
! |
211 |
||
212 |
saveImageFileNameFilters |
|
992 | 213 |
^ OrderedCollection |
214 |
withAll: #( |
|
215 |
'*.xpm ; *.xbm ; *.gif ; *.tif ; *.tiff ; *.bmp' |
|
216 |
'*' |
|
217 |
) |
|
404 | 218 |
|
992 | 219 |
"Modified: / 12.9.1998 / 17:23:54 / cg" |
404 | 220 |
! ! |
221 |
||
222 |
!FileSelectionBrowser class methodsFor:'interface specs'! |
|
223 |
||
224 |
windowSpec |
|
745 | 225 |
"This resource specification was automatically generated |
226 |
by the UIPainter of ST/X." |
|
404 | 227 |
|
745 | 228 |
"Do not manually edit this!! If it is corrupted, |
229 |
the UIPainter may not be able to read the specification." |
|
404 | 230 |
|
231 |
" |
|
232 |
UIPainter new openOnClass:FileSelectionBrowser andSelector:#windowSpec |
|
233 |
FileSelectionBrowser new openInterface:#windowSpec |
|
745 | 234 |
FileSelectionBrowser open |
404 | 235 |
" |
236 |
||
237 |
<resource: #canvas> |
|
238 |
||
1260 | 239 |
^ |
240 |
#(#FullSpec |
|
241 |
#name: #windowSpec |
|
242 |
#window: |
|
243 |
#(#WindowSpec |
|
244 |
#label: 'File Selection Browser' |
|
245 |
#name: 'File Selection Browser' |
|
246 |
#min: #(#Point 10 10) |
|
247 |
#max: #(#Point 1152 900) |
|
248 |
#bounds: #(#Rectangle 18 51 618 401) |
|
249 |
) |
|
250 |
#component: |
|
251 |
#(#SpecCollection |
|
252 |
#collection: #( |
|
253 |
#(#VariableHorizontalPanelSpec |
|
254 |
#name: 'panel' |
|
255 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0) |
|
256 |
#component: |
|
257 |
#(#SpecCollection |
|
258 |
#collection: #( |
|
259 |
#(#ViewSpec |
|
260 |
#name: 'view1' |
|
745 | 261 |
#component: |
1260 | 262 |
#(#SpecCollection |
263 |
#collection: #( |
|
264 |
#(#FileSelectionTreeSpec |
|
265 |
#name: 'directoryTreeView' |
|
266 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0) |
|
267 |
#model: #selectionOfDirectory |
|
268 |
#hasHorizontalScrollBar: true |
|
269 |
#hasVerticalScrollBar: true |
|
270 |
#miniScrollerHorizontal: true |
|
271 |
#showDirectoryIndicatorForRoot: false |
|
272 |
#showDirectoryIndicator: true |
|
273 |
#valueChangeSelector: #readDirectory |
|
274 |
#hierarchicalList: #rootOfDirectory |
|
275 |
#highlightMode: #line |
|
276 |
#itemClass: 'Directory' |
|
277 |
) |
|
278 |
#(#InputFieldSpec |
|
279 |
#name: 'directoryInputField' |
|
280 |
#layout: #(#LayoutFrame 2 0.0 -22 1 0 1.0 0 1) |
|
281 |
#model: #selectionOfDirectory |
|
282 |
#immediateAccept: false |
|
283 |
#acceptOnPointerLeave: false |
|
404 | 284 |
) |
1260 | 285 |
) |
286 |
||
404 | 287 |
) |
1260 | 288 |
) |
289 |
#(#ViewSpec |
|
290 |
#name: 'view2' |
|
291 |
#component: |
|
292 |
#(#SpecCollection |
|
293 |
#collection: #( |
|
294 |
#(#InputFieldSpec |
|
295 |
#name: 'EditField' |
|
296 |
#layout: #(#LayoutFrame 1 0.0 -22 1 -2 1.0 0 1) |
|
297 |
#model: #valueOfFileName |
|
298 |
#acceptOnReturn: false |
|
299 |
#acceptOnTab: false |
|
300 |
#acceptOnPointerLeave: false |
|
301 |
) |
|
302 |
#(#SubCanvasSpec |
|
303 |
#name: 'subCanvas1' |
|
304 |
#layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -25 1.0) |
|
305 |
#clientHolder: #directoryView |
|
306 |
) |
|
307 |
) |
|
308 |
||
309 |
) |
|
310 |
) |
|
311 |
) |
|
312 |
||
404 | 313 |
) |
1260 | 314 |
#handles: #(#Any 0.5 1.0) |
315 |
) |
|
316 |
#(#UISubSpecification |
|
317 |
#name: 'SubSpecification' |
|
318 |
#layout: #(#LayoutFrame 2 0.0 -32 1 0 1.0 0 1.0) |
|
319 |
#majorKey: #ToolApplicationModel |
|
320 |
#minorKey: #windowSpecForCommitWithoutChannels |
|
321 |
) |
|
322 |
) |
|
323 |
||
324 |
) |
|
404 | 325 |
) |
326 |
! ! |
|
327 |
||
328 |
!FileSelectionBrowser methodsFor:'accessing'! |
|
329 |
||
330 |
directory: aDirectory |
|
331 |
||
957 | 332 |
directory := (aDirectory ? Filename currentDirectory) asFilename asAbsoluteFilename pathName |
745 | 333 |
|
957 | 334 |
"Modified: / 17.8.1998 / 10:15:53 / cg" |
404 | 335 |
! |
336 |
||
337 |
directoryView |
|
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
338 |
"return the directory view on the right side (a subcanvas)" |
404 | 339 |
|
340 |
^directoryView ? (directoryView := DirectoryView new) |
|
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
341 |
|
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
342 |
"Modified: / 23.9.1998 / 16:46:50 / cg" |
404 | 343 |
! |
344 |
||
345 |
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
|
346 |
|prevDir| |
404 | 347 |
|
348 |
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
|
349 |
prevDir := directory. |
957 | 350 |
directory := directory ? ((aFileName ? '') asFilename asAbsoluteFilename directoryName). |
351 |
||
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
352 |
"/ 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
|
353 |
"/ 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
|
354 |
(prevDir isNil |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
355 |
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
|
356 |
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
|
357 |
]. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
358 |
|
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
359 |
"Modified: / 24.9.1998 / 23:41:08 / cg" |
404 | 360 |
! |
361 |
||
362 |
listOfFileFilters: anArray |
|
363 |
||
364 |
listOfFileFilters := anArray |
|
365 |
! ! |
|
366 |
||
367 |
!FileSelectionBrowser methodsFor:'accessing - views'! |
|
368 |
||
592 | 369 |
directoryInputField |
370 |
||
371 |
^builder componentAt: #directoryInputField |
|
372 |
||
373 |
! |
|
374 |
||
404 | 375 |
directoryTreeView |
376 |
||
377 |
^builder componentAt: #directoryTreeView |
|
378 |
||
379 |
! ! |
|
380 |
||
381 |
!FileSelectionBrowser methodsFor:'aspects'! |
|
382 |
||
383 |
rootOfDirectory |
|
384 |
||
385 |
|holder| |
|
386 |
(holder := builder bindingAt:#rootOfDirectory) isNil ifTrue:[ |
|
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
387 |
builder |
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
388 |
aspectAt:#rootOfDirectory |
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
389 |
put: (holder := Filename rootDirectory name asValue). |
404 | 390 |
]. |
391 |
^ holder |
|
392 |
||
1011 | 393 |
"Modified: / 5.10.1998 / 12:46:10 / cg" |
404 | 394 |
! |
395 |
||
396 |
selectionOfDirectory |
|
397 |
||
398 |
|holder| |
|
399 |
(holder := builder bindingAt:#selectionOfDirectory) isNil ifTrue:[ |
|
400 |
builder aspectAt:#selectionOfDirectory put: (holder := ValueHolder new) |
|
401 |
]. |
|
402 |
^ holder |
|
403 |
||
404 |
! |
|
405 |
||
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
406 |
setRootForFile:aFilename |
1144 | 407 |
|f root parent| |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
408 |
|
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
409 |
f := aFilename asFilename. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
410 |
root := Filename rootDirectoryOnVolume:f volume. |
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
411 |
self directory:aFilename. |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
412 |
|
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
413 |
"/ on some systems, the root itself is not readable, |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
414 |
"/ 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
|
415 |
"/ 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
|
416 |
"/ 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
|
417 |
|
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
418 |
(root exists and:[root isDirectory and:[root isReadable]]) |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
419 |
ifFalse:[ |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
420 |
"/ search backward from aFilename for the last readable dir. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
421 |
root := f. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
422 |
parent := root directory. |
1005
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
423 |
[parent ~= root |
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
424 |
and:[parent exists |
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
425 |
and:[parent isDirectory |
0b2b698bc4f3
oops - avoid endless loop when alking dir-hierarchy up.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
426 |
and:[parent isReadable]]]] |
1000
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
427 |
whileTrue:[ |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
428 |
root := parent. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
429 |
parent := root directory. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
430 |
]. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
431 |
]. |
efafa57e0313
kludge for win32 in #setRootForFile:
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
432 |
|
1011 | 433 |
self rootOfDirectory value:root pathName |
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
434 |
|
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
435 |
"Created: / 23.9.1998 / 16:36:28 / cg" |
1011 | 436 |
"Modified: / 5.10.1998 / 12:46:06 / cg" |
998
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
437 |
! |
ad33f2625598
care for volume changes in directory field.
Claus Gittinger <cg@exept.de>
parents:
992
diff
changeset
|
438 |
|
404 | 439 |
valueOfFileName |
440 |
||
441 |
|holder| |
|
442 |
(holder := builder bindingAt:#valueOfFileName) isNil ifTrue:[ |
|
443 |
builder aspectAt:#valueOfFileName put:(holder := ValueHolder new). |
|
444 |
]. |
|
445 |
^ holder |
|
446 |
! ! |
|
447 |
||
448 |
!FileSelectionBrowser methodsFor:'callbacks'! |
|
449 |
||
450 |
fileDoubleClicked: aFileName |
|
451 |
||
452 |
self valueOfFileName value: aFileName. |
|
453 |
accept value: true. |
|
1035
25575d9c0fc5
replace send of #close with #closeRequest.
Claus Gittinger <cg@exept.de>
parents:
1011
diff
changeset
|
454 |
self closeRequest |
404 | 455 |
! |
456 |
||
457 |
readDirectory |
|
458 |
||
592 | 459 |
self directoryTreeView selection notNil |
460 |
ifTrue: |
|
461 |
[ |
|
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
462 |
directoryView directory: self selectionOfDirectory value. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
463 |
directoryView readDirectory. |
745 | 464 |
self class lastSelection notNil ifTrue: [self class lastSelection: self selectionOfDirectory value] |
592 | 465 |
] |
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
466 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
467 |
"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
|
468 |
! ! |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
469 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
470 |
!FileSelectionBrowser methodsFor:'misc'! |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
471 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
472 |
entryCompletion |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
473 |
|completedDirectory f dir treeView inputField| |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
474 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
475 |
treeView := self directoryTreeView. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
476 |
inputField := self directoryInputField. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
477 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
478 |
f := inputField contents. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
479 |
dir := f asFilename directoryName. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
480 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
481 |
(completedDirectory := Filename |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
482 |
filenameCompletionFor:f |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
483 |
directory:dir |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
484 |
directoriesOnly:true |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
485 |
filesOnly:false |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
486 |
ifMultiple: |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
487 |
[:dir | |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
488 |
treeView selection notNil ifTrue:[ |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
489 |
treeView selectedNodeExpand: true |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
490 |
] |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
491 |
]) asFilename exists |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
492 |
ifTrue: |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
493 |
[ |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
494 |
"/ volume changed ... (win32 or VMS) |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
495 |
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
|
496 |
self setRootForFile:completedDirectory asFilename. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
497 |
]. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
498 |
treeView selectPathname: completedDirectory. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
499 |
inputField contents: completedDirectory. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
500 |
"/ self directoryTreeView selectPathname: completedDirectory. |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
501 |
self readDirectory |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
502 |
] ifFalse: [ |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
503 |
inputField flash |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
504 |
] |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
505 |
|
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
506 |
"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
|
507 |
"Modified: / 24.9.1998 / 22:20:23 / cg" |
404 | 508 |
! ! |
509 |
||
510 |
!FileSelectionBrowser methodsFor:'startup / release'! |
|
511 |
||
512 |
closeCancel |
|
513 |
||
514 |
directoryView release. |
|
515 |
super closeCancel |
|
516 |
! |
|
517 |
||
518 |
closeRequest |
|
519 |
||
520 |
directoryView release. |
|
521 |
super closeRequest |
|
522 |
||
523 |
! |
|
524 |
||
525 |
open |
|
1353 | 526 |
super open. |
404 | 527 |
|
1353 | 528 |
"return the selected file or nil" |
515 | 529 |
accept value ifTrue:[ |
530 |
^ (self selectionOfDirectory value ? '') asFilename |
|
531 |
constructString:(self valueOfFileName value ? '') |
|
404 | 532 |
]. |
515 | 533 |
^ nil |
957 | 534 |
|
535 |
"Modified: / 17.8.1998 / 10:15:55 / cg" |
|
404 | 536 |
! |
537 |
||
538 |
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
|
539 |
|nm file| |
404 | 540 |
|
541 |
directoryView listOfFileFilters: listOfFileFilters ? #('*'). |
|
462 | 542 |
directoryView fileSelectAction: [:aFileName |self valueOfFileName value: aFileName asFilename baseName]. |
543 |
directoryView fileDoubleClickAction: [:aFileName |self fileDoubleClicked: aFileName asFilename baseName]. |
|
404 | 544 |
directoryView fileFilterSelectAction: [:fileFilter| |
992 | 545 |
"/ CG: obscure code - isn't the code below the same as ? |
546 |
"/ self valueOfFileName value:((self valueOfFileName value ? 'unknown') |
|
547 |
"/ asFilename |
|
548 |
"/ withSuffix:(fileFilter asFilename suffix)) |
|
549 |
self valueOfFileName value: ( |
|
550 |
((self valueOfFileName value ? 'unknown') readStream upTo: $.), '.', |
|
551 |
(fileFilter copy reverse readStream upTo: $.) reverse) |
|
552 |
]. |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
553 |
nm := directory. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
554 |
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
|
555 |
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
|
556 |
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
|
557 |
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
|
558 |
]. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
559 |
]. |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
560 |
|
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
561 |
self directoryTreeView selectPathname:nm. |
592 | 562 |
|
1001
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
563 |
self directoryInputField |
4474ba86a5d8
made expandFilename a separate method and fixed it.
Claus Gittinger <cg@exept.de>
parents:
1000
diff
changeset
|
564 |
entryCompletionBlock:[:f| self entryCompletion]. |
404 | 565 |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
566 |
file := self valueOfFileName value. |
626 | 567 |
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
|
568 |
(directoryView listOfFiles |
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
569 |
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
|
570 |
ifNone: nil). |
626 | 571 |
|
404 | 572 |
^super postBuildWith:aBuilder |
969 | 573 |
|
1003
7880fc48f0bb
care for root when file changes and volume is different (win & vms)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
574 |
"Modified: / 24.9.1998 / 23:41:29 / cg" |
404 | 575 |
! ! |
576 |
||
577 |
!FileSelectionBrowser class methodsFor:'documentation'! |
|
578 |
||
579 |
version |
|
580 |
^ '$Header$' |
|
581 |
! ! |