104 or file-browser-like applications. |
118 or file-browser-like applications. |
105 Thus, the following examples are a bit untypical. |
119 Thus, the following examples are a bit untypical. |
106 |
120 |
107 example (plain file-list): |
121 example (plain file-list): |
108 |
122 |
109 |list| |
123 |list| |
110 |
124 |
111 list := FileSelectionList new. |
125 list := FileSelectionList new. |
112 list open |
126 list open |
113 |
127 |
114 example (scrolled & some action): |
128 |
115 |
129 scrolled & some action: |
116 |top v list| |
130 |
117 |
131 |top v list| |
118 top := StandardSystemView new. |
132 |
119 top extent:(300 @ 200). |
133 top := StandardSystemView new. |
120 v := ScrollableView for:FileSelectionList in:top. |
134 top extent:(300 @ 200). |
121 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
135 v := ScrollableView for:FileSelectionList in:top. |
122 list := v scrolledView. |
136 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
123 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
137 list := v scrolledView. |
124 top open |
138 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
139 top open |
125 |
140 |
126 ignore the parentDirectory: |
141 ignore the parentDirectory: |
127 |
142 |
128 |top v list| |
143 |top v list| |
129 |
144 |
130 top := StandardSystemView new. |
145 top := StandardSystemView new. |
131 top extent:(300 @ 200). |
146 top extent:(300 @ 200). |
132 v := ScrollableView for:FileSelectionList in:top. |
147 v := ScrollableView for:FileSelectionList in:top. |
133 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
148 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
134 list := v scrolledView. |
149 list := v scrolledView. |
135 list ignoreParentDirectory:true. |
150 list ignoreParentDirectory:true. |
136 top open |
151 top open |
137 |
152 |
138 ignore all directories: |
153 ignore all directories (i.e. regular files only): |
139 |
154 |
140 |top v list| |
155 |top v list| |
141 |
156 |
142 top := StandardSystemView new. |
157 top := StandardSystemView new. |
143 top extent:(300 @ 200). |
158 top extent:(300 @ 200). |
144 v := ScrollableView for:FileSelectionList in:top. |
159 v := ScrollableView for:FileSelectionList in:top. |
145 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
160 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
146 list := v scrolledView. |
161 list := v scrolledView. |
147 list ignoreDirectories:true. |
162 list ignoreDirectories:true. |
148 top open |
163 top open |
|
164 |
|
165 ignore all regular files (i.e. directories only): |
|
166 |
|
167 |top v list| |
|
168 |
|
169 top := StandardSystemView new. |
|
170 top extent:(300 @ 200). |
|
171 v := ScrollableView for:FileSelectionList in:top. |
|
172 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
173 list := v scrolledView. |
|
174 list ignoreFiles:true. |
|
175 top open |
149 |
176 |
150 dont show the directory arrow-mark: |
177 dont show the directory arrow-mark: |
151 |
178 |
152 |top v list| |
179 |top v list| |
153 |
180 |
154 top := StandardSystemView new. |
181 top := StandardSystemView new. |
155 top extent:(300 @ 200). |
182 top extent:(300 @ 200). |
156 v := ScrollableView for:FileSelectionList in:top. |
183 v := ScrollableView for:FileSelectionList in:top. |
157 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
184 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
158 list := v scrolledView. |
185 list := v scrolledView. |
159 list markDirectories:false. |
186 list markDirectories:false. |
160 top open |
187 top open |
161 |
188 |
162 example (adds a pattern, only showing .st files and directories): |
189 adds a pattern, only showing .st files and directories: |
163 |
190 |
164 |top v list| |
191 |top v list| |
165 |
192 |
166 top := StandardSystemView new. |
193 top := StandardSystemView new. |
167 top extent:(300 @ 200). |
194 top extent:(300 @ 200). |
168 v := ScrollableView for:FileSelectionList in:top. |
195 v := ScrollableView for:FileSelectionList in:top. |
169 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
196 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
170 list := v scrolledView. |
197 list := v scrolledView. |
171 list pattern:'*.st'. |
198 list pattern:'*.st'. |
172 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
199 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
173 top open |
200 top open |
174 |
201 |
175 example (a more complicated pattern): |
202 a more complicated pattern: |
176 |
203 |
177 |top v list| |
204 |top v list| |
178 |
205 |
179 top := StandardSystemView new. |
206 top := StandardSystemView new. |
180 top extent:(300 @ 200). |
207 top extent:(300 @ 200). |
181 v := ScrollableView for:FileSelectionList in:top. |
208 v := ScrollableView for:FileSelectionList in:top. |
182 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
209 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
183 list := v scrolledView. |
210 list := v scrolledView. |
184 list pattern:'[A-D]*.st'. |
211 list pattern:'[A-D]*.st'. |
185 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
212 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
186 top open |
213 top open |
187 |
214 |
188 example (adds a matchblock to show only writable files): |
215 adds a matchblock to show only writable files: |
189 |
216 |
190 |top v list| |
217 |top v list| |
191 |
218 |
192 top := StandardSystemView new. |
219 top := StandardSystemView new. |
193 top extent:(300 @ 200). |
220 top extent:(300 @ 200). |
194 v := ScrollableView for:FileSelectionList in:top. |
221 v := ScrollableView for:FileSelectionList in:top. |
195 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
222 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
196 list := v scrolledView. |
223 list := v scrolledView. |
197 list matchBlock:[:name | |
224 list matchBlock:[:name | |
198 |fileName| |
225 |fileName| |
199 fileName := name asFilename. |
226 fileName := name asFilename. |
200 fileName isWritable or:[fileName isDirectory] |
227 fileName isWritable or:[fileName isDirectory] |
201 ]. |
228 ]. |
202 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
229 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
203 top open |
230 top open |
204 |
231 |
205 example (adds a matchblock to suppress directories): |
232 adds a matchblock to suppress directories: |
206 |
233 (this can be done easier with #ignoreDirectories) |
207 |top v list| |
234 |
208 |
235 |top v list| |
209 top := StandardSystemView new. |
236 |
210 top extent:(300 @ 200). |
237 top := StandardSystemView new. |
211 v := ScrollableView for:FileSelectionList in:top. |
238 top extent:(300 @ 200). |
212 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
239 v := ScrollableView for:FileSelectionList in:top. |
213 list := v scrolledView. |
240 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
214 list matchBlock:[:name | |
241 list := v scrolledView. |
215 name asFilename isDirectory not |
242 list matchBlock:[:name | |
216 ]. |
243 name asFilename isDirectory not |
217 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
244 ]. |
218 top open |
245 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
219 |
246 top open |
220 example (the above can be done more convenient) |
247 |
221 |
248 the above can be done more convenient: |
222 |top v list| |
249 |
223 |
250 |top v list| |
224 top := StandardSystemView new. |
251 |
225 top extent:(300 @ 200). |
252 top := StandardSystemView new. |
226 v := ScrollableView for:FileSelectionList in:top. |
253 top extent:(300 @ 200). |
227 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
254 v := ScrollableView for:FileSelectionList in:top. |
228 list := v scrolledView. |
255 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
229 list ignoreDirectories:true. |
256 list := v scrolledView. |
230 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
257 list ignoreDirectories:true. |
231 top open |
258 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
232 |
259 top open |
233 example (adds a matchblock to block parent dirs (i.e. only allow files here & below): |
260 |
234 |
261 adds a matchblock to block parent dirs (i.e. only allow files here & below): |
235 |top v list currentDir| |
262 (can be done easier with #ignoreParentDirectory) |
236 |
263 |
237 currentDir := '.' asFilename pathName. |
264 |top v list currentDir| |
238 |
265 |
239 top := StandardSystemView new. |
266 currentDir := '.' asFilename pathName. |
240 top extent:(300 @ 200). |
267 |
241 v := ScrollableView for:FileSelectionList in:top. |
268 top := StandardSystemView new. |
242 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
269 top extent:(300 @ 200). |
243 list := v scrolledView. |
270 v := ScrollableView for:FileSelectionList in:top. |
244 list matchBlock:[:name | |
271 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
245 ((name endsWith:'/..') and:[list directory pathName = currentDir]) not |
272 list := v scrolledView. |
246 ]. |
273 list matchBlock:[:name | |
247 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
274 ((name endsWith:'/..') and:[list directory pathName = currentDir]) not |
248 top open |
275 ]. |
249 |
276 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
250 example (block moving up AND show all .rc-files only): |
277 top open |
251 |
278 |
252 |top v list currentDir| |
279 do not allow changing up AND show all .rc-files only: |
253 |
280 (but allow going down) |
254 currentDir := '.' asFilename pathName. |
281 |
255 |
282 |top v list currentDir| |
256 top := StandardSystemView new. |
283 |
257 top extent:(300 @ 200). |
284 currentDir := '.' asFilename pathName. |
258 v := ScrollableView for:FileSelectionList in:top. |
285 |
259 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
286 top := StandardSystemView new. |
260 list := v scrolledView. |
287 top extent:(300 @ 200). |
261 list pattern:'*.rc'. |
288 v := ScrollableView for:FileSelectionList in:top. |
262 list matchBlock:[:name | |
289 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
263 ((name endsWith:'/..') and:[list directory pathName = currentDir]) not |
290 list := v scrolledView. |
264 ]. |
291 list pattern:'*.rc'. |
265 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
292 list matchBlock:[:name | |
266 top open |
293 ((name endsWith:'/..') and:[list directory pathName = currentDir]) not |
267 |
294 ]. |
268 example (show only .rc-files in current directory): |
295 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
269 |
296 top open |
270 |top v list currentDir| |
297 |
271 |
298 show only .rc-files in current directory: |
272 currentDir := '.' asFilename pathName. |
299 |
273 |
300 |top v list currentDir| |
274 top := StandardSystemView new. |
301 |
275 top extent:(300 @ 200). |
302 currentDir := '.' asFilename pathName. |
276 v := ScrollableView for:FileSelectionList in:top. |
303 |
277 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
304 top := StandardSystemView new. |
278 list := v scrolledView. |
305 top extent:(300 @ 200). |
279 list pattern:'*.rc'. |
306 v := ScrollableView for:FileSelectionList in:top. |
280 list matchBlock:[:name | |
307 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
281 name asFilename isDirectory not |
308 list := v scrolledView. |
282 ]. |
309 list pattern:'*.rc'. |
283 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
310 list matchBlock:[:name | |
284 top open |
311 name asFilename isDirectory not |
285 |
312 ]. |
286 example (show only h*-files in /etc; dont allow directory changes): |
313 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
287 |
314 top open |
288 |top v list| |
315 |
289 |
316 show only h*-files in /etc; dont allow directory changes: |
290 top := StandardSystemView new. |
317 |
291 top extent:(300 @ 200). |
318 |top v list| |
292 v := ScrollableView for:FileSelectionList in:top. |
319 |
293 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
320 top := StandardSystemView new. |
294 list := v scrolledView. |
321 top extent:(300 @ 200). |
295 list directory:'/etc'. |
322 v := ScrollableView for:FileSelectionList in:top. |
296 list pattern:'h*'. |
323 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
297 list matchBlock:[:name | name printNL. |
324 list := v scrolledView. |
298 name asFilename isDirectory not |
325 list directory:'/etc'. |
299 ]. |
326 list pattern:'h*'. |
300 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
327 list matchBlock:[:name | name printNL. |
301 top open |
328 name asFilename isDirectory not |
302 |
329 ]. |
303 example (only allow changing into directories below the current one; i.e. not up; |
330 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
304 but show it) |
331 top open |
305 |
332 |
306 |top v list here| |
333 only allow changing into directories below the current one; i.e. not up; |
307 |
334 but show it |
308 top := StandardSystemView new. |
335 |
309 top extent:(300 @ 200). |
336 |top v list here| |
310 v := ScrollableView for:FileSelectionList in:top. |
337 |
311 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
338 top := StandardSystemView new. |
312 list := v scrolledView. |
339 top extent:(300 @ 200). |
313 list directoryChangeCheckBlock:[:dirPath | |
340 v := ScrollableView for:FileSelectionList in:top. |
314 dirPath asFilename pathName |
341 v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
315 startsWith:Filename currentDirectory pathName]. |
342 list := v scrolledView. |
316 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
343 list directoryChangeCheckBlock:[:dirPath | |
317 top open |
344 dirPath asFilename pathName |
|
345 startsWith:Filename currentDirectory pathName]. |
|
346 list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
347 top open |
|
348 |
|
349 |
|
350 living in a box: |
|
351 |
|
352 |box listView| |
|
353 |
|
354 box := Dialog new. |
|
355 box addTextLabel:'which file ?'. |
|
356 |
|
357 listView := box |
|
358 addListBoxOn:nil |
|
359 class:FileSelectionList |
|
360 withNumberOfLines:10 |
|
361 hScrollable:false |
|
362 vScrollable:true. |
|
363 |
|
364 box addAbortButton; addOkButton. |
|
365 box open. |
|
366 box accepted ifTrue:[ |
|
367 Transcript showCr:listView selectedPathname |
|
368 ] |
|
369 |
|
370 |
|
371 living in a box (local files only, no directory change allowed): |
|
372 |
|
373 |box listView| |
|
374 |
|
375 box := Dialog new. |
|
376 box addTextLabel:'which file ?'. |
|
377 |
|
378 listView := box |
|
379 addListBoxOn:nil |
|
380 class:FileSelectionList |
|
381 withNumberOfLines:10 |
|
382 hScrollable:false |
|
383 vScrollable:true. |
|
384 |
|
385 listView ignoreDirectories:true. |
|
386 listView ignoreParentDirectory:true. |
|
387 |
|
388 box addAbortButton; addOkButton. |
|
389 box open. |
|
390 box accepted ifTrue:[ |
|
391 Transcript showCr:listView selectedPathname |
|
392 ] |
|
393 |
|
394 |
|
395 living in a box (local files only; immediately show owner in another field): |
|
396 |
|
397 |box listView lbl| |
|
398 |
|
399 box := Dialog new. |
|
400 box addTextLabel:'which file ?'. |
|
401 |
|
402 listView := box |
|
403 addListBoxOn:nil |
|
404 class:FileSelectionList |
|
405 withNumberOfLines:10 |
|
406 hScrollable:false |
|
407 vScrollable:true. |
|
408 |
|
409 lbl := box addTextLabel:''. |
|
410 lbl adjust:#left. |
|
411 |
|
412 listView fileSelectAction:[:index | |
|
413 |ownerId owner| |
|
414 |
|
415 ownerId := listView selectedPathname asFilename info at:#uid. |
|
416 ownerId == OperatingSystem getUserID ifTrue:[ |
|
417 lbl label:('one of yours'). |
|
418 ] ifFalse:[ |
|
419 owner := OperatingSystem getUserNameFromID:ownerId. |
|
420 lbl label:(owner , '''s property'). |
|
421 ] |
|
422 ]. |
|
423 |
|
424 listView directorySelectAction:[:index | |
|
425 |ownerId owner| |
|
426 |
|
427 ownerId := listView selectedPathname asFilename info at:#uid. |
|
428 ownerId == OperatingSystem getUserID ifTrue:[ |
|
429 lbl label:('your files there'). |
|
430 ] ifFalse:[ |
|
431 owner := OperatingSystem getUserNameFromID:ownerId. |
|
432 lbl label:(owner , '''s files there'). |
|
433 ] |
|
434 ]. |
|
435 |
|
436 box addAbortButton; addOkButton. |
|
437 box open. |
|
438 box accepted ifTrue:[ |
|
439 Transcript showCr:listView selectedPathname |
|
440 ] |
318 " |
441 " |
319 ! ! |
442 ! ! |
320 |
443 |
321 !FileSelectionList methodsFor:'accessing-behavior'! |
444 !FileSelectionList methodsFor:'accessing-behavior'! |
322 |
445 |