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 |
|
1487
|
16 |
ScrollableView subclass:#DataSetView
|
|
17 |
instanceVariableNames:''
|
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 |
|
1495
|
63 |
top := StandardSystemView new label:'Simple Test'; extent:700@440.
|
611
|
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 |
|
1495
|
92 |
top := StandardSystemView new label:'Row Is Absent'; extent:700@440.
|
619
|
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 |
|
1495
|
119 |
top := StandardSystemView new label:'Editors'; extent:700@440.
|
542
|
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 |
|
1495
|
160 |
top := StandardSystemView new label:'Multiple Select'; extent:700@440.
|
542
|
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 |
|
1495
|
197 |
example 5: Images and Layout
|
542
|
198 |
[exBegin]
|
1495
|
199 |
|top scr columns rows colDesc image text|
|
542
|
200 |
|
1495
|
201 |
text := 'Text'.
|
|
202 |
rows := Array new:1000.
|
542
|
203 |
|
1495
|
204 |
1 to:(rows size) do:[:i|
|
|
205 |
rows at:i put:(Array with:('Id: ', i printString) with:text with:text)
|
|
206 |
].
|
542
|
207 |
|
1495
|
208 |
columns := OrderedCollection new.
|
|
209 |
image := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ).
|
|
210 |
|
|
211 |
colDesc := DataSetColumnSpec label:(LabelAndIcon icon:image string:'Left') selector:#at:.
|
|
212 |
colDesc labelAlignment:#left.
|
|
213 |
colDesc columnAlignment:#left.
|
|
214 |
columns add:colDesc.
|
542
|
215 |
|
1495
|
216 |
colDesc := DataSetColumnSpec label:(LabelAndIcon icon:image string:'Right') selector:#at:.
|
|
217 |
colDesc labelAlignment:#right.
|
|
218 |
colDesc columnAlignment:#right.
|
|
219 |
columns add:colDesc.
|
|
220 |
|
|
221 |
colDesc := DataSetColumnSpec label:(LabelAndIcon icon:image string:'Center') selector:#at:.
|
|
222 |
colDesc labelAlignment:#center.
|
|
223 |
colDesc columnAlignment:#center.
|
|
224 |
columns add:colDesc.
|
542
|
225 |
|
1495
|
226 |
columns do:[:el|el labelActionSelector:#dummy].
|
542
|
227 |
|
1495
|
228 |
top := StandardSystemView new label:'Layout'; extent:500@500.
|
|
229 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
230 |
scr has3Dseparators:true.
|
|
231 |
scr columnDescriptors:columns.
|
|
232 |
scr list:rows.
|
542
|
233 |
|
1495
|
234 |
top open
|
542
|
235 |
[exEnd]
|
|
236 |
|
|
237 |
|
|
238 |
|
1487
|
239 |
example 6: adding and removing
|
|
240 |
[exBegin]
|
|
241 |
|top scr list|
|
|
242 |
|
1495
|
243 |
top := StandardSystemView new label:'Adding & Removing'; extent:600@440.
|
1487
|
244 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
245 |
|
|
246 |
scr columnDescriptors:( Array with:(DataSetColumnSpec label:'FOO' selector:#at:)
|
|
247 |
with:(DataSetColumnSpec label:'BAR' selector:#at:)
|
|
248 |
with:(DataSetColumnSpec label:'BAZ' selector:#at:)
|
|
249 |
).
|
|
250 |
|
|
251 |
scr has3Dseparators:true.
|
|
252 |
scr listHolder:(list := List new).
|
|
253 |
top openAndWait.
|
|
254 |
|
|
255 |
1 to:32 do:[:i| |pid|
|
|
256 |
pid := i printString.
|
|
257 |
list add:(Array with:('foo: ', pid) with:('bar: ', pid) with:('baz: ', pid)).
|
|
258 |
i even ifTrue:[
|
|
259 |
list removeFirst
|
|
260 |
].
|
|
261 |
Delay waitForSeconds:0.1.
|
|
262 |
].
|
|
263 |
[exEnd]
|
|
264 |
|
|
265 |
|
542
|
266 |
"
|
|
267 |
! !
|
|
268 |
|
1326
|
269 |
!DataSetView methodsFor:'initialize / release'!
|
542
|
270 |
|
|
271 |
initialize
|
|
272 |
"set column area
|
|
273 |
"
|
|
274 |
super initialize.
|
|
275 |
|
1487
|
276 |
self setupVertical:true mini:false horizontal:true mini:true.
|
|
277 |
self scrolledView:(DSVColumnView new labelView:(DSVLabelView in:self)).
|
542
|
278 |
! !
|
|
279 |
|
|
280 |
!DataSetView methodsFor:'queries'!
|
|
281 |
|
|
282 |
specClass
|
637
|
283 |
"returns my spec class
|
|
284 |
"
|
542
|
285 |
^ DataSetSpec
|
|
286 |
! !
|
|
287 |
|
|
288 |
!DataSetView class methodsFor:'documentation'!
|
|
289 |
|
|
290 |
version
|
1495
|
291 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetView.st,v 1.31 1999-08-29 16:56:13 cg Exp $'
|
542
|
292 |
! !
|