ProtocolAdaptor.st
author Claus Gittinger <cg@exept.de>
Thu, 18 Apr 1996 01:56:10 +0200
changeset 186 68bd07dcdfa7
parent 129 f890eaabc487
child 223 b65dc250db8d
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
75
claus
parents: 71
diff changeset
     1
"
claus
parents: 71
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 71
diff changeset
     3
	      All Rights Reserved
claus
parents: 71
diff changeset
     4
claus
parents: 71
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 71
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 71
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 71
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 71
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 71
diff changeset
    10
 hereby transferred.
claus
parents: 71
diff changeset
    11
"
claus
parents: 71
diff changeset
    12
69
claus
parents:
diff changeset
    13
ValueModel subclass:#ProtocolAdaptor
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    14
	instanceVariableNames:'accessPath subject subjectChannel subjectSendsUpdates'
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    15
	classVariableNames:''
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    16
	poolDictionaries:''
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    17
	category:'Interface-Support-Models'
69
claus
parents:
diff changeset
    18
!
claus
parents:
diff changeset
    19
claus
parents:
diff changeset
    20
!ProtocolAdaptor class methodsFor:'documentation'!
claus
parents:
diff changeset
    21
claus
parents:
diff changeset
    22
copyright
claus
parents:
diff changeset
    23
"
claus
parents:
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
71
claus
parents: 69
diff changeset
    25
	      All Rights Reserved
69
claus
parents:
diff changeset
    26
claus
parents:
diff changeset
    27
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    32
 hereby transferred.
claus
parents:
diff changeset
    33
"
claus
parents:
diff changeset
    34
!
claus
parents:
diff changeset
    35
claus
parents:
diff changeset
    36
documentation
claus
parents:
diff changeset
    37
"
claus
parents:
diff changeset
    38
    a ProtocolAdaptor allows access to embeded values in a
claus
parents:
diff changeset
    39
    complex model and plays model towards the outside world.
claus
parents:
diff changeset
    40
claus
parents:
diff changeset
    41
    Consider the case where editFields are required for the
claus
parents:
diff changeset
    42
    elements (instance variables) of a more complex model.
claus
parents:
diff changeset
    43
    Using ValueHolders, you had to copy the individual
claus
parents:
diff changeset
    44
    values out-of and into multiple valueHolders.
claus
parents:
diff changeset
    45
    A protocolAdaptor makes this easier, by playing model towards
claus
parents:
diff changeset
    46
    the editField, returning a value from the complex model, 
claus
parents:
diff changeset
    47
    and forwards changes to the complex model.
claus
parents:
diff changeset
    48
claus
parents:
diff changeset
    49
    Notice: since you can specify the aspect- and changeSymbols in most ST/X
claus
parents:
diff changeset
    50
    widgets, ProtocolAdapters are not always needed (at  least, if no access-
claus
parents:
diff changeset
    51
    path is required). 
claus
parents:
diff changeset
    52
    However, if you want to apply widgets on objects which where not originally 
claus
parents:
diff changeset
    53
    designed as models (such as Arrays), ProtocolAdapters are very useful.
claus
parents:
diff changeset
    54
claus
parents:
diff changeset
    55
    Notice: this class was implemented using protocol information
claus
parents:
diff changeset
    56
    from alpha testers - it may not be complete or compatible to
claus
parents:
diff changeset
    57
    the corresponding ST-80 class. If you encounter any incompatibilities,
claus
parents:
diff changeset
    58
    please forward a note to the ST/X team.
claus
parents:
diff changeset
    59
"
claus
parents:
diff changeset
    60
!
claus
parents:
diff changeset
    61
claus
parents:
diff changeset
    62
examples 
claus
parents:
diff changeset
    63
"
claus
parents:
diff changeset
    64
	|a obj|
claus
parents:
diff changeset
    65
claus
parents:
diff changeset
    66
	a := ProtocolAdaptor accessPath:#(1 2 3).
claus
parents:
diff changeset
    67
	obj := Array with:#(11 (121 122 123) 13)
claus
parents:
diff changeset
    68
		     with:#(21 (221 222 223) 23)
claus
parents:
diff changeset
    69
		     with:#(33 (321 322 323) 33).
claus
parents:
diff changeset
    70
	a valueUsingSubject:obj  
claus
parents:
diff changeset
    71
claus
parents:
diff changeset
    72
claus
parents:
diff changeset
    73
claus
parents:
diff changeset
    74
	|a obj|
claus
parents:
diff changeset
    75
claus
parents:
diff changeset
    76
	a := ProtocolAdaptor accessPath:#(1 2 origin).
claus
parents:
diff changeset
    77
	obj := Array with:(Array with:1@1 with:(1@2 corner:100@100))
claus
parents:
diff changeset
    78
		     with:(Array with:2@1 with:2@2)
claus
parents:
diff changeset
    79
		     with:(Array with:3@1 with:3@2).
claus
parents:
diff changeset
    80
	a valueUsingSubject:obj  
claus
parents:
diff changeset
    81
claus
parents:
diff changeset
    82
claus
parents:
diff changeset
    83
claus
parents:
diff changeset
    84
	|a model|
claus
parents:
diff changeset
    85
claus
parents:
diff changeset
    86
	a := ProtocolAdaptor accessPath:#(1 2 origin).
claus
parents:
diff changeset
    87
	model := (Array with:(Array with:1@1 with:(1@2 corner:100@100))
claus
parents:
diff changeset
    88
		     with:(Array with:2@1 with:2@2)
claus
parents:
diff changeset
    89
		     with:(Array with:3@1 with:3@2)) asValue.
claus
parents:
diff changeset
    90
	a subjectChannel:model.
claus
parents:
diff changeset
    91
	a value   
claus
parents:
diff changeset
    92
"
claus
parents:
diff changeset
    93
! !
claus
parents:
diff changeset
    94
claus
parents:
diff changeset
    95
!ProtocolAdaptor class methodsFor:'instance creation'!
claus
parents:
diff changeset
    96
claus
parents:
diff changeset
    97
accessPath:aCollectionOfSelectors
claus
parents:
diff changeset
    98
    ^ (self new) accessPath:aCollectionOfSelectors
claus
parents:
diff changeset
    99
!
claus
parents:
diff changeset
   100
claus
parents:
diff changeset
   101
subject:anObject
claus
parents:
diff changeset
   102
    ^ (self new) subject:anObject
claus
parents:
diff changeset
   103
!
claus
parents:
diff changeset
   104
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   105
subject:anObject accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   106
    ^ (self new) subject:anObject; accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   107
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   108
69
claus
parents:
diff changeset
   109
subject:anObject sendsUpdates:aBoolean
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   110
    ^ (self new) subject:anObject; subjectSendsUpdates:aBoolean
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   111
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   112
    "Modified: 18.4.1996 / 01:45:34 / cg"
69
claus
parents:
diff changeset
   113
!
claus
parents:
diff changeset
   114
claus
parents:
diff changeset
   115
subject:anObject sendsUpdates:aBoolean accessPath:aCollectionOfSelectors
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   116
    ^ (self new) subject:anObject; subjectSendsUpdates:aBoolean; accessPath:aCollectionOfSelectors
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   117
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   118
    "Modified: 18.4.1996 / 01:45:38 / cg"
69
claus
parents:
diff changeset
   119
!
claus
parents:
diff changeset
   120
claus
parents:
diff changeset
   121
subjectChannel:aValueHolder
claus
parents:
diff changeset
   122
    ^ (self new) subjectChannel:aValueHolder
claus
parents:
diff changeset
   123
!
claus
parents:
diff changeset
   124
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   125
subjectChannel:aValueHolder accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   126
    ^ (self new) subjectChannel:aValueHolder; accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   127
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   128
69
claus
parents:
diff changeset
   129
subjectChannel:aValueHolder sendsUpdates:aBoolean 
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   130
    ^ (self new) subjectChannel:aValueHolder; subjectSendsUpdates:aBoolean
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   131
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   132
    "Modified: 18.4.1996 / 01:45:45 / cg"
69
claus
parents:
diff changeset
   133
!
claus
parents:
diff changeset
   134
claus
parents:
diff changeset
   135
subjectChannel:aValueHolder sendsUpdates:aBoolean accessPath:aCollectionOfSelectors
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   136
    ^ (self new) subjectChannel:aValueHolder; subjectSendsUpdates:aBoolean; accessPath:aCollectionOfSelectors
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   137
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   138
    "Modified: 18.4.1996 / 01:45:50 / cg"
69
claus
parents:
diff changeset
   139
! !
claus
parents:
diff changeset
   140
claus
parents:
diff changeset
   141
!ProtocolAdaptor methodsFor:'accessing'!
claus
parents:
diff changeset
   142
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   143
setValue:newValue
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   144
    "set the value in my subject or subjectChannel."
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   145
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   146
    |obj|
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   147
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   148
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   149
	obj := subject.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   150
    ] ifFalse:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   151
	obj := subjectChannel value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   152
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   153
    ^ self setValue:newValue usingSubject:obj
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   154
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   155
69
claus
parents:
diff changeset
   156
setValue:newValue usingSubject:anObject
claus
parents:
diff changeset
   157
    "set a value in anObject, using the selectors in accessPath.
claus
parents:
diff changeset
   158
     A helper for setValue:."
claus
parents:
diff changeset
   159
claus
parents:
diff changeset
   160
    |obj lastIndex|
claus
parents:
diff changeset
   161
claus
parents:
diff changeset
   162
    obj := anObject.
claus
parents:
diff changeset
   163
    lastIndex := accessPath size.
claus
parents:
diff changeset
   164
    accessPath keysAndValuesDo:[:idx :aSelectorOrIndex |
claus
parents:
diff changeset
   165
	aSelectorOrIndex isInteger ifTrue:[
claus
parents:
diff changeset
   166
	    idx == lastIndex ifTrue:[
claus
parents:
diff changeset
   167
		obj at:aSelectorOrIndex put:newValue
claus
parents:
diff changeset
   168
	    ] ifFalse:[
claus
parents:
diff changeset
   169
		obj := obj at:aSelectorOrIndex
claus
parents:
diff changeset
   170
	    ]
claus
parents:
diff changeset
   171
	] ifFalse:[
claus
parents:
diff changeset
   172
	    idx == lastIndex ifTrue:[
claus
parents:
diff changeset
   173
		obj perform:(aSelectorOrIndex , ':') asSymbol with:newValue
claus
parents:
diff changeset
   174
	    ] ifFalse:[
claus
parents:
diff changeset
   175
		obj := obj perform:aSelectorOrIndex
claus
parents:
diff changeset
   176
	    ]
claus
parents:
diff changeset
   177
	]
claus
parents:
diff changeset
   178
    ].
claus
parents:
diff changeset
   179
    ^ newValue
claus
parents:
diff changeset
   180
!
claus
parents:
diff changeset
   181
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   182
value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   183
    "return the value from my subject or subjectChannel."
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   184
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   185
    |obj|
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   186
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   187
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   188
	obj := subject.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   189
    ] ifFalse:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   190
	obj := subjectChannel value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   191
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   192
    ^ self valueUsingSubject:obj
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   193
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   194
69
claus
parents:
diff changeset
   195
valueUsingSubject:anObject
claus
parents:
diff changeset
   196
    "return the value from anObject, using the selectors in accessPath.
claus
parents:
diff changeset
   197
     A helper for value."
claus
parents:
diff changeset
   198
claus
parents:
diff changeset
   199
    |obj|
claus
parents:
diff changeset
   200
claus
parents:
diff changeset
   201
    obj := anObject.
claus
parents:
diff changeset
   202
    accessPath notNil ifTrue:[
claus
parents:
diff changeset
   203
	accessPath do:[:aSelectorOrIndex |
claus
parents:
diff changeset
   204
	    aSelectorOrIndex isInteger ifTrue:[
claus
parents:
diff changeset
   205
		obj := obj at:aSelectorOrIndex
claus
parents:
diff changeset
   206
	    ] ifFalse:[
claus
parents:
diff changeset
   207
		obj := obj perform:aSelectorOrIndex
claus
parents:
diff changeset
   208
	    ]
claus
parents:
diff changeset
   209
	].
claus
parents:
diff changeset
   210
    ].
claus
parents:
diff changeset
   211
    ^ obj
claus
parents:
diff changeset
   212
! !
claus
parents:
diff changeset
   213
claus
parents:
diff changeset
   214
!ProtocolAdaptor methodsFor:'accessing-spec'!
claus
parents:
diff changeset
   215
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   216
accessPath
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   217
    ^ accessPath
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   218
!
69
claus
parents:
diff changeset
   219
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   220
accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   221
    accessPath := aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   222
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   223
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   224
subject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   225
    ^ subject
69
claus
parents:
diff changeset
   226
!
claus
parents:
diff changeset
   227
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   228
subject:anObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   229
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   230
	subject removeDependent:self
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   231
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   232
    subject := anObject.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   233
    self changed:#value.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   234
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   235
	subject addDependent:self
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   236
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   237
!
69
claus
parents:
diff changeset
   238
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   239
subjectChannel
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   240
    ^ subjectChannel
69
claus
parents:
diff changeset
   241
!
claus
parents:
diff changeset
   242
claus
parents:
diff changeset
   243
subjectChannel:aValueHolder
claus
parents:
diff changeset
   244
    |oldChannel|
claus
parents:
diff changeset
   245
100
claus
parents: 96
diff changeset
   246
    subjectChannel notNil ifTrue:[
claus
parents: 96
diff changeset
   247
	subjectChannel removeDependent:self
claus
parents: 96
diff changeset
   248
    ].
69
claus
parents:
diff changeset
   249
    oldChannel := subjectChannel.
claus
parents:
diff changeset
   250
    subjectChannel := aValueHolder.
100
claus
parents: 96
diff changeset
   251
    subjectChannel notNil ifTrue:[
claus
parents: 96
diff changeset
   252
	subjectChannel addDependent:self
claus
parents: 96
diff changeset
   253
    ].
69
claus
parents:
diff changeset
   254
    oldChannel notNil ifTrue:[
claus
parents:
diff changeset
   255
	self changed:#value.
claus
parents:
diff changeset
   256
    ].
100
claus
parents: 96
diff changeset
   257
claus
parents: 96
diff changeset
   258
    "Modified: 6.9.1995 / 01:19:27 / claus"
69
claus
parents:
diff changeset
   259
!
claus
parents:
diff changeset
   260
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   261
subjectSendsUpdates
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   262
    "return true, if the subject sends updates itself
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   263
     If true, the receiver will not send updates on changes"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   264
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   265
    ^ subjectSendsUpdates
69
claus
parents:
diff changeset
   266
!
claus
parents:
diff changeset
   267
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   268
subjectSendsUpdates:aBoolean
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   269
    "set/clear the flag which states if the subject sends updates itself.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   270
     If true, the receiver will not send updates on changes"
69
claus
parents:
diff changeset
   271
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   272
    subjectSendsUpdates := aBoolean.
69
claus
parents:
diff changeset
   273
! !
claus
parents:
diff changeset
   274
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   275
!ProtocolAdaptor methodsFor:'change & update'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   276
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   277
update:something with:aPArameter from:changedObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   278
    "translate updates from my subject into value-changes towards
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   279
     my dependents. Since I have no specific aspect, every change is forwarded"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   280
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   281
    (changedObject == subject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   282
    or:[changedObject == subjectChannel]) ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   283
	self changed:#value.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   284
	^ self
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   285
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   286
! !
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   287
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   288
!ProtocolAdaptor methodsFor:'change notification'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   289
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   290
changed:aspect
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   291
    subjectSendsUpdates ifFalse:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   292
	super changed:aspect
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   293
    ]
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   294
! !
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   295
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   296
!ProtocolAdaptor methodsFor:'initialization'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   297
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   298
initialize
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   299
    super initialize.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   300
    subjectSendsUpdates := false. 
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   301
! !
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   302
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   303
!ProtocolAdaptor class methodsFor:'documentation'!
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   304
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   305
version
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   306
    ^ '$Header: /cvs/stx/stx/libview2/ProtocolAdaptor.st,v 1.10 1996-04-17 23:56:10 cg Exp $'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   307
! !