author | Claus Gittinger <cg@exept.de> |
Tue, 24 Jun 1997 19:26:24 +0200 | |
changeset 2717 | c1cd0f1920a4 |
parent 2716 | 08cf98cf1a53 |
child 5272 | 1dad283c5256 |
permissions | -rw-r--r-- |
1074 | 1 |
Object subclass:#InterestConverter |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
2 |
instanceVariableNames:'destination selector aspect' |
1074 | 3 |
classVariableNames:'' |
4 |
poolDictionaries:'' |
|
5 |
category:'Interface-Support-Models' |
|
6 |
! |
|
7 |
||
8 |
!InterestConverter class methodsFor:'documentation'! |
|
9 |
||
10 |
documentation |
|
11 |
" |
|
12 |
instances convert update messages into messages as setup via |
|
13 |
#onChangeSend:to. |
|
14 |
This is a temporary kludge and will be replaced by a more intelligent |
|
15 |
DependencyCollection class in the future. |
|
1291 | 16 |
|
17 |
[author:] |
|
18 |
Claus Gittinger |
|
1074 | 19 |
" |
20 |
! |
|
21 |
||
22 |
examples |
|
23 |
" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
24 |
#onChangeSend:to / #retractInterestsIn: |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
25 |
interested in any change: |
1315 | 26 |
[exBegin] |
1074 | 27 |
|p b| |
28 |
||
1422 | 29 |
b := [Transcript showCR:'--> notification: point has changed']. |
1074 | 30 |
|
31 |
p := Point new. |
|
32 |
p onChangeSend:#value to:b. |
|
33 |
Delay waitForSeconds:1. |
|
1422 | 34 |
Transcript showCR:'sending change ...'. |
1074 | 35 |
p changed. |
2716 | 36 |
Transcript showCR:'retracting ...'. |
1074 | 37 |
p retractInterestsFor:b. |
38 |
Delay waitForSeconds:1. |
|
1422 | 39 |
Transcript showCR:'sending change ...'. |
1074 | 40 |
p changed. |
1315 | 41 |
[exEnd] |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
42 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
43 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
44 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
45 |
#expressInterestIn:for:sendBack / #retractInterestIn:for: |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
46 |
interested in a specific change: |
1315 | 47 |
[exBegin] |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
48 |
|p b| |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
49 |
|
1422 | 50 |
b := [Transcript showCR:'the point changed']. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
51 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
52 |
p := Point new. |
1422 | 53 |
Transcript showCR:'interest in #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
54 |
p expressInterestIn:#foo for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
55 |
p x:1. |
1422 | 56 |
Transcript showCR:'now changing #bar'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
57 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
58 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
59 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
60 |
Delay waitForSeconds:1. |
1422 | 61 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
62 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
63 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
64 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
65 |
Delay waitForSeconds:1. |
1422 | 66 |
Transcript showCR:'no more interest in #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
67 |
p retractInterestIn:#foo for:b. |
1422 | 68 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
69 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
70 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
71 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
72 |
Delay waitForSeconds:1. |
1422 | 73 |
Transcript showCR:'interest in #bar now'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
74 |
p expressInterestIn:#bar for:b sendBack:#value. |
1422 | 75 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
76 |
p changed:#foo. |
1422 | 77 |
Transcript showCR:'now changing #bar'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
78 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
79 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
80 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
81 |
Delay waitForSeconds:1. |
1422 | 82 |
Transcript showCR:'interest in #foo now'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
83 |
p expressInterestIn:#foo for:b sendBack:#value. |
1422 | 84 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
85 |
p changed:#foo. |
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:'no more interests'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
92 |
p retractInterestsFor:b. |
1422 | 93 |
Transcript showCR:'now changing #foo'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
94 |
p changed:#foo. |
1422 | 95 |
Transcript showCR:'now changing #bar'. |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
96 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
97 |
Transcript cr. |
1315 | 98 |
[exEnd] |
1074 | 99 |
" |
100 |
! ! |
|
101 |
||
102 |
!InterestConverter class methodsFor:'instance creation'! |
|
103 |
||
104 |
destination:anObject selector:aSelector |
|
2717 | 105 |
"create & return an interestConverter, which sends aSelector |
106 |
to anObject when a change notification arrives" |
|
107 |
||
1074 | 108 |
^ self basicNew destination:anObject selector:aSelector |
2717 | 109 |
|
110 |
"Modified: 21.5.1997 / 11:59:08 / cg" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
111 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
112 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
113 |
destination:anObject selector:aSelector aspect:aspect |
2717 | 114 |
"create & return an interestConverter, which sends aSelector |
115 |
to anObject when a change notification for aspect arrives" |
|
116 |
||
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
117 |
^ self basicNew destination:anObject selector:aSelector aspect:aspect |
2717 | 118 |
|
119 |
"Modified: 21.5.1997 / 11:59:26 / cg" |
|
1074 | 120 |
! ! |
121 |
||
122 |
!InterestConverter methodsFor:'accessing'! |
|
123 |
||
2717 | 124 |
aspect |
125 |
"return my aspect (if any)" |
|
126 |
||
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
127 |
^ aspect |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
128 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
129 |
"Created: 8.3.1996 / 23:00:37 / cg" |
2717 | 130 |
"Modified: 21.5.1997 / 11:59:43 / cg" |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
131 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
132 |
|
1074 | 133 |
destination |
134 |
^ destination |
|
135 |
||
136 |
"Created: 7.3.1996 / 10:57:01 / cg" |
|
137 |
! |
|
138 |
||
139 |
destination:dest selector:sel |
|
140 |
destination := dest. |
|
141 |
selector := sel |
|
142 |
||
143 |
"Created: 7.3.1996 / 10:49:13 / cg" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
144 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
145 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
146 |
destination:dest selector:sel aspect:a |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
147 |
destination := dest. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
148 |
selector := sel. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
149 |
aspect := a |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
150 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
151 |
"Created: 8.3.1996 / 22:42:03 / cg" |
1074 | 152 |
! ! |
153 |
||
154 |
!InterestConverter methodsFor:'change & update'! |
|
155 |
||
156 |
update:something with:aParameter from:someObject |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
157 |
(aspect isNil or:[aspect == something]) ifTrue:[ |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
158 |
destination perform:selector |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
159 |
] |
1074 | 160 |
|
161 |
"Created: 7.3.1996 / 10:14:30 / cg" |
|
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1074
diff
changeset
|
162 |
"Modified: 8.3.1996 / 22:41:53 / cg" |
1074 | 163 |
! ! |
164 |
||
165 |
!InterestConverter class methodsFor:'documentation'! |
|
166 |
||
167 |
version |
|
2717 | 168 |
^ '$Header: /cvs/stx/stx/libbasic/InterestConverter.st,v 1.8 1997-06-24 17:26:24 cg Exp $' |
1074 | 169 |
! ! |