author | Claus Gittinger <cg@exept.de> |
Wed, 13 May 2009 13:23:32 +0200 | |
changeset 2675 | a68038b7c4c3 |
parent 2622 | aae1c83162bc |
child 2743 | e4b1622a4d1a |
permissions | -rw-r--r-- |
75 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
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 |
" |
|
1397 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
75 | 14 |
ValueModel subclass:#PluggableAdaptor |
223 | 15 |
instanceVariableNames:'model getBlock putBlock updateBlock' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Support-Models' |
|
75 | 19 |
! |
20 |
||
21 |
!PluggableAdaptor class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
Allows forwarding of value/value:/change messages via blocks. |
|
40 |
Kind of what ST/X always did .... |
|
41 |
||
42 |
PluggableAdaptor is the most general of the adaptor models - |
|
43 |
any other adapter can be simulated. However, they incur certain |
|
82 | 44 |
overhead and complexity. |
45 |
Therefore, in many situations, an AspectAdaptor is the better choice. |
|
223 | 46 |
|
231 | 47 |
Notice: |
48 |
this class was implemented using protocol information |
|
49 |
from alpha testers - it may not be complete or compatible to |
|
50 |
the corresponding ST-80 class. |
|
51 |
If you encounter any incompatibilities, please forward a note |
|
52 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
53 |
||
223 | 54 |
[author:] |
55 |
Claus Gittinger |
|
76 | 56 |
" |
57 |
! |
|
75 | 58 |
|
76 | 59 |
examples |
60 |
" |
|
61 |
an adaptor for the variable x: |
|
231 | 62 |
[exBegin] |
63 |
|m x t| |
|
75 | 64 |
|
231 | 65 |
m := (PluggableAdaptor new) |
66 |
getBlock:[:m | x] |
|
268 | 67 |
putBlock:[:m :newValue | x := newValue. Transcript showCR:x] |
68 |
updateBlock:[:m :aspect :param | Transcript showCR:'changed']. |
|
231 | 69 |
t := Toggle new. |
70 |
t model:m. |
|
71 |
t label:'toggle me'. |
|
72 |
t open. |
|
73 |
[exEnd] |
|
75 | 74 |
|
75 |
||
76 | 76 |
an adaptor to send #destroy: |
231 | 77 |
[exBegin] |
78 |
|m t| |
|
75 | 79 |
|
231 | 80 |
m := (PluggableAdaptor new) |
81 |
getBlock:[:m | false] |
|
82 |
putBlock:[:m :newValue | t destroy] |
|
83 |
updateBlock:[:m :aspect :param | ]. |
|
84 |
t := Button new. |
|
85 |
t model:m. |
|
86 |
t label:'close me'. |
|
87 |
t open. |
|
88 |
[exEnd] |
|
75 | 89 |
|
90 |
||
91 |
as above, more convenient setup: |
|
231 | 92 |
[exBegin] |
93 |
|m t| |
|
75 | 94 |
|
231 | 95 |
t := Button new. |
75 | 96 |
|
231 | 97 |
m := (PluggableAdaptor on:t) performAction:#destroy. |
98 |
t model:m. |
|
99 |
t label:'close me'. |
|
100 |
t open. |
|
101 |
[exEnd] |
|
75 | 102 |
|
103 |
extract values from a complex model: |
|
231 | 104 |
[exBegin] |
105 |
|model dialog name pId| |
|
75 | 106 |
|
231 | 107 |
model := Plug new. |
108 |
model respondTo:#name with:[name]. |
|
109 |
model respondTo:#name: with:[:newValue | name := newValue]. |
|
110 |
model respondTo:#passportId with:[pId]. |
|
111 |
model respondTo:#passportId: with:[:newValue | pId := newValue]. |
|
112 |
name := 'John Smith'. |
|
113 |
pId := 56785432. |
|
75 | 114 |
|
231 | 115 |
dialog := Dialog new. |
116 |
||
117 |
dialog addInputFieldOn:((PluggableAdaptor on:model) |
|
118 |
getBlock:[:m | m name] |
|
119 |
putBlock:[:m :v | m name:v] |
|
120 |
updateBlock:[:m :a :p | false]). |
|
75 | 121 |
|
231 | 122 |
dialog addVerticalSpace. |
75 | 123 |
|
231 | 124 |
dialog addInputFieldOn:((PluggableAdaptor on:model) |
125 |
getBlock:[:m | m passportId printString] |
|
126 |
putBlock:[:m :v | m passportId:v asNumber] |
|
127 |
updateBlock:[:m :a :p | false]). |
|
128 |
dialog addAbortButton; addOkButton. |
|
129 |
dialog width:200; sizeFixed:true. |
|
130 |
dialog open. |
|
75 | 131 |
|
231 | 132 |
dialog accept value ifTrue:[ |
268 | 133 |
Transcript showCR:'accepted.'. |
231 | 134 |
]. |
268 | 135 |
Transcript showCR:' Name: ' , model name. |
136 |
Transcript showCR:' ID : ' , model passportId printString. |
|
231 | 137 |
[exEnd] |
138 |
||
75 | 139 |
|
140 |
||
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
141 |
extract values from an association into different labels: |
231 | 142 |
[exBegin] |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
143 |
|assoc t l| |
82 | 144 |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
145 |
assoc := 'hello' -> 'world'. |
82 | 146 |
|
231 | 147 |
t := HorizontalPanelView new. |
148 |
t extent:200@50. |
|
149 |
t horizontalLayout:#fitSpace. |
|
82 | 150 |
|
231 | 151 |
l := Label in:t. |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
152 |
l model:((PluggableAdaptor on:assoc) getSelector:#key putSelector:#key:); |
231 | 153 |
labelMessage:#value; aspect:#value; |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
154 |
level:-1. |
231 | 155 |
l := Label in:t. |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
156 |
l model:((PluggableAdaptor on:assoc) getSelector:#value putSelector:#value:); |
231 | 157 |
labelMessage:#value; aspect:#value; |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
158 |
level:-1. |
231 | 159 |
t open. |
82 | 160 |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
161 |
(Delay forSeconds:3) wait. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
162 |
assoc key:'goodbye'. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
163 |
assoc changed. |
231 | 164 |
[exEnd] |
82 | 165 |
|
166 |
extract values from an array into different labels: |
|
231 | 167 |
[exBegin] |
168 |
|a t l| |
|
75 | 169 |
|
231 | 170 |
a := #('one' 'two' 'three'). |
75 | 171 |
|
231 | 172 |
t := HorizontalPanelView new. |
173 |
t extent:200@50. |
|
174 |
t horizontalLayout:#fitSpace. |
|
75 | 175 |
|
231 | 176 |
l := Label in:t. |
177 |
l model:((PluggableAdaptor on:a) collectionIndex:1); |
|
178 |
labelMessage:#value; aspect:#value; |
|
179 |
level:-1; |
|
180 |
sizeFixed:true. |
|
181 |
l := Label in:t. |
|
182 |
l model:((PluggableAdaptor on:a) collectionIndex:2); |
|
183 |
labelMessage:#value; aspect:#value; |
|
184 |
level:-1; |
|
185 |
sizeFixed:true. |
|
186 |
l := Label in:t. |
|
187 |
l model:((PluggableAdaptor on:a) collectionIndex:3); |
|
188 |
labelMessage:#value; aspect:#value; |
|
189 |
level:-1; |
|
190 |
sizeFixed:true. |
|
191 |
t open. |
|
75 | 192 |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
193 |
(Delay forSeconds:3) wait. |
231 | 194 |
a at:1 put:'1'. |
195 |
a changed. |
|
196 |
[exEnd] |
|
75 | 197 |
" |
198 |
! ! |
|
199 |
||
200 |
!PluggableAdaptor class methodsFor:'instance creation'! |
|
201 |
||
202 |
on:anObject |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
203 |
"create & return a new protocolAdaptor. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
204 |
Any get/put and updateBlocks are still to be defined" |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
205 |
|
75 | 206 |
^ self new model:anObject |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
207 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
208 |
"Modified: 21.2.1997 / 18:31:22 / cg" |
75 | 209 |
! ! |
210 |
||
125 | 211 |
!PluggableAdaptor methodsFor:'accessing'! |
75 | 212 |
|
2622 | 213 |
getBlock |
214 |
^ getBlock |
|
215 |
! |
|
216 |
||
217 |
putBlock |
|
218 |
^ putBlock |
|
219 |
! |
|
220 |
||
125 | 221 |
setValue:newValue |
222 |
putBlock notNil ifTrue:[ |
|
223 |
^ putBlock value:model value:newValue |
|
75 | 224 |
]. |
125 | 225 |
model value:newValue "/ stupid default |
75 | 226 |
! |
227 |
||
2622 | 228 |
updateBlock |
229 |
^ updateBlock |
|
230 |
! |
|
231 |
||
125 | 232 |
value |
233 |
getBlock notNil ifTrue:[ |
|
234 |
^ getBlock value:model |
|
235 |
]. |
|
236 |
^ model value "/ stupid default |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
237 |
! |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
238 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
239 |
valueUsingSubject:someObject |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
240 |
someObject isNil ifTrue:[^ nil]. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
241 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
242 |
^ getBlock value:someObject |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
243 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
244 |
"Created: 21.2.1997 / 18:28:35 / cg" |
125 | 245 |
! ! |
75 | 246 |
|
1397 | 247 |
!PluggableAdaptor methodsFor:'change & update'! |
75 | 248 |
|
125 | 249 |
update:something with:aParameter from:changedObject |
250 |
changedObject == model ifTrue:[ |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
251 |
updateBlock notNil ifTrue:[ |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
252 |
(updateBlock value:model value:something value:aParameter) |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
253 |
ifTrue:[ |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
254 |
self changed:#value |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
255 |
] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
256 |
] |
125 | 257 |
]. |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
258 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
259 |
"Modified: 21.2.1997 / 18:28:52 / cg" |
125 | 260 |
! ! |
75 | 261 |
|
1769 | 262 |
!PluggableAdaptor methodsFor:'initialization & release'! |
75 | 263 |
|
264 |
collectionIndex:idx |
|
265 |
"configure the adaptor to translate #value/#value:-messages into |
|
266 |
indexed accesses via #at:/#at:put:, using the supplied index" |
|
267 |
||
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
268 |
getBlock := [:model | model value at:idx]. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
269 |
putBlock := [:model :newValue | model value at:idx put:newValue]. |
75 | 270 |
updateBlock := [:model :aspect :parameter | |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
271 |
aspect isNil or:[aspect == #value] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
272 |
] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
273 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
274 |
"Modified: 21.2.1997 / 18:20:24 / cg" |
75 | 275 |
! |
276 |
||
2619 | 277 |
getBlock:newGetBlock |
278 |
"configure the adaptor to translate #value-messages into |
|
279 |
evaluation of the corresponding block. |
|
280 |
The getBlock argument block1 is called with one argument, the model, and is |
|
281 |
supposed to extract & return a value from that model." |
|
282 |
||
283 |
getBlock := newGetBlock. |
|
284 |
! |
|
285 |
||
2119 | 286 |
getBlock:newGetBlock putBlock:newPutBlock |
287 |
"configure the adaptor to translate #value/#value:-messages into |
|
288 |
evaluation of the corresponding block1/block2. |
|
289 |
The getBlock argument block1 is called with one argument, the model, and is |
|
290 |
supposed to extract & return a value from that model. |
|
291 |
The putBlock argument, block2 is called with 2 arguments, the model |
|
292 |
and the new value, and is supposed to store the new value." |
|
293 |
||
294 |
getBlock := newGetBlock. |
|
295 |
putBlock := newPutBlock. |
|
296 |
! |
|
297 |
||
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
298 |
getBlock:newGetBlock putBlock:newPutBlock updateBlock:newUpdateBlock |
75 | 299 |
"configure the adaptor to translate #value/#value:-messages into |
300 |
evaluation of the corresponding block1/block2. |
|
301 |
The getBlock argument block1 is called with one argument, the model, and is |
|
302 |
supposed to extract & return a value from that model. |
|
303 |
The putBlock argument, block2 is called with 2 arguments, the model |
|
304 |
and the new value, and is supposed to store the new value. |
|
305 |
The updateBlock argument, block3 is called with 3 arguments, the model, |
|
306 |
the aspect as changed in the model and the change parameter. It |
|
307 |
is called when the adaptor receives an update message from the model, |
|
308 |
and should return true if a new value should be fetched from the model." |
|
309 |
||
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
310 |
getBlock := newGetBlock. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
311 |
putBlock := newPutBlock. |
2383 | 312 |
self assert:(newUpdateBlock isNil or:[newUpdateBlock numArgs == 3]). |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
313 |
updateBlock := newUpdateBlock. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
314 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
315 |
"Modified: 21.2.1997 / 18:18:38 / cg" |
125 | 316 |
! |
75 | 317 |
|
125 | 318 |
getSelector:getSelector putSelector:putSelector |
319 |
"configure the adaptor to translate #value-messages into a send of |
|
320 |
getSelector and #value:-messages into sends of putSelector." |
|
75 | 321 |
|
125 | 322 |
getBlock := [:model | model perform:getSelector]. |
323 |
putBlock := [:model :newValue | model perform:putSelector with:newValue]. |
|
324 |
updateBlock := [:model :aspect :parameter | |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
325 |
aspect isNil |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
326 |
or:[aspect == getSelector |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
327 |
or:[aspect == #value]] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
328 |
] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
329 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
330 |
"Modified: 21.2.1997 / 18:21:27 / cg" |
125 | 331 |
! |
332 |
||
333 |
model:anObject |
|
334 |
model notNil ifTrue:[ |
|
335 |
model removeDependent:self |
|
75 | 336 |
]. |
125 | 337 |
model := anObject. |
1127
4565ab2ad23c
dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents:
443
diff
changeset
|
338 |
model notNil ifTrue:[ |
4565ab2ad23c
dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents:
443
diff
changeset
|
339 |
model addDependent:self |
4565ab2ad23c
dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents:
443
diff
changeset
|
340 |
] |
75 | 341 |
! |
342 |
||
125 | 343 |
performAction:aSelector |
344 |
"configure the adaptor to send an aSelector-message to the model |
|
345 |
whenever a new value is stored via #value:" |
|
346 |
||
347 |
getBlock := [:model | nil]. |
|
348 |
putBlock := [:model :newValue | model perform:aSelector]. |
|
349 |
updateBlock := [:model :aspect :parameter | false] |
|
350 |
! |
|
351 |
||
2619 | 352 |
putBlock:newPutBlock |
353 |
"configure the adaptor to translate#value:-messages into |
|
354 |
evaluation of the corresponding block2. |
|
355 |
The putBlock argument, block2 is called with 2 arguments, the model |
|
356 |
and the new value, and is supposed to store the new value." |
|
357 |
||
358 |
putBlock := newPutBlock. |
|
359 |
! |
|
360 |
||
125 | 361 |
selectValue:something |
362 |
"configure the adaptor to behave like a boolean value, returning |
|
363 |
true whenever the models value equals something" |
|
364 |
||
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
365 |
"/ getBlock := [:model | model value = something]. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
366 |
"/ putBlock := [:model :newValue | newValue ifTrue:[model value:something]]. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
367 |
"/ updateBlock := [:model :aspect :parameter | |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
368 |
"/ aspect isNil or:[aspect == #value] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
369 |
"/ ] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
370 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
371 |
"/ changed for vw compatibility |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
372 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
373 |
|lastValue| |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
374 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
375 |
lastValue := nil. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
376 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
377 |
getBlock := [:model | lastValue := (model value = something)]. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
378 |
putBlock := [:model :newValue | newValue |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
379 |
ifTrue:[model value:something] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
380 |
ifFalse:[model value = something |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
381 |
ifTrue:[model value:nil] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
382 |
] |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
383 |
]. |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
384 |
updateBlock := [:model :aspect :parameter | |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
385 |
((model value = something) = lastValue) not |
352
ba7970fbcde2
Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents:
268
diff
changeset
|
386 |
] |
ba7970fbcde2
Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents:
268
diff
changeset
|
387 |
|
ba7970fbcde2
Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents:
268
diff
changeset
|
388 |
"Modified: 31.12.1996 / 13:58:09 / stefan" |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
389 |
"Modified: 21.2.1997 / 18:27:26 / cg" |
125 | 390 |
! |
391 |
||
392 |
subjectChannel:aValueHolder |
|
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
393 |
"setup to use aValueHolder as model" |
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
394 |
|
125 | 395 |
self model:aValueHolder |
443
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
396 |
|
5c57a8861677
st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents:
352
diff
changeset
|
397 |
"Modified: 21.2.1997 / 18:19:46 / cg" |
75 | 398 |
! ! |
399 |
||
129 | 400 |
!PluggableAdaptor class methodsFor:'documentation'! |
401 |
||
402 |
version |
|
2622 | 403 |
^ '$Header: /cvs/stx/stx/libview2/PluggableAdaptor.st,v 1.22 2009-03-31 21:57:34 stefan Exp $' |
129 | 404 |
! ! |