author | Jan Vrany <jan.vrany@labware.com> |
Tue, 09 Aug 2022 21:18:05 +0100 | |
branch | jv |
changeset 4471 | df7515191c90 |
parent 3614 | 3272e655d847 |
permissions | -rw-r--r-- |
74 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
3 |
COPYRIGHT (c) 2022 LabWare |
74 | 4 |
All Rights Reserved |
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
2286 | 13 |
"{ Package: 'stx:libview2' }" |
74 | 14 |
|
3614 | 15 |
"{ NameSpace: Smalltalk }" |
16 |
||
125 | 17 |
ProtocolAdaptor subclass:#AspectAdaptor |
217 | 18 |
instanceVariableNames:'myAspect getMsg putMsg' |
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Support-Models' |
|
69 | 22 |
! |
23 |
||
24 |
!AspectAdaptor class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
29 |
COPYRIGHT (c) 2022 LabWare |
71 | 30 |
All Rights Reserved |
69 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
43 |
an AspectAdaptor forwards updates and change messages from/to a complex model. |
69 | 44 |
|
45 |
Consider the case where editFields are required for the |
|
789 | 46 |
elements (instance variables) of a compound object: |
238 | 47 |
- without an aspect adaptor, you needed to copy the individual |
48 |
values out-of the object and move these into multiple valueHolders. |
|
49 |
Then, let the editFields modify the valueHolders contents and |
|
50 |
finally, fetch the values and put them back into the compound object. |
|
51 |
||
69 | 52 |
An aspectAdaptor makes this easier, by playing model with |
85 | 53 |
value/value: symbols towards the editField, and forwarding changes and |
789 | 54 |
updates to/from the compound object using different aspect symbols |
238 | 55 |
and access messages. |
69 | 56 |
|
231 | 57 |
Notice: |
58 |
this class was implemented using protocol information |
|
59 |
from alpha testers - it may not be complete or compatible to |
|
60 |
the corresponding ST-80 class. |
|
61 |
If you encounter any incompatibilities, please forward a note |
|
62 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
217 | 63 |
|
223 | 64 |
[author:] |
65 |
Claus Gittinger |
|
66 |
||
217 | 67 |
[see also:] |
68 |
ValueHolder Model |
|
69 | 69 |
" |
70 |
! |
|
71 |
||
72 |
examples |
|
73 |
" |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
74 |
a dialog on a point's x/y coordinates: |
231 | 75 |
[exBegin] |
76 |
|dialog data f| |
|
69 | 77 |
|
231 | 78 |
data := 0@0. |
69 | 79 |
|
231 | 80 |
dialog := DialogBox new. |
81 |
dialog addTextLabel:'x:'. |
|
82 |
f := dialog addInputFieldOn:(AspectAdaptor new |
|
83 |
subject:data; |
|
84 |
accessWith:#x |
|
85 |
assignWith:#x:). |
|
86 |
f converter:(PrintConverter new initForNumber). |
|
69 | 87 |
|
231 | 88 |
dialog addTextLabel:'y:'. |
89 |
f := dialog addInputFieldOn:(AspectAdaptor new |
|
90 |
subject:data; |
|
91 |
forAspect:#y). |
|
92 |
f converter:(PrintConverter new initForNumber). |
|
69 | 93 |
|
231 | 94 |
dialog addOkButton. |
95 |
data inspect. |
|
96 |
dialog open. |
|
69 | 97 |
|
231 | 98 |
dialog accepted ifTrue:[ |
268 | 99 |
Transcript showCR:'data now: ' , data printString |
231 | 100 |
] |
101 |
[exEnd] |
|
69 | 102 |
|
103 |
||
104 |
a dialog on a four-field complex model: |
|
231 | 105 |
[exBegin] |
106 |
|dialog data dataModel| |
|
69 | 107 |
|
231 | 108 |
data := #('hello' 'one' 'two' 'three'). |
109 |
dataModel := Plug new. |
|
110 |
dataModel respondTo:#field1 with:[data at:1]. |
|
111 |
dataModel respondTo:#field2 with:[data at:2]. |
|
112 |
dataModel respondTo:#field3 with:[data at:3]. |
|
113 |
dataModel respondTo:#field4 with:[data at:4]. |
|
114 |
dataModel respondTo:#field1: with:[:arg | data at:1 put:arg]. |
|
115 |
dataModel respondTo:#field2: with:[:arg | data at:2 put:arg]. |
|
116 |
dataModel respondTo:#field3: with:[:arg | data at:3 put:arg]. |
|
117 |
dataModel respondTo:#field4: with:[:arg | data at:4 put:arg]. |
|
69 | 118 |
|
231 | 119 |
dialog := DialogBox new. |
120 |
dialog addTextLabel:'1:'. |
|
121 |
dialog addInputFieldOn:(AspectAdaptor new |
|
122 |
subject:dataModel; |
|
123 |
accessWith:#field1 |
|
124 |
assignWith:#field1:). |
|
125 |
dialog addTextLabel:'2:'. |
|
126 |
dialog addInputFieldOn:(AspectAdaptor new |
|
127 |
subject:dataModel; |
|
128 |
forAspect:#field2). |
|
129 |
dialog addTextLabel:'3:'. |
|
130 |
dialog addInputFieldOn:(AspectAdaptor new |
|
131 |
subject:dataModel; |
|
132 |
accessWith:#field3 |
|
133 |
assignWith:#field3: |
|
134 |
aspect:#field3). |
|
135 |
dialog addTextLabel:'4:'. |
|
136 |
dialog addInputFieldOn:(AspectAdaptor new |
|
137 |
subject:dataModel; |
|
138 |
forAspect:#field4). |
|
139 |
dialog addOkButton. |
|
140 |
dataModel inspect. |
|
141 |
dialog open. |
|
142 |
dialog accepted ifTrue:[ |
|
268 | 143 |
Transcript showCR:'data now: ' , data printString |
231 | 144 |
] |
145 |
[exEnd] |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
146 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
147 |
a dialog on elements of a dictionary: |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
148 |
(notice: the dicationary elements change as soon as a field of the dialog is |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
149 |
left - i.e. I write immediately to the model) |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
150 |
[exBegin] |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
151 |
|dialog data| |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
152 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
153 |
data := JSONObject new |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
154 |
at:'Name' put:'Fritz'; |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
155 |
at:'Tel' put:'1234567'; |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
156 |
at:'City' put:'Stuttgart'; |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
157 |
yourself. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
158 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
159 |
dialog := DialogBox new. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
160 |
dialog addTextLabel:'Name:'. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
161 |
dialog addInputFieldOn:(AspectAdaptor new |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
162 |
subject:data; |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
163 |
accessWith:#Name |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
164 |
assignWith:#Name:). |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
165 |
dialog addTextLabel:'Tel:'. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
166 |
dialog addInputFieldOn:(AspectAdaptor new |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
167 |
subject:data; |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
168 |
forAspect:#Tel). |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
169 |
dialog addTextLabel:'City:'. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
170 |
dialog addInputFieldOn:(AspectAdaptor new |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
171 |
subject:data; |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
172 |
forAspect:#City). |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
173 |
dialog addOkButton. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
174 |
data inspect. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
175 |
dialog open. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
176 |
dialog accepted ifTrue:[ |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
177 |
Transcript showCR:'data now: ' , data printString |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
178 |
] |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
179 |
[exEnd] |
69 | 180 |
" |
181 |
! ! |
|
182 |
||
183 |
!AspectAdaptor class methodsFor:'instance creation'! |
|
184 |
||
185 |
accessWith:getSelector assignWith:putSelector |
|
83 | 186 |
"create and return an adaptor which uses getSelector to fetch a value |
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
187 |
from the subject and setSelector to change it. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
188 |
The returned object can be used in place of a ValueHolder" |
83 | 189 |
|
69 | 190 |
^ (self new) accessWith:getSelector assignWith:putSelector |
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
191 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
192 |
"Modified (comment): / 25-07-2022 / 08:21:28 / cg" |
85 | 193 |
! |
194 |
||
439 | 195 |
forAspect:anAspect |
196 |
"create and return a new adaptor, which forwards requests |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
197 |
to the subject, using anAspect as get-selector and anAspect-colon as putSelector |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
198 |
for access. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
199 |
The returned object can be used in place of a ValueHolder" |
439 | 200 |
|
201 |
^ self new forAspect:anAspect |
|
202 |
||
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
203 |
"Modified: / 22-01-1997 / 12:00:42 / cg" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
204 |
"Modified (comment): / 25-07-2022 / 08:20:55 / cg" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
205 |
! |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
206 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
207 |
forAspect:anAspect subject:anObject |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
208 |
"create and return a new adaptor, which forwards requests |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
209 |
to anObject, using anAspect as get-selector and anAspect-colon as putSelector |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
210 |
for access. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
211 |
The returned object can be used in place of a ValueHolder" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
212 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
213 |
^ (self new forAspect:anAspect) subject:anObject |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
214 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
215 |
"Created: / 25-07-2022 / 08:20:17 / cg" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
216 |
! |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
217 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
218 |
forAspect:anAspect subjectChannel:aSubjectProvider |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
219 |
"create and return a new adaptor, which forwards requests |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
220 |
to the object provided by aSubjectProvider, |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
221 |
accessing the subject via #value from aSubjectProvider. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
222 |
using anAspect as get-selector and anAspect-colon as putSelector for access. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
223 |
The returned object can be used in place of a ValueHolder" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
224 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
225 |
^ (self new forAspect:anAspect) subjectChannel:aSubjectProvider |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
226 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
227 |
"Created: / 25-07-2022 / 08:22:33 / cg" |
439 | 228 |
! |
229 |
||
85 | 230 |
subject:anObject sendsUpdates:aBoolean accessWith:getSel assignWith:putSel aspect:aspect |
379 | 231 |
"create and return a new adaptor, which forwards requests |
232 |
to anObject, using getSel/putSel for access. |
|
233 |
The returned object can be used in place of a ValueHolder" |
|
234 |
||
85 | 235 |
^ (self subject:anObject sendsUpdates:aBoolean) |
379 | 236 |
accessWith:getSel assignWith:putSel aspect:aspect |
237 |
||
238 |
"Modified: 22.1.1997 / 12:00:42 / cg" |
|
69 | 239 |
! ! |
240 |
||
125 | 241 |
!AspectAdaptor methodsFor:'accessing-spec'! |
242 |
||
243 |
accessWith:getSelector assignWith:putSelector |
|
3614 | 244 |
"setup the receiver to use getSelector to fetch a value |
381 | 245 |
and putSelector to change it." |
125 | 246 |
|
247 |
getMsg := getSelector. |
|
248 |
putMsg := putSelector |
|
381 | 249 |
|
250 |
"Modified: 22.1.1997 / 18:28:46 / cg" |
|
125 | 251 |
! |
252 |
||
253 |
accessWith:getSelector assignWith:putSelector aspect:aspectSymbol |
|
3614 | 254 |
"setup the receiver to use getSelector to fetch a value |
381 | 255 |
and putSelector to change it." |
125 | 256 |
|
257 |
getMsg := getSelector. |
|
258 |
putMsg := putSelector. |
|
259 |
myAspect := aspectSymbol |
|
381 | 260 |
|
261 |
"Modified: 22.1.1997 / 18:28:51 / cg" |
|
125 | 262 |
! |
263 |
||
409 | 264 |
aspect:aSelector |
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
265 |
"set the adaptor's change aspect - this is the aspect of the update message, |
409 | 266 |
on which the adaptor reacts" |
267 |
||
268 |
myAspect := aSelector. |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
269 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
270 |
"Modified (comment): / 25-07-2022 / 08:19:45 / cg" |
409 | 271 |
! |
272 |
||
125 | 273 |
forAspect |
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
274 |
"get the adaptor's aspect - if none was defined, the getMsg is returned" |
381 | 275 |
|
125 | 276 |
myAspect isNil ifTrue:[ |
381 | 277 |
^ getMsg |
125 | 278 |
]. |
279 |
^ myAspect |
|
381 | 280 |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
281 |
"Modified: / 22-01-1997 / 18:27:24 / cg" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
282 |
"Modified (comment): / 25-07-2022 / 08:19:53 / cg" |
125 | 283 |
! |
284 |
||
285 |
forAspect:aSelector |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
286 |
"set the adaptor's aspect - this sets both the get- and put-Messages |
381 | 287 |
(the putMessage is the aspect with a colon)" |
288 |
||
125 | 289 |
getMsg := myAspect := aSelector. |
3300 | 290 |
putMsg := aSelector asMutator. |
381 | 291 |
|
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
292 |
"Modified: / 22-01-1997 / 18:29:05 / cg" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
293 |
"Modified (comment): / 25-07-2022 / 08:19:49 / cg" |
125 | 294 |
! ! |
295 |
||
296 |
!AspectAdaptor methodsFor:'accessing-value'! |
|
297 |
||
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
298 |
defaultValueIfNoSubject |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
299 |
"if there is no subject (taget to provide the value), |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
300 |
this value is returned." |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
301 |
|
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
302 |
^ nil |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
303 |
|
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
304 |
"Created: / 01-03-2012 / 08:53:38 / cg" |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
305 |
! |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
306 |
|
125 | 307 |
setValue:newValue |
381 | 308 |
"set the value - this forwards a putMessage to the target" |
309 |
||
125 | 310 |
|target oldValue| |
311 |
||
312 |
target := super value. |
|
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
313 |
target notNil ifTrue:[ |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
314 |
oldValue := target perform:getMsg. |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
315 |
oldValue ~~ newValue ifTrue:[ |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
316 |
target perform:putMsg with:newValue. |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
317 |
] |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
318 |
]. |
2286 | 319 |
|
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
320 |
"Modified: / 01-03-2012 / 08:54:10 / cg" |
125 | 321 |
! |
322 |
||
323 |
value |
|
324 |
"translate a query for my value from my user |
|
325 |
into an aspect access towards my subject" |
|
326 |
||
327 |
|target| |
|
328 |
||
329 |
target := super value. |
|
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
330 |
target isNil ifTrue:[^ self defaultValueIfNoSubject]. |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
331 |
|
125 | 332 |
^ target perform:getMsg |
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
333 |
|
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
334 |
"Modified (format): / 01-03-2012 / 08:54:33 / cg" |
125 | 335 |
! |
336 |
||
337 |
value:newValue |
|
381 | 338 |
"set the value - this forwards a putMessage to the target |
339 |
and sends out a changeNotification if the value did really change." |
|
340 |
||
125 | 341 |
|target oldValue| |
342 |
||
343 |
target := super value. |
|
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
344 |
target notNil ifTrue:[ |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
345 |
oldValue := target perform:getMsg. |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
346 |
oldValue ~~ newValue ifTrue:[ |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
347 |
target perform:putMsg with:newValue. |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
348 |
subjectSendsUpdates ifFalse:[ |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
349 |
self changed:#value |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
350 |
] |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
351 |
] |
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
352 |
]. |
2286 | 353 |
|
2988
bc154fbdd68d
added: #defaultValueIfNoSubject
Claus Gittinger <cg@exept.de>
parents:
2742
diff
changeset
|
354 |
"Modified: / 01-03-2012 / 08:54:27 / cg" |
125 | 355 |
! ! |
356 |
||
69 | 357 |
!AspectAdaptor methodsFor:'change & update'! |
358 |
||
359 |
update:something with:aParameter from:changedObject |
|
360 |
"translate an update from the model into a #value-change |
|
361 |
via my depenedents ..." |
|
362 |
||
448 | 363 |
((changedObject == subject and:[something == self forAspect]) |
69 | 364 |
or:[changedObject == subjectChannel]) ifTrue:[ |
448 | 365 |
self changed:#value |
69 | 366 |
]. |
367 |
! ! |
|
368 |
||
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
369 |
!AspectAdaptor methodsFor:'printing'! |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
370 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
371 |
displayOn:aStreamOrGC |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
372 |
aStreamOrGC isStream ifFalse:[ |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
373 |
^ super displayOn:aStreamOrGC |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
374 |
]. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
375 |
aStreamOrGC nextPutAll:(self class name); nextPutAll:'('. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
376 |
aStreamOrGC store:getMsg. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
377 |
aStreamOrGC nextPutAll:' to '. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
378 |
(subject ? subjectChannel) displayOn:aStreamOrGC. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
379 |
aStreamOrGC nextPutAll:')'. |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
380 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
381 |
"Created: / 10-03-2022 / 08:25:24 / exept MBP" |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
382 |
! ! |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
383 |
|
129 | 384 |
!AspectAdaptor class methodsFor:'documentation'! |
385 |
||
386 |
version |
|
3614 | 387 |
^ '$Header$' |
4471
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
388 |
! |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
389 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
390 |
version_HG |
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
391 |
|
df7515191c90
Update AspectAdaptor from CVS, rev 1.30
Jan Vrany <jan.vrany@labware.com>
parents:
3614
diff
changeset
|
392 |
^ '$Changeset: <not expanded> $' |
129 | 393 |
! ! |
3300 | 394 |