author | Claus Gittinger <cg@exept.de> |
Fri, 20 Aug 1999 18:40:55 +0200 | |
changeset 1483 | c9fd1b1d775d |
parent 1389 | 3548d53b14ae |
child 1487 | fd003e2156cc |
permissions | -rw-r--r-- |
542 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
||
14 |
||
15 |
||
16 |
View subclass:#DataSetView |
|
824 | 17 |
instanceVariableNames:'labelView columnView listHolder useIndex scrolledView' |
542 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-DataSet' |
|
21 |
! |
|
22 |
||
23 |
!DataSetView class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
28 |
All Rights Reserved |
|
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 |
||
39 |
||
40 |
! |
|
41 |
||
42 |
documentation |
|
43 |
" |
|
44 |
This class implements a selection list view based on rows and columns. |
|
45 |
It allows for the dynamic editing of this information. |
|
46 |
||
47 |
[author:] |
|
48 |
Claus Atzkern |
|
49 |
||
50 |
[see also:] |
|
51 |
DataSetColumnSpec |
|
52 |
DataSetColumn |
|
53 |
DSVColumnView |
|
54 |
" |
|
55 |
! |
|
56 |
||
57 |
examples |
|
58 |
" |
|
619 | 59 |
example 1: list with valid rows of type Array |
611 | 60 |
[exBegin] |
61 |
|top scr columns rows bool rdWtSel| |
|
542 | 62 |
|
611 | 63 |
top := StandardSystemView new label:'select'; extent:700@440. |
64 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
65 |
||
66 |
columns := OrderedCollection new. |
|
67 |
rows := OrderedCollection new. |
|
68 |
bool := true. |
|
69 |
rdWtSel := #( #at: #at:put: ). |
|
70 |
||
71 |
1 to:1000 do:[:i||n| |
|
72 |
n := i printString. |
|
73 |
rows add:(Array with:('text: ', n) with:('input: ', n) with:bool). |
|
74 |
bool := bool not. |
|
75 |
]. |
|
76 |
||
77 |
columns add:(DataSetColumnSpec label:'Text' editorType:#None selector:rdWtSel). |
|
78 |
columns add:(DataSetColumnSpec label:'Input' editorType:#InputField selector:rdWtSel). |
|
79 |
columns add:(DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:rdWtSel). |
|
80 |
||
81 |
scr columnDescriptors:columns. |
|
82 |
scr list:rows. |
|
83 |
top open. |
|
84 |
[exEnd] |
|
85 |
||
86 |
||
619 | 87 |
|
88 |
example 2: list with none valid rows; defining #rowIfAbsent: block |
|
89 |
[exBegin] |
|
90 |
|top scr columns bool rdWtSel| |
|
91 |
||
92 |
top := StandardSystemView new label:'select'; extent:700@440. |
|
93 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
94 |
||
95 |
columns := OrderedCollection new. |
|
96 |
bool := true. |
|
97 |
rdWtSel := #( #at: #at:put: ). |
|
98 |
||
99 |
columns add:(DataSetColumnSpec label:'Text' editorType:#None selector:rdWtSel). |
|
100 |
columns add:(DataSetColumnSpec label:'Input' editorType:#InputField selector:rdWtSel). |
|
101 |
columns add:(DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:rdWtSel). |
|
102 |
||
103 |
scr rowIfAbsent:[:i| |
|
104 |
bool := bool not. |
|
105 |
Array with:('text: ', i printString) with:('input: ') with:bool |
|
106 |
]. |
|
107 |
||
108 |
scr columnDescriptors:columns. |
|
109 |
scr list:(Array new:1000). |
|
110 |
top open. |
|
111 |
[exEnd] |
|
112 |
||
113 |
||
114 |
||
115 |
example 3: list with valid rows of type Structure |
|
542 | 116 |
[exBegin] |
117 |
|top scr clDc rows slct list idx bool| |
|
118 |
||
119 |
top := StandardSystemView new label:'select'; extent:700@440. |
|
120 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
121 |
||
122 |
clDc := OrderedCollection new. |
|
123 |
rows := OrderedCollection new. |
|
124 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ). |
|
125 |
slct := #( #text #field #cbox #clist #toggle #choices ). |
|
126 |
idx := 11. |
|
127 |
bool := true. |
|
128 |
||
129 |
20 timesRepeat:[ |values| |
|
130 |
values := list collect:[:n| |
|
131 |
n isString ifTrue:[n, idx printString] |
|
132 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
133 |
]. |
|
134 |
rows add:(Structure newWith:slct values:values). |
|
135 |
bool := bool not. |
|
136 |
idx := idx + 1. |
|
137 |
]. |
|
138 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
139 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
140 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ). |
|
141 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ). |
|
142 |
clDc last choices:#choices. |
|
143 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
144 |
clDc last choices:#choices. |
|
145 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
146 |
||
607 | 147 |
scr has3Dseparators:true. |
542 | 148 |
scr columnDescriptors:clDc. |
149 |
scr list:rows. |
|
150 |
top open. |
|
151 |
[exEnd] |
|
152 |
||
153 |
||
154 |
||
155 |
||
619 | 156 |
example 4: table includes a row selector and multiple select is enabled |
542 | 157 |
[exBegin] |
158 |
|top scr clDc rows slct list idx bool| |
|
159 |
||
160 |
top := StandardSystemView new label:'select'; extent:700@440. |
|
161 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
162 |
||
163 |
clDc := OrderedCollection new. |
|
164 |
rows := OrderedCollection new. |
|
165 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ). |
|
166 |
slct := #( #text #field #cbox #clist #toggle #choices ). |
|
167 |
idx := 11. |
|
168 |
bool := true. |
|
169 |
||
170 |
20 timesRepeat:[ |values| |
|
171 |
values := list collect:[:n| |
|
172 |
n isString ifTrue:[n, idx printString] |
|
173 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
174 |
]. |
|
175 |
rows add:(Structure newWith:slct values:values). |
|
176 |
bool := bool not. |
|
177 |
idx := idx + 1. |
|
178 |
]. |
|
179 |
clDc add:( DataSetColumnSpec rowSelector ). |
|
180 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
181 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
182 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ). |
|
183 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ). |
|
184 |
clDc last choices:#choices. |
|
185 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
186 |
clDc last choices:#choices. |
|
187 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
188 |
||
607 | 189 |
scr has3Dseparators:true. |
542 | 190 |
scr columnDescriptors:clDc. |
619 | 191 |
scr multipleSelectOk:true. |
542 | 192 |
scr list:rows. |
193 |
top open. |
|
194 |
[exEnd] |
|
195 |
||
196 |
||
197 |
||
198 |
||
619 | 199 |
example 5: performance test; with valid rows |
542 | 200 |
[exBegin] |
201 |
|t1 top scr clDc rows slct list bool tmArr listModel| |
|
202 |
||
203 |
top := StandardSystemView new label:'select'; extent:600@440. |
|
204 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
205 |
||
206 |
clDc := OrderedCollection new. |
|
207 |
rows := OrderedCollection new. |
|
208 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true ). |
|
209 |
slct := #( #text #field #cbox #clist #toggle ). |
|
210 |
bool := true. |
|
211 |
||
212 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
213 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ). |
|
214 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ). |
|
215 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
216 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
217 |
||
218 |
scr columnDescriptors:clDc. |
|
219 |
scr beDependentOfRows:false. |
|
607 | 220 |
scr has3Dseparators:false. |
542 | 221 |
|
222 |
top openAndWait. |
|
223 |
tmArr := Array new:4. |
|
224 |
listModel := List new. |
|
225 |
scr listHolder:listModel. |
|
226 |
||
227 |
(1 to:tmArr size) do:[:i| |
|
228 |
listModel removeAll. |
|
229 |
||
230 |
t1 := Time millisecondsToRun:[ |
|
231 |
1 to:200 do:[:i| |values| |
|
232 |
values := list collect:[:n| |
|
233 |
n isString ifTrue:[n, i printString] |
|
234 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
235 |
]. |
|
236 |
listModel add:(Structure newWith:slct values:values). |
|
237 |
bool := bool not. |
|
238 |
||
239 |
i even ifTrue:[ |
|
240 |
listModel removeFirst |
|
241 |
] |
|
242 |
]. |
|
243 |
]. |
|
244 |
tmArr at:i put:t1 |
|
245 |
]. |
|
246 |
t1 := 0. |
|
247 |
||
248 |
Transcript showCR:'----------'. |
|
249 |
tmArr do:[:t| |
|
250 |
t1 := t1 + t. |
|
251 |
Transcript showCR:'TIME : ', t printString. |
|
252 |
]. |
|
253 |
Transcript showCR:'----------'. |
|
254 |
Transcript showCR:'DIFF : ', (t1 // tmArr size) printString. |
|
255 |
[exEnd] |
|
256 |
||
257 |
||
258 |
||
619 | 259 |
example 6: performance test; with invalid rows: defining #rowIfAbsent:. |
260 |
[exBegin] |
|
261 |
|t1 top scr clDc rows slct list bool tmArr listModel ctr| |
|
262 |
||
263 |
top := StandardSystemView new label:'select'; extent:600@440. |
|
264 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
265 |
||
266 |
clDc := OrderedCollection new. |
|
267 |
rows := OrderedCollection new. |
|
268 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true ). |
|
269 |
slct := #( #text #field #cbox #clist #toggle ). |
|
270 |
bool := true. |
|
271 |
||
272 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
273 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ). |
|
274 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ). |
|
275 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
276 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
277 |
ctr := 0. |
|
278 |
||
279 |
scr rowIfAbsent:[:i||values| |
|
280 |
bool := bool not. |
|
281 |
ctr := ctr + 1. |
|
282 |
values := list collect:[:n| |
|
283 |
n isString ifTrue:[n, ctr printString] |
|
284 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
285 |
]. |
|
286 |
Structure newWith:slct values:values |
|
287 |
]. |
|
288 |
||
289 |
scr columnDescriptors:clDc. |
|
290 |
scr beDependentOfRows:false. |
|
291 |
scr has3Dseparators:true. |
|
292 |
||
293 |
top openAndWait. |
|
294 |
tmArr := Array new:4. |
|
295 |
listModel := List new. |
|
296 |
scr listHolder:listModel. |
|
297 |
||
298 |
(1 to:tmArr size) do:[:i| |
|
299 |
listModel removeAll. |
|
300 |
||
301 |
t1 := Time millisecondsToRun:[ |
|
302 |
1 to:200 do:[:i| |values| |
|
303 |
listModel add:nil. |
|
304 |
i even ifTrue:[ |
|
305 |
listModel removeFirst |
|
306 |
] |
|
307 |
] |
|
308 |
]. |
|
309 |
tmArr at:i put:t1 |
|
310 |
]. |
|
311 |
t1 := 0. |
|
312 |
||
313 |
Transcript showCR:'----------'. |
|
314 |
tmArr do:[:t| |
|
315 |
t1 := t1 + t. |
|
316 |
Transcript showCR:'TIME : ', t printString. |
|
317 |
]. |
|
318 |
Transcript showCR:'----------'. |
|
319 |
Transcript showCR:'DIFF : ', (t1 // tmArr size) printString. |
|
320 |
[exEnd] |
|
321 |
||
322 |
||
323 |
||
324 |
example 7: images as label |
|
542 | 325 |
[exBegin] |
326 |
||
327 |
|lbl top scr clDc rows slct list idx bool| |
|
328 |
||
329 |
top := StandardSystemView new label:'select'; extent:400@440. |
|
330 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
331 |
||
332 |
clDc := OrderedCollection new. |
|
333 |
rows := OrderedCollection new. |
|
334 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ). |
|
335 |
slct := #( #text #field #cbox #clist #toggle #choices ). |
|
336 |
idx := 11. |
|
337 |
bool := true. |
|
338 |
||
339 |
20 timesRepeat:[ |values| |
|
340 |
values := list collect:[:n| |
|
341 |
n isString ifTrue:[n, idx printString] |
|
342 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
343 |
]. |
|
344 |
rows add:(Structure newWith:slct values:values). |
|
345 |
bool := bool not. |
|
346 |
idx := idx + 1. |
|
347 |
]. |
|
348 |
lbl := Image fromFile:('gifImages/nexthand.gif' ). |
|
349 |
||
350 |
clDc add:( DataSetColumnSpec label:lbl editorType:#None selector:#text ). |
|
351 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
352 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ). |
|
353 |
||
354 |
lbl := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ). |
|
355 |
clDc add:( DataSetColumnSpec label:lbl editorType:#ComboBox selector:#cbox ). |
|
356 |
clDc last choices:#choices. |
|
357 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
358 |
clDc last choices:#choices. |
|
359 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
360 |
||
607 | 361 |
scr has3Dseparators:true. |
542 | 362 |
scr columnDescriptors:clDc. |
363 |
scr list:rows. |
|
364 |
top open. |
|
365 |
[exEnd] |
|
366 |
||
367 |
||
368 |
||
369 |
" |
|
370 |
! ! |
|
371 |
||
824 | 372 |
!DataSetView class methodsFor:'test'! |
373 |
||
374 |
test |
|
1187 | 375 |
|top scr clDc rows slct list bool spc img model idx size| |
824 | 376 |
|
377 |
top := StandardSystemView new label:'select'; extent:600@500. |
|
378 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
379 |
||
380 |
clDc := OrderedCollection new. |
|
381 |
rows := OrderedCollection new. |
|
382 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ). |
|
383 |
slct := #( #text #field #cbox #clist #toggle #choices ). |
|
384 |
bool := true. |
|
385 |
||
386 |
10 to:30 do:[:i| |values| |
|
387 |
values := list collect:[:n| |
|
388 |
n isString ifTrue:[n, i printString] |
|
389 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
390 |
]. |
|
391 |
rows add:(Structure newWith:slct values:values). |
|
392 |
bool := bool not. |
|
393 |
]. |
|
394 |
clDc add:( spc := DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
395 |
spc labelAlignment:#left. |
|
396 |
||
397 |
img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ). |
|
398 |
clDc add:( spc := DataSetColumnSpec label:img editorType:#None selector:#text ). |
|
399 |
spc labelAlignment:#right. |
|
400 |
||
401 |
img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ). |
|
402 |
clDc add:( spc := DataSetColumnSpec label:img editorType:#InputField selector:#field ). |
|
403 |
spc labelAlignment:#left. |
|
404 |
||
405 |
img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ). |
|
406 |
clDc add:( spc := DataSetColumnSpec label:(LabelAndIcon icon:img string:'Combo') editorType:#ComboBox selector:#cbox ). |
|
407 |
spc labelAlignment:#center. |
|
408 |
spc choices:#choices. |
|
409 |
||
410 |
clDc add:( spc := DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
411 |
spc choices:#choices. |
|
412 |
clDc add:( spc := DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
413 |
clDc do:[:el| |
|
414 |
el minWidth:80. |
|
415 |
el labelActionSelector:#dummy. |
|
416 |
]. |
|
417 |
scr has3Dseparators:true. |
|
1187 | 418 |
model := ValueHolder new. |
419 |
model value:clDc. |
|
420 |
scr columnHolder:model. |
|
421 |
"/ scr columnDescriptors:clDc. |
|
824 | 422 |
scr list:rows. |
423 |
top open. |
|
1187 | 424 |
Delay waitForSeconds:1. |
824 | 425 |
|
1187 | 426 |
idx := 1. |
427 |
size := clDc size. |
|
428 |
||
429 |
[top shown] whileTrue:[|coll| |
|
430 |
"/ coll := OrderedCollection new:size. |
|
431 |
"/ clDc keysAndValuesDo:[:i :c| |
|
432 |
"/ i ~~ idx ifTrue:[coll add:c] |
|
433 |
"/ ]. |
|
434 |
"/ idx == size ifTrue:[idx := 1] |
|
435 |
"/ ifFalse:[idx := idx + 1]. |
|
436 |
"/ model value:coll. |
|
437 |
"/ Delay waitForSeconds:0.5. |
|
438 |
scr showLabels:(scr showLabels not). |
|
439 |
Delay waitForSeconds:2. |
|
440 |
||
441 |
]. |
|
442 |
Transcript showCR:'READY'. |
|
824 | 443 |
|
1483 | 444 |
! |
445 |
||
446 |
test2 |
|
447 |
" |
|
448 |
self test2 |
|
449 |
" |
|
450 |
|t1 top scr clDc rows slct list bool tmArr listModel| |
|
451 |
||
452 |
top := StandardSystemView new label:'select'; extent:600@440. |
|
453 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
454 |
||
455 |
clDc := OrderedCollection new. |
|
456 |
rows := OrderedCollection new. |
|
457 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true ). |
|
458 |
slct := #( #text #field #cbox #clist #toggle ). |
|
459 |
bool := true. |
|
460 |
||
461 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
462 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ). |
|
463 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ). |
|
464 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
465 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
466 |
||
467 |
scr columnDescriptors:clDc. |
|
468 |
scr beDependentOfRows:false. |
|
469 |
scr has3Dseparators:false. |
|
470 |
||
471 |
top openAndWait. |
|
472 |
tmArr := Array new:1. |
|
473 |
listModel := List new. |
|
474 |
scr listHolder:listModel. |
|
475 |
||
476 |
(1 to:tmArr size) do:[:i| |
|
477 |
listModel removeAll. |
|
478 |
||
479 |
t1 := Time millisecondsToRun:[ |
|
480 |
1 to:30 do:[:i| |values| |
|
481 |
values := list collect:[:n| |
|
482 |
n isString ifTrue:[n, i printString] |
|
483 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
484 |
]. |
|
485 |
listModel add:(Structure newWith:slct values:values). |
|
486 |
bool := bool not. |
|
487 |
i even ifTrue:[ |
|
488 |
listModel removeFirst |
|
489 |
]. |
|
490 |
Delay waitForSeconds:0.5. |
|
491 |
]. |
|
492 |
]. |
|
493 |
tmArr at:i put:t1 |
|
494 |
]. |
|
495 |
t1 := 0. |
|
496 |
||
497 |
Transcript showCR:'----------'. |
|
498 |
tmArr do:[:t| |
|
499 |
t1 := t1 + t. |
|
500 |
Transcript showCR:'TIME : ', t printString. |
|
501 |
]. |
|
502 |
Transcript showCR:'----------'. |
|
503 |
Transcript showCR:'DIFF : ', (t1 // tmArr size) printString. |
|
504 |
||
824 | 505 |
! ! |
506 |
||
542 | 507 |
!DataSetView methodsFor:'accessing'! |
508 |
||
637 | 509 |
add:aRow |
510 |
"add a row; reimplemented caused by add in base class |
|
511 |
" |
|
512 |
^ columnView add:aRow |
|
513 |
! |
|
514 |
||
885 | 515 |
columnView |
516 |
"returns my scrolledView |
|
517 |
" |
|
518 |
^ columnView |
|
519 |
! |
|
520 |
||
521 |
labelView |
|
522 |
^ labelView |
|
523 |
! |
|
524 |
||
833 | 525 |
scrolledView |
526 |
"returns my scrolledView |
|
527 |
" |
|
528 |
^ columnView |
|
529 |
! |
|
530 |
||
542 | 531 |
useIndex |
637 | 532 |
"specify, if the selected components value or its index in the |
533 |
list should be sent to the model. The default is its index. |
|
534 |
" |
|
542 | 535 |
^ useIndex |
536 |
! |
|
537 |
||
538 |
useIndex:aBool |
|
637 | 539 |
"specify, if the selected components value or its index in the |
540 |
list should be sent to the model. The default is its index. |
|
541 |
" |
|
542 | 542 |
useIndex := aBool |
543 |
! ! |
|
544 |
||
700 | 545 |
!DataSetView methodsFor:'accessing look'! |
546 |
||
547 |
font:aFont |
|
548 |
"set the font for all rows and labels. |
|
549 |
" |
|
550 |
columnView font:aFont |
|
551 |
! |
|
552 |
||
553 |
horizontalMini:aBool |
|
554 |
"control the horizontal scrollBar to be either a miniScroller, |
|
555 |
or a full scrollBar. |
|
556 |
" |
|
557 |
scrolledView horizontalMini:aBool. |
|
824 | 558 |
self columnsSizeChanged. |
700 | 559 |
! |
560 |
||
561 |
horizontalScrollable:aBool |
|
562 |
"enable/disable horizontal scrollability. |
|
563 |
If disabled, the horizontal scrollBar is made invisible. |
|
564 |
" |
|
565 |
scrolledView horizontalScrollable:aBool. |
|
824 | 566 |
self columnsSizeChanged. |
700 | 567 |
! |
568 |
||
569 |
isHorizontalScrollable |
|
570 |
"returns true if horizontal scrollable |
|
571 |
" |
|
572 |
^ scrolledView isHorizontalScrollable |
|
573 |
! |
|
574 |
||
575 |
isVerticalScrollable |
|
576 |
"returns true if vertical scrollable |
|
577 |
" |
|
578 |
^ scrolledView isVerticalScrollable |
|
579 |
! |
|
580 |
||
1187 | 581 |
showLabels |
582 |
"control the labels view to be visible or unvisible |
|
583 |
" |
|
584 |
^ labelView notNil |
|
585 |
||
586 |
! |
|
587 |
||
588 |
showLabels:aState |
|
589 |
"control the labels view to be visible or unvisible |
|
590 |
" |
|
591 |
|saveLabel| |
|
592 |
||
593 |
labelView isNil ifTrue:[ |
|
594 |
aState ifTrue:[ |
|
595 |
labelView := DSVLabelView origin:(0.0 @ 0.0) corner:(1.0 @ 0.0) in:self. |
|
596 |
labelView for:columnView. |
|
597 |
||
598 |
self shown ifTrue:[ |
|
599 |
labelView realize |
|
600 |
]. |
|
601 |
columnView columnDescriptors:(columnView columnDescriptors). |
|
602 |
] |
|
603 |
] ifFalse:[ |
|
604 |
aState ifFalse:[ |
|
605 |
saveLabel := labelView. |
|
606 |
labelView := nil. |
|
607 |
saveLabel destroy. |
|
608 |
scrolledView topInset:0 |
|
609 |
] |
|
610 |
]. |
|
611 |
||
612 |
! |
|
613 |
||
700 | 614 |
verticalMini:aBool |
615 |
"control the vertical scrollBar to be either a miniScroller, |
|
616 |
or a full scrollBar. |
|
617 |
" |
|
618 |
scrolledView verticalMini:aBool. |
|
824 | 619 |
self columnsSizeChanged. |
700 | 620 |
|
621 |
! |
|
622 |
||
623 |
verticalScrollable:aBool |
|
624 |
"enable/disable vertical scrollability. |
|
625 |
If disabled, the horizontal scrollBar is made invisible. |
|
626 |
" |
|
627 |
scrolledView verticalScrollable:aBool. |
|
824 | 628 |
self columnsSizeChanged |
700 | 629 |
! |
630 |
||
631 |
viewBackground |
|
632 |
"get the background color of the rows and labels |
|
633 |
" |
|
634 |
^ columnView backgroundColor. |
|
635 |
||
636 |
||
637 |
! |
|
638 |
||
639 |
viewBackground:aColor |
|
640 |
"set the background color of the rows and labels |
|
641 |
" |
|
642 |
^ columnView backgroundColor:aColor. |
|
643 |
||
644 |
||
645 |
! ! |
|
646 |
||
542 | 647 |
!DataSetView methodsFor:'accessing menus'! |
648 |
||
649 |
menuHolder:anObject |
|
650 |
"set the menu holder in the column view too |
|
651 |
" |
|
652 |
super menuHolder:anObject. |
|
653 |
columnView menuHolder:anObject. |
|
654 |
||
655 |
! |
|
656 |
||
657 |
menuMessage:aSymbol |
|
658 |
"set the menu message in the column view too |
|
659 |
" |
|
660 |
super menuMessage:aSymbol. |
|
661 |
columnView menuMessage:aSymbol. |
|
662 |
||
663 |
! |
|
664 |
||
665 |
menuPerformer:anObject |
|
666 |
"set the performer in the column view too |
|
667 |
" |
|
668 |
super menuPerformer:anObject. |
|
669 |
columnView menuPerformer:anObject. |
|
670 |
||
671 |
! ! |
|
672 |
||
637 | 673 |
!DataSetView methodsFor:'accessing mvc'! |
542 | 674 |
|
1012
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
675 |
columnAdaptor |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
676 |
^ columnView columnAdaptor |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
677 |
|
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
678 |
"Modified: / 26.7.1998 / 12:16:17 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
679 |
"Created: / 27.7.1998 / 09:50:58 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
680 |
! |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
681 |
|
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
682 |
columnAdaptor:someone |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
683 |
columnView columnAdaptor:someone |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
684 |
|
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
685 |
"Created: / 26.7.1998 / 12:04:31 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
686 |
"Modified: / 26.7.1998 / 12:16:17 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
687 |
! |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
688 |
|
1066
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
689 |
listAt:index put:newElement |
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
690 |
"kludge callback, when an element hs to be replaced |
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
691 |
due to a col-adaptor returning a new row element" |
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
692 |
|
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
693 |
listHolder value at:index put:newElement |
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
694 |
|
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
695 |
"Created: / 7.8.1998 / 22:18:11 / cg" |
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
696 |
"Modified: / 7.8.1998 / 22:21:00 / cg" |
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
697 |
! |
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
698 |
|
542 | 699 |
listHolder:aListHolder |
637 | 700 |
"set the valueHolder which holds the list of rows |
542 | 701 |
" |
611 | 702 |
listHolder ~~ aListHolder ifTrue:[ |
703 |
listHolder notNil ifTrue:[ |
|
704 |
listHolder removeDependent:self |
|
705 |
]. |
|
706 |
||
707 |
(listHolder := aListHolder) notNil ifTrue:[ |
|
708 |
listHolder addDependent:self |
|
709 |
] |
|
542 | 710 |
]. |
1200 | 711 |
columnView pushEvent:#list: with:(listHolder value). |
542 | 712 |
! |
713 |
||
714 |
model:aModel |
|
637 | 715 |
"set the valueHolder which holds the selection and maybe the list of rows |
542 | 716 |
" |
717 |
(model respondsTo:#list) ifTrue:[ |
|
718 |
(model list == listHolder) ifTrue:[ |
|
719 |
self listHolder:nil |
|
720 |
] |
|
721 |
]. |
|
722 |
super model:aModel. |
|
723 |
||
724 |
aModel notNil ifTrue:[ |
|
725 |
(aModel respondsTo:#list) ifTrue:[ |
|
726 |
self listHolder:model list |
|
727 |
] |
|
728 |
] |
|
637 | 729 |
! ! |
730 |
||
700 | 731 |
!DataSetView methodsFor:'change & update'! |
637 | 732 |
|
824 | 733 |
columnsSizeChanged |
734 |
"recompute label view |
|
735 |
" |
|
736 |
|pL pR| |
|
737 |
||
1187 | 738 |
(realized and:[labelView notNil]) ifFalse:[ |
824 | 739 |
^ self |
740 |
]. |
|
741 |
pL := device translatePoint:(0@0) from:(columnView id) to:(self id). |
|
742 |
pR := device translatePoint:((columnView width) @ 0) from:(columnView id) to:(self id). |
|
743 |
||
744 |
labelView leftInset:pL x - 1. |
|
745 |
labelView rightInset:(self width - pR x). |
|
1389
3548d53b14ae
set the contained dataSetView to not shown when calling
Claus Gittinger <cg@exept.de>
parents:
1326
diff
changeset
|
746 |
labelView columnsSizeChanged. |
824 | 747 |
|
748 |
scrolledView topInset:(labelView height). |
|
749 |
||
750 |
! |
|
751 |
||
542 | 752 |
update:what with:aPara from:chgObj |
753 |
"one of my models changed |
|
754 |
" |
|
1314
c98924f94a97
list change notification #at:
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
755 |
|val idx| |
542 | 756 |
|
637 | 757 |
chgObj == columnView ifTrue:[ |
647 | 758 |
what == #selection ifTrue:[ |
759 |
model notNil ifTrue:[ |
|
759 | 760 |
val := columnView selectedRowIndex copy. |
647 | 761 |
|
762 |
(model respondsTo:#selectionIndex:) ifTrue:[ |
|
763 |
model selectionIndex:val |
|
764 |
] ifFalse:[ |
|
765 |
useIndex ifFalse:[ model value:(columnView selectedRow) ] |
|
766 |
ifTrue:[ model value:val ] |
|
767 |
] |
|
768 |
]. |
|
769 |
^ self |
|
770 |
]. |
|
1187 | 771 |
|
772 |
(realized and:[labelView notNil]) ifTrue:[ |
|
824 | 773 |
what == #sizeOfColumns ifTrue:[ ^ self columnsSizeChanged ]. |
774 |
what == #columnsLayout ifTrue:[ ^ labelView columnsLayoutChanged ]. |
|
775 |
what == #originOfContents ifTrue:[ ^ labelView columnsOriginChanged:aPara ]. |
|
776 |
]. |
|
647 | 777 |
^ self |
637 | 778 |
]. |
779 |
||
780 |
chgObj == model ifTrue:[ |
|
781 |
(what == #selectionIndex or:[what == #selection]) ifTrue:[ |
|
759 | 782 |
^ columnView selectRowIndex:(model selectionIndex copy) |
637 | 783 |
]. |
784 |
what == #list ifTrue:[ |
|
785 |
^ self listHolder:model list |
|
786 |
]. |
|
787 |
model == listHolder ifFalse:[ |
|
788 |
what == #value ifTrue:[ |
|
789 |
columnView selectRowIndex:model value |
|
542 | 790 |
]. |
637 | 791 |
^ self |
542 | 792 |
]. |
637 | 793 |
]. |
794 |
||
795 |
"/ listHolder and model could be the same |
|
542 | 796 |
|
637 | 797 |
chgObj == listHolder ifTrue:[ |
798 |
what == #at: ifTrue:[ |
|
1314
c98924f94a97
list change notification #at:
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
799 |
idx := aPara isCollection ifTrue:[aPara at:1] |
c98924f94a97
list change notification #at:
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
800 |
ifFalse:[aPara]. |
c98924f94a97
list change notification #at:
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
801 |
|
c98924f94a97
list change notification #at:
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
802 |
columnView at:aPara put:(listHolder at:idx) |
637 | 803 |
] ifFalse:[ |
714 | 804 |
(what isNil or:[what == #list or:[what == #size or:[what == #value]]]) ifTrue:[ |
637 | 805 |
^ self listHolder:listHolder "/ reread list from model |
806 |
]. |
|
862 | 807 |
what == #selectionIndex ifTrue:[ |
808 |
^ self |
|
809 |
]. |
|
637 | 810 |
self perform:what with:aPara |
811 |
] |
|
542 | 812 |
]. |
808 | 813 |
! ! |
814 |
||
637 | 815 |
!DataSetView methodsFor:'change & update list'! |
542 | 816 |
|
817 |
insert:anIndex |
|
818 |
"raised from listHolder: insert row derived from listHolder at anIndex |
|
819 |
" |
|
820 |
|list| |
|
821 |
||
822 |
list := listHolder value. |
|
823 |
columnView add:(list at:anIndex) beforeIndex:anIndex |
|
824 |
||
825 |
||
826 |
! |
|
827 |
||
828 |
insertCollection:anArray |
|
829 |
"raised from listHolder: insert collection of rows derived from listHolder |
|
830 |
from start (anArray at:1) to stop (anArray at:2). |
|
831 |
" |
|
570 | 832 |
|start stop size list| |
542 | 833 |
|
834 |
list := listHolder value. |
|
862 | 835 |
start := anArray at:1. |
836 |
size := anArray at:2. |
|
542 | 837 |
|
611 | 838 |
size ~~ 0 ifTrue:[ |
839 |
stop := start + size - 1. |
|
840 |
columnView addAll:(list copyFrom:start to:stop) beforeIndex:start |
|
841 |
] |
|
542 | 842 |
! |
843 |
||
844 |
remove:anIndex |
|
845 |
"raised from listHolder: remove row at anIndex |
|
846 |
" |
|
847 |
columnView removeIndex:anIndex |
|
848 |
||
849 |
||
850 |
! |
|
851 |
||
852 |
removeFrom:anArray |
|
853 |
"raised from listHolder: remove rows from start (anArray at:1) |
|
854 |
to stop (anArray at:2). |
|
855 |
" |
|
619 | 856 |
listHolder value size == 0 ifTrue:[ |
542 | 857 |
columnView list:nil |
858 |
] ifFalse:[ |
|
862 | 859 |
columnView removeFrom:(anArray at:1) to:(anArray at:2) |
542 | 860 |
] |
861 |
! |
|
862 |
||
863 |
replace:anArray |
|
864 |
"raised from listHolder: replace collection of rows derived from listHolder |
|
865 |
from start (anArray at:1) to stop (anArray at:2). |
|
866 |
" |
|
867 |
|start stop list| |
|
868 |
||
862 | 869 |
start := anArray at:1. |
870 |
stop := anArray at:2. |
|
542 | 871 |
list := listHolder value. |
872 |
||
873 |
start to:stop do:[:anIndex| |
|
874 |
columnView at:anIndex put:(list at:anIndex) |
|
875 |
]. |
|
876 |
||
877 |
! ! |
|
878 |
||
879 |
!DataSetView methodsFor:'error handling'! |
|
880 |
||
881 |
doesNotUnderstand:aMessage |
|
637 | 882 |
"does not understand message; delegate to column view |
883 |
" |
|
542 | 884 |
^ aMessage sendTo:columnView |
885 |
! ! |
|
886 |
||
1326 | 887 |
!DataSetView methodsFor:'initialize / release'! |
542 | 888 |
|
889 |
destroy |
|
890 |
"remove dependencies |
|
891 |
" |
|
892 |
listHolder notNil ifTrue:[ |
|
893 |
listHolder removeDependent:self |
|
894 |
]. |
|
637 | 895 |
columnView removeDependent:self. |
896 |
||
542 | 897 |
super destroy |
898 |
||
899 |
||
900 |
||
901 |
! |
|
902 |
||
903 |
initialize |
|
904 |
"set column area |
|
905 |
" |
|
906 |
super initialize. |
|
907 |
||
700 | 908 |
scrolledView := HVScrollableView for:DSVColumnView |
542 | 909 |
miniScrollerH:true |
910 |
miniScrollerV:false |
|
911 |
origin:(0.0 @ 0.0) |
|
912 |
corner:(1.0 @ 1.0) |
|
913 |
in:self. |
|
914 |
||
637 | 915 |
useIndex := true. |
700 | 916 |
columnView := scrolledView scrolledView. |
637 | 917 |
|
542 | 918 |
columnView borderWidth:0. |
919 |
columnView addDependent:self. |
|
1066
c588ca20e4b4
pass myself down to the columnView, to give it access
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
920 |
columnView dataSetView:self. "/ kludge |
1187 | 921 |
self showLabels:true. |
542 | 922 |
! |
923 |
||
924 |
realize |
|
637 | 925 |
"realize view; update labels |
926 |
" |
|
715 | 927 |
|selection| |
928 |
||
929 |
selection := 0. |
|
930 |
||
931 |
model notNil ifTrue:[ |
|
932 |
(model respondsTo:#selectionIndex) ifTrue:[ |
|
933 |
selection := model selectionIndex |
|
934 |
] ifFalse:[ |
|
935 |
model == listHolder ifFalse:[ |
|
936 |
selection := model value |
|
937 |
] |
|
938 |
] |
|
939 |
]. |
|
940 |
columnView selectRowIndex:selection. |
|
542 | 941 |
super realize. |
1389
3548d53b14ae
set the contained dataSetView to not shown when calling
Claus Gittinger <cg@exept.de>
parents:
1326
diff
changeset
|
942 |
columnView instVarNamed:'shown' put:false. |
824 | 943 |
self columnsSizeChanged. |
1389
3548d53b14ae
set the contained dataSetView to not shown when calling
Claus Gittinger <cg@exept.de>
parents:
1326
diff
changeset
|
944 |
columnView instVarNamed:'shown' put:true. |
3548d53b14ae
set the contained dataSetView to not shown when calling
Claus Gittinger <cg@exept.de>
parents:
1326
diff
changeset
|
945 |
|
542 | 946 |
! ! |
947 |
||
948 |
!DataSetView methodsFor:'queries'! |
|
949 |
||
950 |
specClass |
|
637 | 951 |
"returns my spec class |
952 |
" |
|
542 | 953 |
^ DataSetSpec |
954 |
! ! |
|
955 |
||
956 |
!DataSetView class methodsFor:'documentation'! |
|
957 |
||
958 |
version |
|
1483 | 959 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetView.st,v 1.29 1999-08-20 16:40:01 cg Exp $' |
542 | 960 |
! ! |