8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 ProtocolAdaptor subclass:#AspectAdaptor |
13 ProtocolAdaptor subclass:#AspectAdaptor |
14 instanceVariableNames:'myAspect getMsg putMsg' |
14 instanceVariableNames:'myAspect getMsg putMsg' |
15 classVariableNames:'' |
15 classVariableNames:'' |
16 poolDictionaries:'' |
16 poolDictionaries:'' |
17 category:'Interface-Support-Models' |
17 category:'Interface-Support-Models' |
18 ! |
18 ! |
29 inclusion of the above copyright notice. This software may not |
29 inclusion of the above copyright notice. This software may not |
30 be provided or otherwise made available to, or used by, any |
30 be provided or otherwise made available to, or used by, any |
31 other person. No title to or ownership of the software is |
31 other person. No title to or ownership of the software is |
32 hereby transferred. |
32 hereby transferred. |
33 " |
33 " |
34 ! |
|
35 |
|
36 version |
|
37 ^ '$Header: /cvs/stx/stx/libview2/AspectAdaptor.st,v 1.7 1995-11-11 16:04:16 cg Exp $' |
|
38 ! |
34 ! |
39 |
35 |
40 documentation |
36 documentation |
41 " |
37 " |
42 an AspectAdaptor forwards updates and change messages |
38 an AspectAdaptor forwards updates and change messages |
129 dialog open. |
125 dialog open. |
130 dialog accepted ifTrue:[ |
126 dialog accepted ifTrue:[ |
131 Transcript showCr:'data now: ' , data printString |
127 Transcript showCr:'data now: ' , data printString |
132 ] |
128 ] |
133 " |
129 " |
|
130 ! |
|
131 |
|
132 version |
|
133 ^ '$Header: /cvs/stx/stx/libview2/AspectAdaptor.st,v 1.8 1995-11-23 10:42:05 cg Exp $' |
134 ! ! |
134 ! ! |
135 |
135 |
136 !AspectAdaptor class methodsFor:'instance creation'! |
136 !AspectAdaptor class methodsFor:'instance creation'! |
137 |
137 |
138 accessWith:getSelector assignWith:putSelector |
138 accessWith:getSelector assignWith:putSelector |
145 subject:anObject sendsUpdates:aBoolean accessWith:getSel assignWith:putSel aspect:aspect |
145 subject:anObject sendsUpdates:aBoolean accessWith:getSel assignWith:putSel aspect:aspect |
146 ^ (self subject:anObject sendsUpdates:aBoolean) |
146 ^ (self subject:anObject sendsUpdates:aBoolean) |
147 accessWith:getSel assignWith:putSel aspect:aspect |
147 accessWith:getSel assignWith:putSel aspect:aspect |
148 ! ! |
148 ! ! |
149 |
149 |
150 !AspectAdaptor methodsFor:'change & update'! |
150 !AspectAdaptor methodsFor:'accessing-spec'! |
151 |
151 |
152 update:something with:aParameter from:changedObject |
152 accessWith:getSelector assignWith:putSelector |
153 "translate an update from the model into a #value-change |
153 "setup the recevier to use getSelector to fetch a value |
154 via my depenedents ..." |
154 and setSelector to change it." |
155 |
155 |
156 ((changedObject == subject) |
156 getMsg := getSelector. |
157 or:[changedObject == subjectChannel]) ifTrue:[ |
157 putMsg := putSelector |
158 something == self forAspect ifTrue:[ |
158 ! |
159 self changed:#value |
159 |
160 ]. |
160 accessWith:getSelector assignWith:putSelector aspect:aspectSymbol |
161 ^ self |
161 "setup the recevier to use getSelector to fetch a value |
|
162 and setSelector to change it." |
|
163 |
|
164 getMsg := getSelector. |
|
165 putMsg := putSelector. |
|
166 myAspect := aspectSymbol |
|
167 ! |
|
168 |
|
169 forAspect |
|
170 myAspect isNil ifTrue:[ |
|
171 ^ getMsg |
162 ]. |
172 ]. |
|
173 ^ myAspect |
|
174 ! |
|
175 |
|
176 forAspect:aSelector |
|
177 getMsg := myAspect := aSelector. |
|
178 putMsg := (aSelector , ':') asSymbol. |
163 ! ! |
179 ! ! |
164 |
180 |
165 !AspectAdaptor methodsFor:'accessing-value'! |
181 !AspectAdaptor methodsFor:'accessing-value'! |
166 |
|
167 value |
|
168 "translate a query for my value from my user |
|
169 into an aspect access towards my subject" |
|
170 |
|
171 |target| |
|
172 |
|
173 target := super value. |
|
174 ^ target perform:getMsg |
|
175 ! |
|
176 |
182 |
177 setValue:newValue |
183 setValue:newValue |
178 |target oldValue| |
184 |target oldValue| |
179 |
185 |
180 target := super value. |
186 target := super value. |
181 oldValue := target perform:getMsg. |
187 oldValue := target perform:getMsg. |
182 oldValue ~~ newValue ifTrue:[ |
188 oldValue ~~ newValue ifTrue:[ |
183 target perform:putMsg with:newValue. |
189 target perform:putMsg with:newValue. |
184 ] |
190 ] |
|
191 ! |
|
192 |
|
193 value |
|
194 "translate a query for my value from my user |
|
195 into an aspect access towards my subject" |
|
196 |
|
197 |target| |
|
198 |
|
199 target := super value. |
|
200 ^ target perform:getMsg |
185 ! |
201 ! |
186 |
202 |
187 value:newValue |
203 value:newValue |
188 |target oldValue| |
204 |target oldValue| |
189 |
205 |
194 subjectSendsUpdates ifFalse:[ |
210 subjectSendsUpdates ifFalse:[ |
195 self changed:#value |
211 self changed:#value |
196 ] |
212 ] |
197 ] |
213 ] |
198 ! ! |
214 ! ! |
199 |
215 |
200 !AspectAdaptor methodsFor:'accessing-spec'! |
216 !AspectAdaptor methodsFor:'change & update'! |
201 |
217 |
202 forAspect |
218 update:something with:aParameter from:changedObject |
203 myAspect isNil ifTrue:[ |
219 "translate an update from the model into a #value-change |
204 ^ getMsg |
220 via my depenedents ..." |
|
221 |
|
222 ((changedObject == subject) |
|
223 or:[changedObject == subjectChannel]) ifTrue:[ |
|
224 something == self forAspect ifTrue:[ |
|
225 self changed:#value |
|
226 ]. |
|
227 ^ self |
205 ]. |
228 ]. |
206 ^ myAspect |
229 ! ! |
207 ! |
230 |
208 |
|
209 forAspect:aSelector |
|
210 getMsg := myAspect := aSelector. |
|
211 putMsg := (aSelector , ':') asSymbol. |
|
212 ! |
|
213 |
|
214 accessWith:getSelector assignWith:putSelector |
|
215 "setup the recevier to use getSelector to fetch a value |
|
216 and setSelector to change it." |
|
217 |
|
218 getMsg := getSelector. |
|
219 putMsg := putSelector |
|
220 ! |
|
221 |
|
222 accessWith:getSelector assignWith:putSelector aspect:aspectSymbol |
|
223 "setup the recevier to use getSelector to fetch a value |
|
224 and setSelector to change it." |
|
225 |
|
226 getMsg := getSelector. |
|
227 putMsg := putSelector. |
|
228 myAspect := aspectSymbol |
|
229 ! ! |
|