author | convert-repo |
Mon, 20 Jan 2020 04:27:28 +0000 | |
changeset 6803 | ee24f1bc43ae |
parent 6698 | 378e50623340 |
permissions | -rw-r--r-- |
6504 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1990 by Claus Gittinger |
59 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
14 |
"{ Package: 'stx:libwidg' }" |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
15 |
|
5590 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
ListSelectionBox subclass:#FileSelectionBox |
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
19 |
instanceVariableNames:'patternField selectingDirectory allowMakeDirectory' |
6698 | 20 |
classVariableNames:'LastFileSelectionDirectory LastSuffixPatternPerDefault' |
351 | 21 |
poolDictionaries:'' |
22 |
category:'Views-DialogBoxes' |
|
0 | 23 |
! |
24 |
||
849 | 25 |
!FileSelectionBox class methodsFor:'documentation'! |
7 | 26 |
|
38 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 30 |
All Rights Reserved |
38 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
7 | 41 |
documentation |
42 |
" |
|
38 | 43 |
this class implements file selection boxes. Instances show a list of |
44 |
files, and perform an action block with the selected pathname as |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
45 |
argument when ok is clicked. It is also possible, to open the box |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
46 |
without action and ask it afterward if it has been left with ok |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
47 |
(i.e. the ST-80 way, asking 'aBox accepted ifTrue:[...]') |
38 | 48 |
|
49 |
There is an optional PatternField, which shows itself when a pattern |
|
50 |
is defined (i.e. if there is no pattern, it is hidden). |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
51 |
If there is a pattern, only files matching the pattern are shown in |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
52 |
the list. Directories are not affected by the patternField. |
38 | 53 |
|
54 |
In addition, there is an optional matchBlock (actually this is defined |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
55 |
in the FileSelectionList). Only names for which this matchblock |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
56 |
returns true will be presented. The matchBlock affects both regular files |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
57 |
and names of directories. The argument passed to the matchBlock is the full |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
58 |
pathname. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
59 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
60 |
All of the actual work is done in the fileList; see the documentation |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
61 |
of FileSelectionList for more options |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
62 |
(you can access a boxes fileList via 'aBox>>listView' and get access to all |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
63 |
of those fancy settings) |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
64 |
For example, by accessing the list, it is possible to hide all directories |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
65 |
('aBox listView ignoreDirectories:true'), to hide the parentDirectory alone |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
66 |
('aBox listView ignoreParentDirectory') and to turn off the marking |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
67 |
of subdirectories ('aBox listView markSubdirectories:false'). |
585 | 68 |
|
69 |
[author:] |
|
70 |
Claus Gittinger |
|
71 |
||
72 |
[see also:] |
|
73 |
DialogBox |
|
648 | 74 |
EnterBox2 FilenameEnterBox YesNoBox |
593 | 75 |
ListSelectionBox FileSaveBox |
76 |
FileSelectionList SelectionInListView |
|
62 | 77 |
" |
78 |
! |
|
38 | 79 |
|
62 | 80 |
examples |
81 |
" |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
82 |
simple standard queries |
2441 | 83 |
(notice, that the receiver of those messages is Dialog - this should always |
84 |
be done for compatibility - although the real fileBox implementation is here). |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
85 |
|
238 | 86 |
very simple: |
593 | 87 |
[exBegin] |
351 | 88 |
|name| |
238 | 89 |
|
2441 | 90 |
name := Dialog requestFileName. |
655 | 91 |
Transcript showCR:name |
593 | 92 |
[exEnd] |
38 | 93 |
|
238 | 94 |
|
95 |
simple: |
|
593 | 96 |
[exBegin] |
351 | 97 |
|name| |
238 | 98 |
|
593 | 99 |
name := FileSelectionBox requestFileName:'which file ?'. |
655 | 100 |
Transcript showCR:name |
593 | 101 |
[exEnd] |
38 | 102 |
|
238 | 103 |
|
104 |
with initial selection: |
|
593 | 105 |
[exBegin] |
351 | 106 |
|name| |
238 | 107 |
|
593 | 108 |
name := FileSelectionBox requestFileName:'which file ?' default:'Make.proto'. |
655 | 109 |
Transcript showCR:name |
593 | 110 |
[exEnd] |
38 | 111 |
|
238 | 112 |
|
12 | 113 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
114 |
more detailed setup |
238 | 115 |
|
116 |
setting title: |
|
593 | 117 |
[exBegin] |
351 | 118 |
|box| |
119 |
box := FileSelectionBox new. |
|
120 |
box title:'Which file ?'. |
|
121 |
box open. |
|
122 |
box accepted ifTrue:[ |
|
1411 | 123 |
Transcript showCR:'you selected: ' , box pathName |
351 | 124 |
] |
593 | 125 |
[exEnd] |
38 | 126 |
|
238 | 127 |
setting a matchpattern: |
593 | 128 |
[exBegin] |
351 | 129 |
|box| |
130 |
box := FileSelectionBox new. |
|
131 |
box title:'Which file ?'. |
|
132 |
box pattern:'*.rc'. |
|
133 |
box open |
|
593 | 134 |
[exEnd] |
351 | 135 |
|
136 |
setting multiple patterns: |
|
593 | 137 |
[exBegin] |
351 | 138 |
|box| |
139 |
box := FileSelectionBox new. |
|
140 |
box title:'Which file ?'. |
|
141 |
box pattern:'*.rc;*.st'. |
|
142 |
box open |
|
593 | 143 |
[exEnd] |
38 | 144 |
|
238 | 145 |
setting a matchblock: |
593 | 146 |
[exBegin] |
351 | 147 |
|box| |
148 |
box := FileSelectionBox new. |
|
149 |
box title:'Which file ?'. |
|
150 |
box directory:'/etc'. |
|
151 |
box pattern:'*'. |
|
152 |
box matchBlock:[:name | name asFilename baseName first between:$a and:$z]. |
|
153 |
box open |
|
593 | 154 |
[exEnd] |
44 | 155 |
|
238 | 156 |
both pattern and matchBlock: |
593 | 157 |
[exBegin] |
351 | 158 |
|box| |
159 |
box := FileSelectionBox new. |
|
160 |
box title:'Which directory ?'. |
|
161 |
box selectingDirectory:true. |
|
162 |
box pattern:'l*'. |
|
163 |
box matchBlock:[:name | OperatingSystem isDirectory:name]. |
|
655 | 164 |
box action:[:fn | Transcript showCR:fn]. |
351 | 165 |
box open |
593 | 166 |
[exEnd] |
238 | 167 |
|
5590 | 168 |
don't show the parent directory: |
593 | 169 |
[exBegin] |
351 | 170 |
|box| |
171 |
box := FileSelectionBox new. |
|
172 |
box title:'Which directory ?'. |
|
173 |
box listView ignoreParentDirectory:true. |
|
174 |
box open |
|
593 | 175 |
[exEnd] |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
176 |
|
5590 | 177 |
don't show any directory: |
593 | 178 |
[exBegin] |
351 | 179 |
|box| |
180 |
box := FileSelectionBox new. |
|
181 |
box title:'Which file ?'. |
|
182 |
box listView ignoreDirectories:true. |
|
183 |
box open |
|
593 | 184 |
[exEnd] |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
185 |
|
5590 | 186 |
don't show any directory or hidden file: |
842
a27a1c6ddde0
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
800
diff
changeset
|
187 |
(notice the basename extraction - we are not interested in the full pathName) |
593 | 188 |
[exBegin] |
351 | 189 |
|box| |
190 |
box := FileSelectionBox new. |
|
191 |
box title:'Which file ?'. |
|
192 |
box listView ignoreDirectories:true. |
|
193 |
box matchBlock:[:name | (name asFilename baseName startsWith:'.') not]. |
|
194 |
box open |
|
593 | 195 |
[exEnd] |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
196 |
|
5590 | 197 |
don't allow direct filename entry: |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
198 |
(i.e. avoid the user choosing files from other directories) |
593 | 199 |
[exBegin] |
351 | 200 |
|box| |
201 |
box := FileSelectionBox new. |
|
202 |
box title:'Which one ?'. |
|
203 |
box enterField beInvisible. |
|
204 |
box open. |
|
205 |
box accepted ifTrue:[ |
|
655 | 206 |
Transcript showCR:'path is ' , box pathName |
351 | 207 |
]. |
593 | 208 |
[exEnd] |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
209 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
210 |
combined with above directory ignoring, |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
211 |
this limits selection of files from a single directory: |
593 | 212 |
[exBegin] |
351 | 213 |
|box| |
214 |
box := FileSelectionBox new. |
|
215 |
box title:'Which file ?'. |
|
216 |
box enterField beInvisible. |
|
217 |
box listView ignoreDirectories:true. |
|
218 |
box open. |
|
219 |
box accepted ifTrue:[ |
|
655 | 220 |
Transcript showCR:'path is ' , box pathName |
351 | 221 |
]. |
593 | 222 |
[exEnd] |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
223 |
|
238 | 224 |
finally, an action: |
593 | 225 |
[exBegin] |
351 | 226 |
|box| |
227 |
box := FileSelectionBox new. |
|
228 |
box title:'Which directory ?'. |
|
229 |
box pattern:'l*'. |
|
230 |
box matchBlock:[:name | OperatingSystem isDirectory:name]. |
|
655 | 231 |
box action:[:name | Transcript showCR:name]. |
351 | 232 |
box open |
593 | 233 |
[exEnd] |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
234 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
235 |
concrete examples: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
236 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
237 |
only show files beginning with lowercase characters |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
238 |
and ending in '.c': |
593 | 239 |
[exBegin] |
351 | 240 |
|box| |
241 |
box := FileSelectionBox new. |
|
242 |
box title:'Which directory ?'. |
|
243 |
box matchBlock:[:name | |
|
244 |
box pathName asFilename isDirectory |
|
245 |
or:[name first isLowercase |
|
246 |
and:[name endsWith:'.c']] |
|
247 |
]. |
|
248 |
box open. |
|
249 |
box accepted ifTrue:[ |
|
655 | 250 |
Transcript showCR:'full path: ' , box pathName. |
251 |
Transcript showCR:'files name: ' , box fileName. |
|
1643
2710f3be2a77
fixed #fileName - return fileName only (not full path)
Claus Gittinger <cg@exept.de>
parents:
1639
diff
changeset
|
252 |
Transcript showCR:'directory : ' , box directory pathName. |
351 | 253 |
] |
593 | 254 |
[exEnd] |
7 | 255 |
" |
256 |
! ! |
|
0 | 257 |
|
1320 | 258 |
!FileSelectionBox class methodsFor:'accessing'! |
259 |
||
260 |
lastFileSelectionDirectory |
|
1571
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
261 |
"return the name of the directory used in the previous |
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
262 |
fileSelection dialog. This will be used as default for the next dialog, |
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
263 |
if no explicit path is specified (see requestFileName:* methods)" |
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
264 |
|
1574 | 265 |
|f| |
266 |
||
1571
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
267 |
LastFileSelectionDirectory notNil ifTrue:[ |
1574 | 268 |
((f := LastFileSelectionDirectory asFilename) exists |
269 |
and:[f isDirectory]) ifFalse:[ |
|
270 |
LastFileSelectionDirectory := nil. |
|
271 |
] |
|
1571
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
272 |
]. |
1320 | 273 |
^ LastFileSelectionDirectory |
274 |
||
1571
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
275 |
"Created: / 9.9.1997 / 10:03:17 / cg" |
1574 | 276 |
"Modified: / 16.6.1998 / 15:11:20 / cg" |
1320 | 277 |
! |
278 |
||
279 |
lastFileSelectionDirectory:aDirectoryString |
|
1571
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
280 |
"set the name of the directory used in the previous |
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
281 |
fileSelection dialog. This will be used as default for the next dialog, |
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
282 |
if no explicit path is specified (see requestFileName:* methods)" |
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
283 |
|
1320 | 284 |
LastFileSelectionDirectory := aDirectoryString |
285 |
||
1571
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
286 |
"Created: / 9.9.1997 / 10:03:42 / cg" |
fdaa3b9aa746
flush lastFileSelectionDirectory, if it does not exists
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
287 |
"Modified: / 15.6.1998 / 14:05:21 / cg" |
6698 | 288 |
! |
289 |
||
290 |
lastSuffixPatternUsedForDefault:default |
|
291 |
"return the suffix pattern used in the previous fileSelection dialog, |
|
292 |
IFF it was changed from default by the user. |
|
293 |
This will be used as default for the next dialog, if the same default is coming" |
|
294 |
||
295 |
LastSuffixPatternPerDefault isNil ifTrue:[^ default]. |
|
296 |
^ LastSuffixPatternPerDefault at:default ifAbsent:default |
|
297 |
! |
|
298 |
||
299 |
lastSuffixPatternUsedForDefault:default is:newPattern |
|
300 |
"return the suffix pattern used in the previous fileSelection dialog, |
|
301 |
IFF it was changed from default by the user. |
|
302 |
This will be used as default for the next dialog, if the same default is coming" |
|
303 |
||
304 |
LastSuffixPatternPerDefault isNil ifTrue:[ |
|
305 |
LastSuffixPatternPerDefault := Dictionary new. |
|
306 |
]. |
|
307 |
LastSuffixPatternPerDefault at:default put:newPattern |
|
1320 | 308 |
! ! |
309 |
||
849 | 310 |
!FileSelectionBox class methodsFor:'defaults'! |
12 | 311 |
|
312 |
listViewType |
|
313 |
"return the type of listView - using a FileSelectionList here" |
|
314 |
||
315 |
^ FileSelectionList |
|
316 |
! ! |
|
317 |
||
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
318 |
!FileSelectionBox class methodsFor:'menu specs'! |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
319 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
320 |
fileListMenu |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
321 |
"This resource specification was automatically generated |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
322 |
by the MenuEditor of ST/X." |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
323 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
324 |
"Do not manually edit this!! If it is corrupted, |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
325 |
the MenuEditor may not be able to read the specification." |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
326 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
327 |
" |
2354 | 328 |
MenuEditor new openOnClass:FileSelectionBox andSelector:#fileListMenu |
329 |
(Menu new fromLiteralArrayEncoding:(FileSelectionBox fileListMenu)) startUp |
|
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
330 |
" |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
331 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
332 |
<resource: #menu> |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
333 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
334 |
^ |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
335 |
#(#Menu |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
336 |
#( |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
337 |
#(#MenuItem |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
338 |
#label: 'New Folder...' |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
339 |
#translateLabel: true |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
340 |
#value: #fileListMenuNewFolder |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
341 |
) |
2354 | 342 |
#(#MenuItem |
343 |
#label: '-' |
|
344 |
) |
|
345 |
#(#MenuItem |
|
346 |
#label: 'Remove...' |
|
347 |
#translateLabel: true |
|
348 |
#value: #fileListMenuRemove |
|
349 |
) |
|
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
350 |
) |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
351 |
nil |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
352 |
nil |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
353 |
) |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
354 |
! ! |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
355 |
|
197 | 356 |
!FileSelectionBox methodsFor:'accessing'! |
3 | 357 |
|
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
358 |
allowMakeDirectory:aBoolean |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
359 |
"allow or deny creation of new directories; |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
360 |
The default is to allow it." |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
361 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
362 |
allowMakeDirectory := aBoolean. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
363 |
! |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
364 |
|
197 | 365 |
contents |
366 |
"return the current entered value (i.e. the enterFields string). |
|
367 |
redefined to return the full pathname." |
|
368 |
||
1809 | 369 |
|string| |
3 | 370 |
|
197 | 371 |
string := super contents. |
2638
4dac570cd467
fixed cancel-value if in requestFileName mode
Claus Gittinger <cg@exept.de>
parents:
2463
diff
changeset
|
372 |
string size == 0 ifTrue:[ |
4dac570cd467
fixed cancel-value if in requestFileName mode
Claus Gittinger <cg@exept.de>
parents:
2463
diff
changeset
|
373 |
selectingDirectory ifFalse:[^ string]. |
1670
8d24855a9f0b
oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
374 |
^ selectionList directory pathName |
121 | 375 |
]. |
1670
8d24855a9f0b
oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
376 |
(string asFilename isAbsolute) ifTrue:[ |
8d24855a9f0b
oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
377 |
^ string |
77 | 378 |
]. |
197 | 379 |
^ (selectionList directory pathName asFilename construct:string) asString |
1670
8d24855a9f0b
oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
380 |
|
8d24855a9f0b
oops - handle absolute filenames correctly under vms and msdos
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
381 |
"Modified: / 9.9.1998 / 21:23:16 / cg" |
132 | 382 |
! |
383 |
||
1672 | 384 |
directory |
385 |
"return the directory which is currently shown" |
|
386 |
||
387 |
^ selectionList directory |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
388 |
! |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
389 |
|
1672 | 390 |
directory:directoryName |
391 |
"change the directory shown in the list." |
|
392 |
||
2463 | 393 |
selectionList directory:directoryName. |
394 |
selectingDirectory ifTrue:[ |
|
395 |
enterField contents:directoryName asFilename pathName |
|
396 |
] |
|
132 | 397 |
! |
398 |
||
1672 | 399 |
fileName |
400 |
"if some filename has been entered, return it (without the directory path) |
|
401 |
otherwise, return nil" |
|
402 |
||
403 |
|string| |
|
404 |
||
405 |
string := super contents. |
|
406 |
string isNil ifTrue:[^ nil]. |
|
407 |
^ self pathName asFilename baseName |
|
408 |
||
409 |
"Modified: / 12.8.1998 / 09:54:01 / cg" |
|
351 | 410 |
! |
411 |
||
1672 | 412 |
matchBlock:aBlock |
413 |
"set the matchBlock (in the selectionList). Only files |
|
414 |
for which the block returns true are shown. |
|
415 |
The matching is actually done in the fileSelectionList." |
|
416 |
||
417 |
selectionList matchBlock:aBlock |
|
197 | 418 |
! |
0 | 419 |
|
1672 | 420 |
openOn:aPath |
421 |
"open the box showing files in aPath. |
|
422 |
This is only a shortcut message - no new functionality." |
|
423 |
||
424 |
self directory:aPath. |
|
425 |
self showAtPointer |
|
38 | 426 |
! |
427 |
||
351 | 428 |
pathName |
429 |
"same as contents - return the full pathname of the selected file, |
|
430 |
or the pathname of the directory if nothing has been entered" |
|
431 |
||
432 |
^ self contents |
|
433 |
! |
|
434 |
||
1672 | 435 |
pattern:aPattern |
436 |
"set the pattern - this also enables the PatternField |
|
437 |
(if the pattern is non-nil) or hides it (if nil)." |
|
438 |
||
439 |
|focusSequence| |
|
130 | 440 |
|
1672 | 441 |
patternField initialText:aPattern. |
442 |
selectionList pattern:aPattern. |
|
443 |
aPattern isNil ifTrue:[ |
|
444 |
patternField beInvisible. |
|
445 |
self makeUntabable:patternField. |
|
446 |
focusSequence := (Array |
|
447 |
with:enterField |
|
448 |
with:selectionList |
|
449 |
with:okButton |
|
450 |
with:abortButton) |
|
451 |
] ifFalse:[ |
|
452 |
patternField beVisible. |
|
3468 | 453 |
self makeTabable:patternField. |
1672 | 454 |
focusSequence := (Array |
455 |
with:patternField |
|
456 |
with:enterField |
|
457 |
with:selectionList |
|
458 |
with:okButton |
|
459 |
with:abortButton) |
|
460 |
]. |
|
461 |
||
462 |
windowGroup notNil ifTrue:[ |
|
463 |
windowGroup focusSequence:focusSequence |
|
464 |
]. |
|
465 |
||
466 |
"Modified: 18.10.1997 / 03:02:05 / cg" |
|
351 | 467 |
! |
468 |
||
469 |
selectingDirectory:aBoolean |
|
849 | 470 |
"setup the box for directory selection (hides regular files). |
471 |
Use this, to ask the user for a directories name" |
|
472 |
||
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
473 |
selectingDirectory := aBoolean. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
474 |
aBoolean ifTrue:[ |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
475 |
selectionList directoryChangeAction:[:entry | self directoryChanged]. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
476 |
selectionList directorySelectAction:[:entry | self directorySelected]. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
477 |
selectionList ignoreFiles:true. |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
478 |
] |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
479 |
|
849 | 480 |
"Modified: 22.10.1996 / 13:24:50 / cg" |
197 | 481 |
! ! |
482 |
||
483 |
!FileSelectionBox methodsFor:'change & update'! |
|
484 |
||
485 |
update:something with:argument from:changedObject |
|
486 |
|commonName index s| |
|
487 |
||
488 |
something == #directory ifTrue:[ |
|
4355 | 489 |
" |
490 |
sent by fileNameEnterField, if a filename |
|
491 |
completion was not possible due to multiple |
|
492 |
matches. |
|
493 |
" |
|
494 |
selectionList directory:argument. |
|
495 |
s := enterField contents. |
|
496 |
s notNil ifTrue:[ |
|
497 |
commonName := s asFilename baseName. |
|
6550 | 498 |
commonName size ~~ 0 ifTrue:[ |
4355 | 499 |
index := selectionList list findFirst:[:entry | entry startsWith:commonName]. |
500 |
index ~~ 0 ifTrue:[ |
|
501 |
selectionList makeLineVisible:index |
|
502 |
] |
|
503 |
] |
|
504 |
] |
|
505 |
]. |
|
506 |
||
507 |
super update:something with:argument from:changedObject |
|
508 |
||
509 |
"Modified: / 23-01-2012 / 17:35:54 / cg" |
|
6550 | 510 |
"Modified: / 01-03-2019 / 15:43:24 / Claus Gittinger" |
197 | 511 |
! ! |
512 |
||
513 |
!FileSelectionBox methodsFor:'initialization'! |
|
514 |
||
1672 | 515 |
createEnterField |
516 |
"if the (optional) class FilenameEditField is present, use |
|
517 |
it, since it provides filename completion. Otherwise, we have |
|
518 |
to live with the dumb (default) field ... |
|
519 |
" |
|
520 |
FilenameEditField notNil ifTrue:[ |
|
521 |
^ FilenameEditField new. |
|
522 |
]. |
|
523 |
^ super createEnterField |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
524 |
|
1672 | 525 |
"Modified: 18.4.1996 / 20:02:24 / cg" |
38 | 526 |
! |
0 | 527 |
|
1672 | 528 |
initialize |
529 |
|corner| |
|
530 |
||
531 |
super initialize. |
|
532 |
selectingDirectory := false. |
|
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
533 |
allowMakeDirectory := true. |
1672 | 534 |
|
535 |
label := resources string:'File dialog'. |
|
536 |
||
537 |
labelField extent:(0.7 @ labelField height). |
|
4355 | 538 |
labelField label:(resources string:'Select a file:'). |
1672 | 539 |
labelField adjust:#left. |
540 |
||
541 |
patternField := EditField in:self. |
|
542 |
self is3D ifTrue:[ |
|
543 |
corner := (1.0 @ (labelField origin y+patternField heightIncludingBorder)). |
|
544 |
] ifFalse:[ |
|
545 |
corner := [(width - ViewSpacing - (patternField borderWidth * 2)) @ (labelField origin y+patternField height"IncludingBorder")]. |
|
546 |
]. |
|
547 |
patternField origin:(0.7 @ labelField origin y) corner:corner. |
|
4355 | 548 |
patternField rightInset:0. |
1672 | 549 |
patternField initialText:'*'. |
550 |
patternField leaveAction:[:reason | self patternChanged]. |
|
551 |
patternField crAction:[self patternChanged]. |
|
552 |
patternField hiddenOnRealize:true. "delay showing, until a pattern is defined" |
|
553 |
"/ no, since its invisible |
|
554 |
"/ self makeTabable:patternField before:enterField. |
|
555 |
||
4355 | 556 |
enterField |
557 |
origin:[0.0 @ (ViewSpacing + ViewSpacing + (labelField preferredHeight max:patternField preferredHeight) "height")]. |
|
1672 | 558 |
enterField addDependent:self. |
4355 | 559 |
"/ enterField immediateAccept:true. |
560 |
enterField acceptAction:[:newFile | self enterFieldChanged ]. |
|
561 |
enterField crAction:[:newFile | self enterFieldChanged. self okPressed ]. |
|
1672 | 562 |
|
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
563 |
selectionList menuHolder:self; menuMessage:#fileListMenu; menuPerformer:self. |
2375
1e3b7281d4ac
added optional ignoreCase in matchpattern
Claus Gittinger <cg@exept.de>
parents:
2354
diff
changeset
|
564 |
selectionList ignoreCaseInPattern:true. |
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
565 |
|
1672 | 566 |
" |
567 |
FileSelectionBox open |
|
568 |
FileSelectionBox new show |
|
569 |
" |
|
570 |
||
4355 | 571 |
"Modified: / 23-01-2012 / 18:18:47 / cg" |
1672 | 572 |
! |
573 |
||
574 |
postRealize |
|
575 |
"if some default is present in the enterField, |
|
576 |
scroll to make this one visible" |
|
577 |
||
578 |
|contents| |
|
579 |
||
580 |
super postRealize. |
|
581 |
(contents := enterField contents) notNil ifTrue:[ |
|
582 |
contents notEmpty ifTrue:[ |
|
583 |
selectionList makeVisible:contents |
|
584 |
] |
|
585 |
] |
|
586 |
||
587 |
"Created: 24.7.1997 / 18:19:14 / cg" |
|
197 | 588 |
! ! |
589 |
||
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
590 |
!FileSelectionBox methodsFor:'menu'! |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
591 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
592 |
fileListMenu |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
593 |
allowMakeDirectory ifFalse:[^ self]. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
594 |
^ self class fileListMenu |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
595 |
! |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
596 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
597 |
fileListMenuNewFolder |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
598 |
|newDirName d| |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
599 |
|
4629 | 600 |
newDirName := Dialog request:(resources string:'Name of new Folder:'). |
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
601 |
newDirName size == 0 ifTrue:[^ self]. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
602 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
603 |
d := self directory asFilename construct:newDirName. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
604 |
d exists ifTrue:[ |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
605 |
d isDirectory ifTrue:[ |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
606 |
^ self |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
607 |
]. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
608 |
self warn:(resources string:'A file named %1 already exists.' with:newDirName). |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
609 |
^ self |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
610 |
]. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
611 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
612 |
d makeDirectory. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
613 |
self updateList. |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
614 |
|
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
615 |
" |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
616 |
self open |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
617 |
" |
2354 | 618 |
! |
619 |
||
620 |
fileListMenuRemove |
|
621 |
|selectedFilename baseName| |
|
622 |
||
623 |
selectedFilename := self pathName asFilename. |
|
624 |
baseName := selectedFilename baseName. |
|
625 |
||
6544 | 626 |
(Dialog confirm:(resources string:'Really remove "%1" ?' with:baseName allBold)) ifFalse:[ |
2354 | 627 |
^ self. |
628 |
]. |
|
629 |
||
630 |
selectedFilename isDirectory ifTrue:[ |
|
6544 | 631 |
self warn:(resources string:'"%1" is a directory.' with:baseName). |
2354 | 632 |
^ self. |
633 |
]. |
|
634 |
||
6299 | 635 |
selectedFilename remove. |
2376 | 636 |
self updateListWithoutScrolling. |
6544 | 637 |
|
638 |
"Modified: / 21-02-2019 / 17:47:04 / Claus Gittinger" |
|
2231
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
639 |
! ! |
48ab82d819bc
added makeDirectory popUpMenu.
Claus Gittinger <cg@exept.de>
parents:
1809
diff
changeset
|
640 |
|
197 | 641 |
!FileSelectionBox methodsFor:'private'! |
642 |
||
1672 | 643 |
updateList |
644 |
selectionList updateList |
|
2376 | 645 |
! |
646 |
||
647 |
updateListWithoutScrolling |
|
648 |
selectionList updateListWithoutScrolling |
|
1672 | 649 |
! ! |
38 | 650 |
|
197 | 651 |
!FileSelectionBox methodsFor:'queries'! |
652 |
||
6504 | 653 |
computePreferredExtent |
5875 | 654 |
"return my preferred extent |
655 |
- that's the minimum size to make everything visible" |
|
1672 | 656 |
|
657 |
|wWanted hWanted mm| |
|
658 |
||
659 |
mm := ViewSpacing. |
|
660 |
||
661 |
wWanted := mm + |
|
3614
eb3e6fc07151
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
662 |
labelField preferredWidth + |
1672 | 663 |
(mm * 2) + |
3614
eb3e6fc07151
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
664 |
patternField preferredWidth + |
1672 | 665 |
mm. |
666 |
(wWanted < width) ifTrue:[ |
|
667 |
wWanted := width |
|
668 |
]. |
|
669 |
hWanted := mm + labelField height + |
|
670 |
mm + enterField height + |
|
671 |
mm + selectionList height + |
|
3614
eb3e6fc07151
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3468
diff
changeset
|
672 |
mm + buttonPanel preferredHeight + |
1672 | 673 |
mm. |
674 |
||
675 |
(hWanted < height) ifTrue:[ |
|
676 |
hWanted := height |
|
677 |
]. |
|
678 |
^ (wWanted @ hWanted) |
|
679 |
||
6504 | 680 |
"Created: / 09-11-2018 / 19:52:40 / Claus Gittinger" |
1672 | 681 |
! ! |
197 | 682 |
|
683 |
!FileSelectionBox methodsFor:'user actions'! |
|
684 |
||
1672 | 685 |
directoryChanged |
686 |
selectingDirectory ifTrue:[ |
|
687 |
selectionList changeDirectory. |
|
688 |
enterField contents:(selectionList directory pathName). |
|
689 |
selectionList setSelection:nil. |
|
690 |
]. |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
691 |
|
1672 | 692 |
"Created: 18.4.1996 / 18:38:21 / cg" |
693 |
"Modified: 25.5.1996 / 12:27:05 / cg" |
|
548
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
694 |
! |
c418699a90c0
moved all request methods (class protocol) to DialogBox
Claus Gittinger <cg@exept.de>
parents:
438
diff
changeset
|
695 |
|
1672 | 696 |
directorySelected |
697 |
"a directory was selected - show the new path in the inputField, |
|
698 |
if we are in directory mode" |
|
699 |
||
700 |
selectingDirectory ifTrue:[ |
|
701 |
|newDir| |
|
702 |
||
703 |
newDir := (selectionList directory) |
|
704 |
construct:selectionList selectionValue. |
|
705 |
enterField contents:newDir pathName. |
|
706 |
]. |
|
707 |
||
708 |
"Created: / 18.4.1996 / 18:46:15 / cg" |
|
709 |
"Modified: / 7.8.1998 / 17:19:26 / cg" |
|
710 |
! |
|
711 |
||
712 |
doubleClick |
|
713 |
|entry| |
|
714 |
||
715 |
entry := selectionList selectionValue. |
|
716 |
entry notNil ifTrue:[ |
|
717 |
((selectionList directory asFilename construct:entry) isDirectory) ifFalse:[ |
|
718 |
selectingDirectory ifFalse:[ |
|
719 |
enterField contents:entry. |
|
720 |
self okPressed |
|
721 |
] |
|
722 |
] |
|
723 |
]. |
|
724 |
||
725 |
"Modified: 19.10.1997 / 00:17:37 / cg" |
|
197 | 726 |
! |
727 |
||
4355 | 728 |
enterFieldChanged |
729 |
|fn dir| |
|
730 |
||
731 |
fn := enterField contents. |
|
732 |
(dir := fn asFilename) exists ifFalse:[ |
|
733 |
dir := dir directory. |
|
734 |
]. |
|
735 |
dir exists ifTrue:[ |
|
736 |
dir isDirectory ifFalse:[ |
|
737 |
dir := dir directory |
|
738 |
]. |
|
739 |
selectionList changeDirectoryTo:dir pathName |
|
740 |
]. |
|
741 |
||
742 |
"Created: / 23-01-2012 / 18:10:32 / cg" |
|
743 |
! |
|
744 |
||
197 | 745 |
okPressed |
746 |
"called for both on ok-press and on return-key" |
|
747 |
||
748 |
|dir string fname| |
|
749 |
||
750 |
string := enterField contents. |
|
3237
4c6fe0664cab
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
751 |
(string notEmptyOrNil) ifTrue:[ |
351 | 752 |
string := string withoutSeparators. |
753 |
string asFilename isAbsolute ifTrue:[ |
|
754 |
fname := string asFilename |
|
755 |
] ifFalse:[ |
|
756 |
dir := selectionList directory pathName asFilename. |
|
757 |
fname := dir construct:string |
|
758 |
]. |
|
759 |
fname isDirectory ifTrue:[ |
|
760 |
selectingDirectory ifFalse:[ |
|
761 |
selectionList directory:fname asString. |
|
762 |
self updateList. |
|
763 |
^ self |
|
764 |
] |
|
765 |
] |
|
766 |
] ifFalse:[ |
|
767 |
selectingDirectory ifTrue:[ |
|
768 |
enterField contents:(selectionList directory pathName). |
|
769 |
]. |
|
38 | 770 |
]. |
351 | 771 |
|
197 | 772 |
super okPressed |
351 | 773 |
|
1674
75149fa16b10
oops - leftover halt removed.
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
774 |
"Modified: / 10.9.1998 / 22:19:11 / cg" |
197 | 775 |
! |
776 |
||
1672 | 777 |
patternChanged |
778 |
selectionList pattern:patternField contents. |
|
746
4442a4d4121f
dont want return in patternField to be accept of box
Claus Gittinger <cg@exept.de>
parents:
740
diff
changeset
|
779 |
self updateList |
4442a4d4121f
dont want return in patternField to be accept of box
Claus Gittinger <cg@exept.de>
parents:
740
diff
changeset
|
780 |
|
4442a4d4121f
dont want return in patternField to be accept of box
Claus Gittinger <cg@exept.de>
parents:
740
diff
changeset
|
781 |
"Created: 4.6.1996 / 20:30:23 / cg" |
1672 | 782 |
! |
783 |
||
784 |
selectionChanged |
|
785 |
|entry| |
|
786 |
||
787 |
entry := selectionList selectionValue. |
|
788 |
(selectionList directory asFilename construct:entry) type == #directory ifFalse:[ |
|
789 |
selectingDirectory ifTrue:[ |
|
790 |
enterField contents:(selectionList directory pathName). |
|
791 |
selectionList setSelection:nil. |
|
792 |
^ self |
|
793 |
] |
|
794 |
]. |
|
795 |
enterField contents:entry |
|
796 |
||
797 |
"Modified: 21.9.1997 / 12:07:55 / cg" |
|
0 | 798 |
! ! |
197 | 799 |
|
849 | 800 |
!FileSelectionBox class methodsFor:'documentation'! |
240 | 801 |
|
802 |
version |
|
5590 | 803 |
^ '$Header$' |
240 | 804 |
! ! |
4629 | 805 |