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