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