author | Claus Gittinger <cg@exept.de> |
Thu, 08 Feb 1996 20:22:02 +0100 | |
changeset 330 | 56fcae58bcb5 |
parent 329 | dc3de413de73 |
child 338 | 9cbc51998a23 |
permissions | -rw-r--r-- |
11 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
62 | 3 |
All Rights Reserved |
11 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
SelectionInListView subclass:#FileSelectionList |
|
287 | 14 |
instanceVariableNames:'pattern directory timeStamp directoryId directoryName |
15 |
directoryContents directoryFileTypes fileTypes realAction |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
16 |
matchBlock stayInDirectory ignoreParentDirectory markDirectories |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
17 |
ignoreDirectories directoryChangeCheckBlock' |
282 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Text' |
|
11 | 21 |
! |
22 |
||
23 |
!FileSelectionList class methodsFor:'documentation'! |
|
24 |
||
38 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
62 | 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 |
||
11 | 39 |
documentation |
40 |
" |
|
38 | 41 |
this class implements file selection lists - its basically a |
42 |
selection in list, but adds some right-arrows to directories. |
|
43 |
(and will soon remember the previous position when changing directories). |
|
59 | 44 |
You can specify an optional filename-pattern (such as '*.st') and an |
45 |
optional matchBlock (such as: [:name | name startsWith:'A']). |
|
46 |
||
47 |
Only files (plus directories) matching the pattern (if present) and |
|
48 |
for which the matchBlock returns true (if present), are shown. |
|
21 | 49 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
50 |
Except for file-browser like applications, FileSelectionLists are almost |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
51 |
exclusively used with FileSelectionBoxes (see examples there). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
52 |
|
38 | 53 |
Instance variables: |
62 | 54 |
pattern the matchpattern |
55 |
||
56 |
directory the current directory |
|
59 | 57 |
|
62 | 58 |
timeStamp the time, when directoryContents was last taken |
59 |
directoryId the directories id (inode-nr) when it was taken |
|
285
e1f09d0f2c15
oops - inode is not sufficient for caching dir-contents
Claus Gittinger <cg@exept.de>
parents:
282
diff
changeset
|
60 |
directoryName the path when it was taken |
62 | 61 |
directoryContents (cached) contents of current directory |
62 |
directoryFileTypes (cached) file types (symbols) of current directory |
|
63 |
fileTypes file types as shown in list (i.e only matching ones) |
|
64 |
matchBlock if non-nil: block evaluated per full filename; |
|
65 |
only files for which matchBlock returns true are shown. |
|
59 | 66 |
|
62 | 67 |
realAction (internal) the action to perform when a file is selected |
68 |
||
69 |
" |
|
70 |
! |
|
59 | 71 |
|
62 | 72 |
examples |
73 |
" |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
74 |
FileSelectionLists are typically used in FileSelectionBoxes, |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
75 |
or file-browser-like applications. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
76 |
Thus, the following examples are a bit untypical. |
59 | 77 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
78 |
example (plain file-list): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
79 |
|
62 | 80 |
|list| |
59 | 81 |
|
62 | 82 |
list := FileSelectionList new. |
83 |
list open |
|
59 | 84 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
85 |
example (scrolled & some action): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
86 |
|
62 | 87 |
|top v list| |
59 | 88 |
|
62 | 89 |
top := StandardSystemView new. |
90 |
top extent:(300 @ 200). |
|
91 |
v := ScrollableView for:FileSelectionList in:top. |
|
92 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
93 |
list := v scrolledView. |
|
94 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
95 |
top open |
|
59 | 96 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
97 |
ignore the parentDirectory: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
98 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
99 |
|top v list| |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
100 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
101 |
top := StandardSystemView new. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
102 |
top extent:(300 @ 200). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
103 |
v := ScrollableView for:FileSelectionList in:top. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
104 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
105 |
list := v scrolledView. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
106 |
list ignoreParentDirectory:true. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
107 |
top open |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
108 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
109 |
ignore all directories: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
110 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
111 |
|top v list| |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
112 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
113 |
top := StandardSystemView new. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
114 |
top extent:(300 @ 200). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
115 |
v := ScrollableView for:FileSelectionList in:top. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
116 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
117 |
list := v scrolledView. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
118 |
list ignoreDirectories:true. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
119 |
top open |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
120 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
121 |
dont show the directory arrow-mark: |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
122 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
123 |
|top v list| |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
124 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
125 |
top := StandardSystemView new. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
126 |
top extent:(300 @ 200). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
127 |
v := ScrollableView for:FileSelectionList in:top. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
128 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
129 |
list := v scrolledView. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
130 |
list markDirectories:false. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
131 |
top open |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
132 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
133 |
example (adds a pattern, only showing .st files and directories): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
134 |
|
62 | 135 |
|top v list| |
59 | 136 |
|
62 | 137 |
top := StandardSystemView new. |
138 |
top extent:(300 @ 200). |
|
139 |
v := ScrollableView for:FileSelectionList in:top. |
|
140 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
141 |
list := v scrolledView. |
|
142 |
list pattern:'*.st'. |
|
143 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
144 |
top open |
|
59 | 145 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
146 |
example (a more complicated pattern): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
147 |
|
62 | 148 |
|top v list| |
59 | 149 |
|
62 | 150 |
top := StandardSystemView new. |
151 |
top extent:(300 @ 200). |
|
152 |
v := ScrollableView for:FileSelectionList in:top. |
|
153 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
154 |
list := v scrolledView. |
|
155 |
list pattern:'[A-D]*.st'. |
|
156 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
157 |
top open |
|
59 | 158 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
159 |
example (adds a matchblock to show only writable files): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
160 |
|
62 | 161 |
|top v list| |
59 | 162 |
|
62 | 163 |
top := StandardSystemView new. |
164 |
top extent:(300 @ 200). |
|
165 |
v := ScrollableView for:FileSelectionList in:top. |
|
166 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
167 |
list := v scrolledView. |
|
168 |
list matchBlock:[:name | |
|
169 |
|fileName| |
|
170 |
fileName := name asFilename. |
|
171 |
fileName isWritable or:[fileName isDirectory] |
|
172 |
]. |
|
173 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
174 |
top open |
|
59 | 175 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
176 |
example (adds a matchblock to suppress directories): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
177 |
|
62 | 178 |
|top v list| |
59 | 179 |
|
62 | 180 |
top := StandardSystemView new. |
181 |
top extent:(300 @ 200). |
|
182 |
v := ScrollableView for:FileSelectionList in:top. |
|
183 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
184 |
list := v scrolledView. |
|
185 |
list matchBlock:[:name | |
|
186 |
name asFilename isDirectory not |
|
187 |
]. |
|
188 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
189 |
top open |
|
59 | 190 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
191 |
example (the above can be done more convenient) |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
192 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
193 |
|top v list| |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
194 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
195 |
top := StandardSystemView new. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
196 |
top extent:(300 @ 200). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
197 |
v := ScrollableView for:FileSelectionList in:top. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
198 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
199 |
list := v scrolledView. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
200 |
list ignoreDirectories:true. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
201 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
202 |
top open |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
203 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
204 |
example (adds a matchblock to block parent dirs (i.e. only allow files here & below): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
205 |
|
62 | 206 |
|top v list currentDir| |
59 | 207 |
|
62 | 208 |
currentDir := '.' asFilename pathName. |
59 | 209 |
|
62 | 210 |
top := StandardSystemView new. |
211 |
top extent:(300 @ 200). |
|
212 |
v := ScrollableView for:FileSelectionList in:top. |
|
213 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
214 |
list := v scrolledView. |
|
215 |
list matchBlock:[:name | |
|
216 |
((name endsWith:'/..') and:[list directory pathName = currentDir]) not |
|
217 |
]. |
|
218 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
219 |
top open |
|
59 | 220 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
221 |
example (block moving up AND show all .rc-files only): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
222 |
|
62 | 223 |
|top v list currentDir| |
59 | 224 |
|
62 | 225 |
currentDir := '.' asFilename pathName. |
59 | 226 |
|
62 | 227 |
top := StandardSystemView new. |
228 |
top extent:(300 @ 200). |
|
229 |
v := ScrollableView for:FileSelectionList in:top. |
|
230 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
231 |
list := v scrolledView. |
|
232 |
list pattern:'*.rc'. |
|
233 |
list matchBlock:[:name | |
|
234 |
((name endsWith:'/..') and:[list directory pathName = currentDir]) not |
|
235 |
]. |
|
236 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
237 |
top open |
|
59 | 238 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
239 |
example (show only .rc-files in current directory): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
240 |
|
62 | 241 |
|top v list currentDir| |
59 | 242 |
|
62 | 243 |
currentDir := '.' asFilename pathName. |
59 | 244 |
|
62 | 245 |
top := StandardSystemView new. |
246 |
top extent:(300 @ 200). |
|
247 |
v := ScrollableView for:FileSelectionList in:top. |
|
248 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
249 |
list := v scrolledView. |
|
250 |
list pattern:'*.rc'. |
|
251 |
list matchBlock:[:name | |
|
252 |
name asFilename isDirectory not |
|
253 |
]. |
|
254 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
255 |
top open |
|
59 | 256 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
257 |
example (show only h*-files in /etc; dont allow directory changes): |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
258 |
|
62 | 259 |
|top v list| |
59 | 260 |
|
62 | 261 |
top := StandardSystemView new. |
262 |
top extent:(300 @ 200). |
|
263 |
v := ScrollableView for:FileSelectionList in:top. |
|
264 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
265 |
list := v scrolledView. |
|
266 |
list directory:'/etc'. |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
267 |
list pattern:'h*'. |
62 | 268 |
list matchBlock:[:name | name printNL. |
269 |
name asFilename isDirectory not |
|
270 |
]. |
|
271 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
|
272 |
top open |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
273 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
274 |
example (only allow changing into directories below the current one; i.e. not up; |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
275 |
but show it) |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
276 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
277 |
|top v list here| |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
278 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
279 |
top := StandardSystemView new. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
280 |
top extent:(300 @ 200). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
281 |
v := ScrollableView for:FileSelectionList in:top. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
282 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
283 |
list := v scrolledView. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
284 |
list directoryChangeCheckBlock:[:dirPath | |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
285 |
dirPath asFilename pathName |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
286 |
startsWith:Filename currentDirectory pathName]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
287 |
list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
288 |
top open |
11 | 289 |
" |
77 | 290 |
! ! |
291 |
||
292 |
!FileSelectionList methodsFor:'accessing'! |
|
293 |
||
193 | 294 |
action:aBlock |
295 |
"set the action to be performed on a selection" |
|
296 |
||
297 |
realAction := aBlock |
|
298 |
! |
|
299 |
||
300 |
directory |
|
301 |
"return the shown directory" |
|
302 |
||
303 |
^ directory |
|
304 |
! |
|
305 |
||
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
306 |
directoryChangeCheckBlock:aBlock |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
307 |
"set the directoryChangeCheckBlock - if non-nil, it controls if |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
308 |
a directory change is legal." |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
309 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
310 |
directoryChangeCheckBlock := aBlock |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
311 |
! |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
312 |
|
77 | 313 |
directory:nameOrDirectory |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
314 |
"set the lists contents to the filenames in the directory. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
315 |
This does not validate the change with any directoryChangeBlock." |
77 | 316 |
|
317 |
|oldPath name| |
|
318 |
||
319 |
nameOrDirectory isString ifTrue:[ |
|
81 | 320 |
name := nameOrDirectory |
77 | 321 |
] ifFalse:[ |
81 | 322 |
nameOrDirectory isNil ifTrue:[ |
323 |
directory := nil. |
|
324 |
^ self updateList |
|
325 |
]. |
|
326 |
name := nameOrDirectory pathName |
|
77 | 327 |
]. |
328 |
directory isNil ifTrue:[ |
|
81 | 329 |
directory := FileDirectory new. |
330 |
oldPath := nil |
|
77 | 331 |
] ifFalse:[ |
81 | 332 |
oldPath := directory pathName. |
77 | 333 |
]. |
334 |
directory pathName:name. |
|
335 |
realized ifTrue:[ |
|
81 | 336 |
(directory pathName = oldPath) ifFalse:[ |
337 |
self updateList |
|
338 |
] |
|
77 | 339 |
] |
340 |
! |
|
341 |
||
342 |
ignoreParentDirectory:aBoolean |
|
343 |
"set/clear the flag which controls if the parent directory (..) |
|
344 |
is shown in the list. The default is false (i.e. show it)" |
|
345 |
||
346 |
ignoreParentDirectory := aBoolean |
|
347 |
! |
|
348 |
||
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
349 |
ignoreDirectories:aBoolean |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
350 |
"set/clear the flag which controls if directories are ignored |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
351 |
(i.e. hidden). The default is false (i.e. dirs are shown)" |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
352 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
353 |
ignoreDirectories := aBoolean |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
354 |
! |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
355 |
|
282 | 356 |
markDirectories:aBoolean |
357 |
"turn on/off marking of directories with an arrow. |
|
358 |
The default is on" |
|
359 |
||
360 |
markDirectories := aBoolean |
|
361 |
! |
|
362 |
||
193 | 363 |
matchBlock:aBlock |
364 |
"set the matchBlock - if non-nil, it controls which |
|
365 |
names are shown in the list." |
|
366 |
||
367 |
matchBlock := aBlock |
|
368 |
! |
|
369 |
||
77 | 370 |
pattern:aPattern |
371 |
"set the pattern - if it changes, update the list." |
|
21 | 372 |
|
77 | 373 |
pattern ~= aPattern ifTrue:[ |
374 |
pattern := aPattern. |
|
375 |
realized ifTrue:[ |
|
376 |
self updateList |
|
377 |
]. |
|
378 |
]. |
|
379 |
! |
|
380 |
||
381 |
selectedPathname |
|
382 |
"if there is a selection, return its full pathname. |
|
383 |
Of there is no selection, return nil." |
|
384 |
||
385 |
|sel| |
|
386 |
||
387 |
sel := self selectionValue. |
|
388 |
sel isNil ifTrue:[^ nil]. |
|
389 |
^ directory pathName , Filename separator asString , sel. |
|
390 |
||
391 |
! |
|
392 |
||
193 | 393 |
stayInDirectory:aBoolean |
394 |
"set/clear the flag which controls if selecting a directory |
|
395 |
should locally change (if false) or be handled just like |
|
396 |
the selection of a file (if true). |
|
397 |
The default is false (i.e. change and do not tell via action)" |
|
398 |
||
399 |
stayInDirectory := aBoolean |
|
400 |
! ! |
|
401 |
||
402 |
!FileSelectionList methodsFor:'drawing'! |
|
403 |
||
404 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
|
405 |
"redefined to look for directory in every line" |
|
406 |
||
407 |
|l| |
|
408 |
||
409 |
"first, draw chunk of lines" |
|
410 |
super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. |
|
282 | 411 |
markDirectories ifFalse:[^ self]. |
193 | 412 |
|
413 |
"then draw marks" |
|
414 |
startVisLineNr to:endVisLineNr do:[:visLineNr | |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
415 |
l := self visibleLineToListLine:visLineNr. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
416 |
l notNil ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
417 |
(fileTypes at:l) == #directory ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
418 |
self drawRightArrowInVisibleLine:visLineNr |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
419 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
420 |
] |
193 | 421 |
] |
422 |
! |
|
423 |
||
424 |
redrawVisibleLine:visLineNr |
|
425 |
"if the line is one for a directory, draw a right arrow" |
|
426 |
||
427 |
|l| |
|
428 |
||
429 |
super redrawVisibleLine:visLineNr. |
|
282 | 430 |
markDirectories ifFalse:[^ self]. |
431 |
||
193 | 432 |
l := self visibleLineToListLine:visLineNr. |
433 |
l notNil ifTrue:[ |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
434 |
(fileTypes at:l) == #directory ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
435 |
self drawRightArrowInVisibleLine:visLineNr |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
436 |
] |
193 | 437 |
] |
438 |
! ! |
|
439 |
||
329
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
440 |
!FileSelectionList methodsFor:'events'! |
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
441 |
|
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
442 |
sizeChanged:how |
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
443 |
"redraw marks if any" |
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
444 |
|
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
445 |
super sizeChanged:how. |
330 | 446 |
shown and:[markDirectories] ifTrue:[ |
447 |
self redraw |
|
448 |
] |
|
329
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
449 |
! ! |
dc3de413de73
redraw directoryMarks if size changes
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
450 |
|
193 | 451 |
!FileSelectionList methodsFor:'initialization'! |
452 |
||
453 |
initialize |
|
454 |
directory := FileDirectory currentDirectory. |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
455 |
stayInDirectory := ignoreParentDirectory := ignoreDirectories := false. |
282 | 456 |
markDirectories := true. |
193 | 457 |
super initialize. |
77 | 458 |
|
193 | 459 |
pattern := '*'. |
460 |
self initializeAction. |
|
461 |
||
462 |
"nontypical use ..." |
|
463 |
" |
|
464 |
FileSelectionList new open |
|
465 |
(FileSelectionList new directory:'/etc') open |
|
466 |
(ScrollableView for:FileSelectionList) open |
|
467 |
(HVScrollableView for:FileSelectionList) open |
|
468 |
" |
|
469 |
! |
|
470 |
||
471 |
initializeAction |
|
472 |
"setup action as: selections in list get forwarded to enterfield if not |
|
473 |
a directory; otherwise directory is changed" |
|
474 |
||
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
475 |
actionBlock := [:lineNr | self selectionChanged]. |
193 | 476 |
! |
477 |
||
478 |
reinitialize |
|
479 |
directory := FileDirectory currentDirectory. |
|
480 |
super reinitialize |
|
21 | 481 |
! ! |
482 |
||
11 | 483 |
!FileSelectionList methodsFor:'private'! |
484 |
||
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
485 |
selectionChanged |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
486 |
"if the selection changed, check for it being a directory |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
487 |
and possibly go there. If its not a directory, perform the realAction." |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
488 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
489 |
|entry ok newDir warnMessage| |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
490 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
491 |
self selection isCollection ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
492 |
entry := self selectionValue. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
493 |
(entry endsWith:' ...') ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
494 |
entry := entry copyWithoutLast:4. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
495 |
]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
496 |
(stayInDirectory not |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
497 |
and:[(directory typeOf:entry) == #directory]) ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
498 |
ok := false. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
499 |
newDir := directory pathName , Filename separator asString , entry. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
500 |
|
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
501 |
(directoryChangeCheckBlock isNil |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
502 |
or:[directoryChangeCheckBlock value:newDir]) ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
503 |
(directory isReadable:entry) ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
504 |
warnMessage := 'not allowed to read directory %1' |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
505 |
] ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
506 |
(directory isExecutable:entry) ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
507 |
warnMessage := 'not allowed to change to directory %1' |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
508 |
] ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
509 |
ok := true. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
510 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
511 |
]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
512 |
]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
513 |
ok ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
514 |
warnMessage notNil ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
515 |
self warn:(resources string:warnMessage with:entry). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
516 |
]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
517 |
self deselect |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
518 |
] ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
519 |
self directory:newDir. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
520 |
]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
521 |
] ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
522 |
realAction notNil ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
523 |
realAction value:self selection |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
524 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
525 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
526 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
527 |
! |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
528 |
|
77 | 529 |
updateList |
530 |
"set the lists contents to the filenames in the directory" |
|
531 |
||
287 | 532 |
|oldCursor files newList index path obsolete| |
77 | 533 |
|
534 |
directory isNil ifTrue:[ |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
535 |
super list:nil. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
536 |
files := newList := fileTypes := nil. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
537 |
^ self |
77 | 538 |
]. |
539 |
||
540 |
oldCursor := cursor. |
|
541 |
self cursor:(Cursor read). |
|
542 |
||
543 |
" |
|
544 |
if the directory-id changed, MUST update. |
|
545 |
(can happen after a restart, when a file is no longer |
|
546 |
there, has moved or is NFS-mounted differently) |
|
547 |
" |
|
287 | 548 |
obsolete := directoryId ~~ directory id |
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
549 |
or:[directoryName ~= directory pathName |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
550 |
or:[timeStamp notNil |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
551 |
and:[directory timeOfLastChange > timeStamp]]]. |
287 | 552 |
|
553 |
obsolete ifTrue:[ |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
554 |
timeStamp := directory timeOfLastChange. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
555 |
directoryId := directory id. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
556 |
directoryName := directory pathName. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
557 |
directoryContents := directory asStringCollection sort. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
558 |
directoryFileTypes := OrderedCollection new. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
559 |
directoryContents do:[:name | directoryFileTypes add:(directory typeOf:name)]. |
77 | 560 |
]. |
561 |
||
562 |
files := directoryContents. |
|
563 |
newList := OrderedCollection new. |
|
564 |
fileTypes := OrderedCollection new. |
|
565 |
index := 1. |
|
566 |
||
95 | 567 |
path := directory pathName , Filename separator asString. |
568 |
files do:[:name | |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
569 |
|type| |
77 | 570 |
|
296
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
571 |
(matchBlock isNil or:[matchBlock value:(path , name)]) ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
572 |
type := directoryFileTypes at:index. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
573 |
type == #directory ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
574 |
ignoreDirectories ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
575 |
name = '..' ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
576 |
ignoreParentDirectory ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
577 |
newList add:name. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
578 |
fileTypes add:type |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
579 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
580 |
] ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
581 |
name = '.' ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
582 |
"ignore" |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
583 |
] ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
584 |
newList add:(name ", ' ...'"). |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
585 |
fileTypes add:type |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
586 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
587 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
588 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
589 |
] ifFalse:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
590 |
(pattern isNil |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
591 |
or:[pattern isEmpty |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
592 |
or:[pattern = '*' |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
593 |
or:[pattern match:name]]]) ifTrue:[ |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
594 |
newList add:name. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
595 |
fileTypes add:type |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
596 |
] |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
597 |
]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
598 |
]. |
e1b9431b3aef
more examples in the documentation category
Claus Gittinger <cg@exept.de>
parents:
287
diff
changeset
|
599 |
index := index + 1 |
77 | 600 |
]. |
601 |
super list:newList. |
|
95 | 602 |
|
77 | 603 |
self cursor:oldCursor. |
287 | 604 |
|
77 | 605 |
! |
606 |
||
21 | 607 |
visibleLineNeedsSpecialCare:visLineNr |
608 |
|l| |
|
609 |
||
610 |
l := self visibleLineToListLine:visLineNr. |
|
611 |
l notNil ifTrue:[ |
|
62 | 612 |
(fileTypes at:l) == #directory ifTrue:[^ true]. |
613 |
^ super visibleLineNeedsSpecialCare:visLineNr |
|
21 | 614 |
]. |
615 |
^ false |
|
616 |
! |
|
617 |
||
193 | 618 |
widthForScrollBetween:firstLine and:lastLine |
619 |
"return the width in pixels for a scroll between firstLine and lastLine |
|
620 |
- return full width here since there might be directory marks" |
|
11 | 621 |
|
193 | 622 |
^ (width - margin - margin) |
11 | 623 |
! ! |
624 |
||
625 |
!FileSelectionList methodsFor:'realization'! |
|
626 |
||
627 |
realize |
|
628 |
"make the view visible; redefined to check if directory is still |
|
629 |
valid (using timestamp and inode numbers) - reread if not" |
|
630 |
||
631 |
(timeStamp isNil |
|
632 |
or:[(directory timeOfLastChange > timeStamp) |
|
633 |
or:[(directoryId isNil) |
|
634 |
or:[directoryId ~~ directory id]]]) ifTrue:[ |
|
62 | 635 |
directoryId := nil. |
636 |
self updateList |
|
11 | 637 |
]. |
638 |
super realize |
|
639 |
! ! |
|
77 | 640 |
|
282 | 641 |
!FileSelectionList class methodsFor:'documentation'! |
642 |
||
643 |
version |
|
330 | 644 |
^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.22 1996-02-08 19:22:02 cg Exp $' |
282 | 645 |
! ! |