author | convert-repo |
Sat, 11 Feb 2017 04:41:47 +0000 | |
changeset 3880 | c4269847c0fe |
parent 3878 | f7e300dabdf5 |
child 4214 | fd7887c261d5 |
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 |
" |
|
1438
739c0e3e3993
pass the newValue as parameter with change-notification
Claus Gittinger <cg@exept.de>
parents:
1363
diff
changeset
|
12 |
"{ Package: 'stx:libview2' }" |
739c0e3e3993
pass the newValue as parameter with change-notification
Claus Gittinger <cg@exept.de>
parents:
1363
diff
changeset
|
13 |
|
3782 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
69 | 16 |
Model subclass:#ValueModel |
441
b0d486981a62
unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
17 |
instanceVariableNames:'' |
175
df08e5b663d0
let objects interest implementation do things
Claus Gittinger <cg@exept.de>
parents:
143
diff
changeset
|
18 |
classVariableNames:'' |
df08e5b663d0
let objects interest implementation do things
Claus Gittinger <cg@exept.de>
parents:
143
diff
changeset
|
19 |
poolDictionaries:'' |
df08e5b663d0
let objects interest implementation do things
Claus Gittinger <cg@exept.de>
parents:
143
diff
changeset
|
20 |
category:'Interface-Support-Models' |
62 | 21 |
! |
22 |
||
441
b0d486981a62
unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
23 |
!ValueModel class methodsFor:'documentation'! |
68 | 24 |
|
69 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
71 | 28 |
All Rights Reserved |
69 | 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 |
||
68 | 39 |
documentation |
40 |
" |
|
41 |
abstract superclass for ValueHolders and Adaptors. |
|
69 | 42 |
It does not itself know how and where the value is stored, |
143
ae38792bd85c
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
129
diff
changeset
|
43 |
but knows about interested objects (which get informed, whenever |
69 | 44 |
the value changes) and keeps track if the value was ever accepted. |
68 | 45 |
|
231 | 46 |
Notice: |
47 |
this class was implemented using protocol information |
|
48 |
from alpha testers - it may not be complete or compatible to |
|
49 |
the corresponding ST-80 class. |
|
50 |
If you encounter any incompatibilities, please forward a note |
|
51 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
69 | 52 |
|
53 |
subclasses must redefine: #setValue: and #value |
|
54 |
(and optionally redefine #value:) |
|
223 | 55 |
|
56 |
[author:] |
|
57 |
Claus Gittinger |
|
68 | 58 |
" |
59 |
! ! |
|
60 |
||
441
b0d486981a62
unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
61 |
!ValueModel class methodsFor:'instance creation'! |
62 | 62 |
|
63 |
new |
|
1189 | 64 |
^ self basicNew initialize |
62 | 65 |
! ! |
66 |
||
3878 | 67 |
!ValueModel class methodsFor:'queries'! |
68 |
||
69 |
isAbstract |
|
70 |
"Return if this class is an abstract class. |
|
71 |
True is returned here for myself only; false for subclasses. |
|
72 |
Abstract subclasses must redefine this again." |
|
73 |
||
74 |
^ self == ValueModel. |
|
75 |
! ! |
|
76 |
||
125 | 77 |
!ValueModel methodsFor:'accessing'! |
78 |
||
79 |
setValue:newValue |
|
80 |
"physically set my value, without change notifications" |
|
81 |
||
82 |
^ self subclassResponsibility |
|
83 |
! |
|
73 | 84 |
|
1363 | 85 |
triggerValue:newValue |
86 |
"set my value & send change notifications to my dependents. |
|
87 |
Send the change message even if the value didn't change." |
|
88 |
||
89 |
self setValue:newValue. |
|
90 |
self changed:#value |
|
91 |
||
92 |
"Modified: 27.3.1997 / 15:14:04 / cg" |
|
93 |
! |
|
94 |
||
125 | 95 |
value |
96 |
"return my value" |
|
97 |
||
98 |
^ self subclassResponsibility |
|
99 |
! |
|
100 |
||
504 | 101 |
value:newValue |
102 |
"set my value & send change notifications to my dependents |
|
103 |
if it changed." |
|
104 |
||
1156 | 105 |
"/ "/ mhmh - that seems to be what VW does ... |
106 |
"/ "/ (i.e. always send a change message) |
|
107 |
"/ self setValue:newValue. |
|
108 |
"/ self changed:#value |
|
109 |
||
504 | 110 |
|oldValue| |
125 | 111 |
|
504 | 112 |
oldValue := self value. |
113 |
oldValue ~~ newValue ifTrue:[ |
|
114 |
self setValue:newValue. |
|
1438
739c0e3e3993
pass the newValue as parameter with change-notification
Claus Gittinger <cg@exept.de>
parents:
1363
diff
changeset
|
115 |
self changed:#value with:newValue |
504 | 116 |
] |
326
ab4e3df5c5d5
only ignore new value if identical to previous value.
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
117 |
|
504 | 118 |
"Modified: 27.3.1997 / 15:14:04 / cg" |
796
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
119 |
! |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
120 |
|
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
121 |
value:newValue withoutNotifying:someOne |
1095
ffd2aaae1a45
Fix typo (interrest -> interest)
Stefan Vogel <sv@exept.de>
parents:
796
diff
changeset
|
122 |
"like #value, but temporarily retract all interests for someOne |
796
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
123 |
(i.e. the value-change will NOT directly send ANY change notification |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
124 |
to someOne; we cannot guarantee indirect notifications, though.) |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
125 |
Useful if someone is itself depending on the receiver, |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
126 |
and wants to avoid recursive update notifications." |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
127 |
|
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
128 |
|oldInterests wasDependent| |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
129 |
|
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
130 |
[ |
3782 | 131 |
oldInterests := self retractInterestsFor:someOne. |
132 |
wasDependent := self dependents includes:someOne. |
|
133 |
wasDependent ifTrue:[ |
|
134 |
self removeDependent:someOne. |
|
135 |
]. |
|
796
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
136 |
|
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
137 |
self value:newValue. |
1557
e5e78ee63670
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
138 |
] ensure:[ |
796
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
139 |
wasDependent ifTrue:[self addDependent:someOne]. |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
140 |
oldInterests do:[:i | |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
141 |
self addInterest:i |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
142 |
]. |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
143 |
]. |
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
144 |
|
5aca7d7a8f30
added #value:withoutNotifying:
Claus Gittinger <cg@exept.de>
parents:
773
diff
changeset
|
145 |
"Modified: / 30.1.1998 / 14:14:01 / cg" |
62 | 146 |
! ! |
147 |
||
492 | 148 |
!ValueModel methodsFor:'converting'! |
149 |
||
1156 | 150 |
asValue |
151 |
"return the receiver - it is already a valueHolder" |
|
152 |
||
153 |
^ self |
|
154 |
! |
|
155 |
||
492 | 156 |
compute:aBlock |
157 |
"return a BlockValue on the receiver, which computes aBlock" |
|
158 |
||
159 |
^ BlockValue with:aBlock arguments:(Array with:self) |
|
160 |
! ! |
|
161 |
||
3004 | 162 |
!ValueModel methodsFor:'misc'! |
163 |
||
164 |
deccrement |
|
165 |
self value:(self value + 1) |
|
166 |
||
167 |
"Created: / 27-04-2012 / 14:51:54 / cg" |
|
168 |
! |
|
169 |
||
170 |
increment |
|
171 |
self value:(self value + 1) |
|
172 |
||
173 |
"Created: / 27-04-2012 / 14:51:51 / cg" |
|
174 |
! ! |
|
175 |
||
773
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
176 |
!ValueModel methodsFor:'queries'! |
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
177 |
|
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
178 |
isBuffering |
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
179 |
"return true, if the receiver is buffering something. |
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
180 |
For compatibility with BufferedValueHolder, false is returned here" |
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
181 |
|
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
182 |
^ false |
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
183 |
|
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
184 |
"Created: / 27.1.1998 / 12:12:08 / cg" |
1114 | 185 |
! |
186 |
||
187 |
isValueModel |
|
188 |
"return true, if the receiver is some kind of valueModel; |
|
189 |
true returned here - redefined from Object" |
|
190 |
||
191 |
^ true |
|
773
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
192 |
! ! |
b6337f784d05
added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents:
504
diff
changeset
|
193 |
|
441
b0d486981a62
unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
194 |
!ValueModel class methodsFor:'documentation'! |
129 | 195 |
|
196 |
version |
|
3782 | 197 |
^ '$Header$' |
129 | 198 |
! ! |
3782 | 199 |