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