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