author | Claus Gittinger <cg@exept.de> |
Wed, 15 Mar 2006 11:23:43 +0100 | |
changeset 9281 | 9f05718319a0 |
parent 8436 | 4a9e5fbe67e5 |
child 11715 | 03f0d5aee2fd |
permissions | -rw-r--r-- |
5272 | 1 |
" |
2 |
COPYRIGHT (c) 1996 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 |
||
6056 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
1074 | 16 |
Object subclass:#InterestConverter |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
17 |
instanceVariableNames:'destination selector aspect' |
1074 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Support-Models' |
|
21 |
! |
|
22 |
||
23 |
!InterestConverter class methodsFor:'documentation'! |
|
24 |
||
5272 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1996 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 |
||
1074 | 40 |
documentation |
41 |
" |
|
42 |
instances convert update messages into messages as setup via |
|
8436 | 43 |
#onChangeSend:to:. |
1074 | 44 |
This is a temporary kludge and will be replaced by a more intelligent |
45 |
DependencyCollection class in the future. |
|
1291 | 46 |
|
47 |
[author:] |
|
48 |
Claus Gittinger |
|
1074 | 49 |
" |
50 |
! |
|
51 |
||
52 |
examples |
|
53 |
" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
54 |
#onChangeSend:to / #retractInterestsIn: |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
55 |
interested in any change: |
1315 | 56 |
[exBegin] |
1074 | 57 |
|p b| |
58 |
||
1422 | 59 |
b := [Transcript showCR:'--> notification: point has changed']. |
1074 | 60 |
|
61 |
p := Point new. |
|
62 |
p onChangeSend:#value to:b. |
|
63 |
Delay waitForSeconds:1. |
|
1422 | 64 |
Transcript showCR:'sending change ...'. |
1074 | 65 |
p changed. |
2716 | 66 |
Transcript showCR:'retracting ...'. |
1074 | 67 |
p retractInterestsFor:b. |
68 |
Delay waitForSeconds:1. |
|
1422 | 69 |
Transcript showCR:'sending change ...'. |
1074 | 70 |
p changed. |
1315 | 71 |
[exEnd] |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
72 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
73 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
74 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
75 |
#expressInterestIn:for:sendBack / #retractInterestIn:for: |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
76 |
interested in a specific change: |
1315 | 77 |
[exBegin] |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
78 |
|p b| |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
79 |
|
1422 | 80 |
b := [Transcript showCR:'the point changed']. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
81 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
82 |
p := Point new. |
1422 | 83 |
Transcript showCR:'interest in #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
84 |
p expressInterestIn:#foo for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
85 |
p x:1. |
1422 | 86 |
Transcript showCR:'now changing #bar'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
87 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
88 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
89 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
90 |
Delay waitForSeconds:1. |
1422 | 91 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
92 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
93 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
94 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
95 |
Delay waitForSeconds:1. |
1422 | 96 |
Transcript showCR:'no more interest in #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
97 |
p retractInterestIn:#foo for:b. |
1422 | 98 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
99 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
100 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
101 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
102 |
Delay waitForSeconds:1. |
1422 | 103 |
Transcript showCR:'interest in #bar now'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
104 |
p expressInterestIn:#bar for:b sendBack:#value. |
1422 | 105 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
106 |
p changed:#foo. |
1422 | 107 |
Transcript showCR:'now changing #bar'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
108 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
109 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
110 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
111 |
Delay waitForSeconds:1. |
1422 | 112 |
Transcript showCR:'interest in #foo now'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
113 |
p expressInterestIn:#foo for:b sendBack:#value. |
1422 | 114 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
115 |
p changed:#foo. |
1422 | 116 |
Transcript showCR:'now changing #bar'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
117 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
118 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
119 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
120 |
Delay waitForSeconds:1. |
1422 | 121 |
Transcript showCR:'no more interests'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
122 |
p retractInterestsFor:b. |
1422 | 123 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
124 |
p changed:#foo. |
1422 | 125 |
Transcript showCR:'now changing #bar'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
126 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
127 |
Transcript cr. |
1315 | 128 |
[exEnd] |
1074 | 129 |
" |
130 |
! ! |
|
131 |
||
132 |
!InterestConverter class methodsFor:'instance creation'! |
|
133 |
||
134 |
destination:anObject selector:aSelector |
|
2717 | 135 |
"create & return an interestConverter, which sends aSelector |
136 |
to anObject when a change notification arrives" |
|
137 |
||
1074 | 138 |
^ self basicNew destination:anObject selector:aSelector |
2717 | 139 |
|
140 |
"Modified: 21.5.1997 / 11:59:08 / cg" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
141 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
142 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
143 |
destination:anObject selector:aSelector aspect:aspect |
2717 | 144 |
"create & return an interestConverter, which sends aSelector |
145 |
to anObject when a change notification for aspect arrives" |
|
146 |
||
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
147 |
^ self basicNew destination:anObject selector:aSelector aspect:aspect |
2717 | 148 |
|
149 |
"Modified: 21.5.1997 / 11:59:26 / cg" |
|
1074 | 150 |
! ! |
151 |
||
152 |
!InterestConverter methodsFor:'accessing'! |
|
153 |
||
2717 | 154 |
aspect |
155 |
"return my aspect (if any)" |
|
156 |
||
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
157 |
^ aspect |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
158 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
159 |
"Created: 8.3.1996 / 23:00:37 / cg" |
2717 | 160 |
"Modified: 21.5.1997 / 11:59:43 / cg" |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
161 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
162 |
|
1074 | 163 |
destination |
164 |
^ destination |
|
165 |
||
166 |
"Created: 7.3.1996 / 10:57:01 / cg" |
|
167 |
! |
|
168 |
||
169 |
destination:dest selector:sel |
|
170 |
destination := dest. |
|
171 |
selector := sel |
|
172 |
||
173 |
"Created: 7.3.1996 / 10:49:13 / cg" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
174 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
175 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
176 |
destination:dest selector:sel aspect:a |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
177 |
destination := dest. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
178 |
selector := sel. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
179 |
aspect := a |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
180 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
181 |
"Created: 8.3.1996 / 22:42:03 / cg" |
7347 | 182 |
! |
183 |
||
184 |
selector |
|
185 |
^ selector |
|
186 |
||
187 |
"Created: 7.3.1996 / 10:57:01 / cg" |
|
1074 | 188 |
! ! |
189 |
||
190 |
!InterestConverter methodsFor:'change & update'! |
|
191 |
||
192 |
update:something with:aParameter from:someObject |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
193 |
(aspect isNil or:[aspect == something]) ifTrue:[ |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
194 |
destination perform:selector |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
195 |
] |
1074 | 196 |
|
197 |
"Created: 7.3.1996 / 10:14:30 / cg" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
198 |
"Modified: 8.3.1996 / 22:41:53 / cg" |
1074 | 199 |
! ! |
200 |
||
6056 | 201 |
!InterestConverter methodsFor:'printing'! |
202 |
||
203 |
displayString |
|
204 |
^ self className , '(sending ' , selector storeString , ' to ' , destination printString , ')' |
|
205 |
! ! |
|
206 |
||
9281 | 207 |
!InterestConverter methodsFor:'testing'! |
208 |
||
209 |
isInterestConverter |
|
210 |
^ true |
|
211 |
! ! |
|
212 |
||
1074 | 213 |
!InterestConverter class methodsFor:'documentation'! |
214 |
||
215 |
version |
|
9281 | 216 |
^ '$Header: /cvs/stx/stx/libbasic/InterestConverter.st,v 1.13 2006-03-15 10:23:43 cg Exp $' |
1074 | 217 |
! ! |