ProtocolAdaptor.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Apr 1996 18:43:54 +0200
changeset 223 b65dc250db8d
parent 186 68bd07dcdfa7
child 231 2fec6188bd28
permissions -rw-r--r--
documentation
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.
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
    59
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
    60
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
    61
        Claus Gittinger
69
claus
parents:
diff changeset
    62
"
claus
parents:
diff changeset
    63
!
claus
parents:
diff changeset
    64
claus
parents:
diff changeset
    65
examples 
claus
parents:
diff changeset
    66
"
claus
parents:
diff changeset
    67
	|a obj|
claus
parents:
diff changeset
    68
claus
parents:
diff changeset
    69
	a := ProtocolAdaptor accessPath:#(1 2 3).
claus
parents:
diff changeset
    70
	obj := Array with:#(11 (121 122 123) 13)
claus
parents:
diff changeset
    71
		     with:#(21 (221 222 223) 23)
claus
parents:
diff changeset
    72
		     with:#(33 (321 322 323) 33).
claus
parents:
diff changeset
    73
	a valueUsingSubject:obj  
claus
parents:
diff changeset
    74
claus
parents:
diff changeset
    75
claus
parents:
diff changeset
    76
claus
parents:
diff changeset
    77
	|a obj|
claus
parents:
diff changeset
    78
claus
parents:
diff changeset
    79
	a := ProtocolAdaptor accessPath:#(1 2 origin).
claus
parents:
diff changeset
    80
	obj := Array with:(Array with:1@1 with:(1@2 corner:100@100))
claus
parents:
diff changeset
    81
		     with:(Array with:2@1 with:2@2)
claus
parents:
diff changeset
    82
		     with:(Array with:3@1 with:3@2).
claus
parents:
diff changeset
    83
	a valueUsingSubject:obj  
claus
parents:
diff changeset
    84
claus
parents:
diff changeset
    85
claus
parents:
diff changeset
    86
claus
parents:
diff changeset
    87
	|a model|
claus
parents:
diff changeset
    88
claus
parents:
diff changeset
    89
	a := ProtocolAdaptor accessPath:#(1 2 origin).
claus
parents:
diff changeset
    90
	model := (Array with:(Array with:1@1 with:(1@2 corner:100@100))
claus
parents:
diff changeset
    91
		     with:(Array with:2@1 with:2@2)
claus
parents:
diff changeset
    92
		     with:(Array with:3@1 with:3@2)) asValue.
claus
parents:
diff changeset
    93
	a subjectChannel:model.
claus
parents:
diff changeset
    94
	a value   
claus
parents:
diff changeset
    95
"
claus
parents:
diff changeset
    96
! !
claus
parents:
diff changeset
    97
claus
parents:
diff changeset
    98
!ProtocolAdaptor class methodsFor:'instance creation'!
claus
parents:
diff changeset
    99
claus
parents:
diff changeset
   100
accessPath:aCollectionOfSelectors
claus
parents:
diff changeset
   101
    ^ (self new) accessPath:aCollectionOfSelectors
claus
parents:
diff changeset
   102
!
claus
parents:
diff changeset
   103
claus
parents:
diff changeset
   104
subject:anObject
claus
parents:
diff changeset
   105
    ^ (self new) subject:anObject
claus
parents:
diff changeset
   106
!
claus
parents:
diff changeset
   107
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   108
subject:anObject accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   109
    ^ (self new) subject:anObject; accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   110
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   111
69
claus
parents:
diff changeset
   112
subject:anObject sendsUpdates:aBoolean
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   113
    ^ (self new) subject:anObject; subjectSendsUpdates:aBoolean
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   114
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   115
    "Modified: 18.4.1996 / 01:45:34 / cg"
69
claus
parents:
diff changeset
   116
!
claus
parents:
diff changeset
   117
claus
parents:
diff changeset
   118
subject:anObject sendsUpdates:aBoolean accessPath:aCollectionOfSelectors
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   119
    ^ (self new) subject:anObject; subjectSendsUpdates:aBoolean; accessPath:aCollectionOfSelectors
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   120
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   121
    "Modified: 18.4.1996 / 01:45:38 / cg"
69
claus
parents:
diff changeset
   122
!
claus
parents:
diff changeset
   123
claus
parents:
diff changeset
   124
subjectChannel:aValueHolder
claus
parents:
diff changeset
   125
    ^ (self new) subjectChannel:aValueHolder
claus
parents:
diff changeset
   126
!
claus
parents:
diff changeset
   127
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   128
subjectChannel:aValueHolder accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   129
    ^ (self new) subjectChannel:aValueHolder; accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   130
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   131
69
claus
parents:
diff changeset
   132
subjectChannel:aValueHolder sendsUpdates:aBoolean 
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   133
    ^ (self new) subjectChannel:aValueHolder; subjectSendsUpdates:aBoolean
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   134
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   135
    "Modified: 18.4.1996 / 01:45:45 / cg"
69
claus
parents:
diff changeset
   136
!
claus
parents:
diff changeset
   137
claus
parents:
diff changeset
   138
subjectChannel:aValueHolder sendsUpdates:aBoolean accessPath:aCollectionOfSelectors
186
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   139
    ^ (self new) subjectChannel:aValueHolder; subjectSendsUpdates:aBoolean; accessPath:aCollectionOfSelectors
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   140
68bd07dcdfa7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   141
    "Modified: 18.4.1996 / 01:45:50 / cg"
69
claus
parents:
diff changeset
   142
! !
claus
parents:
diff changeset
   143
claus
parents:
diff changeset
   144
!ProtocolAdaptor methodsFor:'accessing'!
claus
parents:
diff changeset
   145
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   146
setValue:newValue
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   147
    "set the value in my subject or subjectChannel."
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   148
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   149
    |obj|
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   150
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   151
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   152
	obj := subject.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   153
    ] ifFalse:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   154
	obj := subjectChannel value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   155
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   156
    ^ self setValue:newValue usingSubject:obj
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   157
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   158
69
claus
parents:
diff changeset
   159
setValue:newValue usingSubject:anObject
claus
parents:
diff changeset
   160
    "set a value in anObject, using the selectors in accessPath.
claus
parents:
diff changeset
   161
     A helper for setValue:."
claus
parents:
diff changeset
   162
claus
parents:
diff changeset
   163
    |obj lastIndex|
claus
parents:
diff changeset
   164
claus
parents:
diff changeset
   165
    obj := anObject.
claus
parents:
diff changeset
   166
    lastIndex := accessPath size.
claus
parents:
diff changeset
   167
    accessPath keysAndValuesDo:[:idx :aSelectorOrIndex |
claus
parents:
diff changeset
   168
	aSelectorOrIndex isInteger ifTrue:[
claus
parents:
diff changeset
   169
	    idx == lastIndex ifTrue:[
claus
parents:
diff changeset
   170
		obj at:aSelectorOrIndex put:newValue
claus
parents:
diff changeset
   171
	    ] ifFalse:[
claus
parents:
diff changeset
   172
		obj := obj at:aSelectorOrIndex
claus
parents:
diff changeset
   173
	    ]
claus
parents:
diff changeset
   174
	] ifFalse:[
claus
parents:
diff changeset
   175
	    idx == lastIndex ifTrue:[
claus
parents:
diff changeset
   176
		obj perform:(aSelectorOrIndex , ':') asSymbol with:newValue
claus
parents:
diff changeset
   177
	    ] ifFalse:[
claus
parents:
diff changeset
   178
		obj := obj perform:aSelectorOrIndex
claus
parents:
diff changeset
   179
	    ]
claus
parents:
diff changeset
   180
	]
claus
parents:
diff changeset
   181
    ].
claus
parents:
diff changeset
   182
    ^ newValue
claus
parents:
diff changeset
   183
!
claus
parents:
diff changeset
   184
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   185
value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   186
    "return the value from my subject or subjectChannel."
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   187
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   188
    |obj|
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   189
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   190
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   191
	obj := subject.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   192
    ] ifFalse:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   193
	obj := subjectChannel value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   194
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   195
    ^ self valueUsingSubject:obj
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   196
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   197
69
claus
parents:
diff changeset
   198
valueUsingSubject:anObject
claus
parents:
diff changeset
   199
    "return the value from anObject, using the selectors in accessPath.
claus
parents:
diff changeset
   200
     A helper for value."
claus
parents:
diff changeset
   201
claus
parents:
diff changeset
   202
    |obj|
claus
parents:
diff changeset
   203
claus
parents:
diff changeset
   204
    obj := anObject.
claus
parents:
diff changeset
   205
    accessPath notNil ifTrue:[
claus
parents:
diff changeset
   206
	accessPath do:[:aSelectorOrIndex |
claus
parents:
diff changeset
   207
	    aSelectorOrIndex isInteger ifTrue:[
claus
parents:
diff changeset
   208
		obj := obj at:aSelectorOrIndex
claus
parents:
diff changeset
   209
	    ] ifFalse:[
claus
parents:
diff changeset
   210
		obj := obj perform:aSelectorOrIndex
claus
parents:
diff changeset
   211
	    ]
claus
parents:
diff changeset
   212
	].
claus
parents:
diff changeset
   213
    ].
claus
parents:
diff changeset
   214
    ^ obj
claus
parents:
diff changeset
   215
! !
claus
parents:
diff changeset
   216
claus
parents:
diff changeset
   217
!ProtocolAdaptor methodsFor:'accessing-spec'!
claus
parents:
diff changeset
   218
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   219
accessPath
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   220
    ^ accessPath
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   221
!
69
claus
parents:
diff changeset
   222
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   223
accessPath:aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   224
    accessPath := aCollectionOfSelectors
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   225
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   226
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   227
subject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   228
    ^ subject
69
claus
parents:
diff changeset
   229
!
claus
parents:
diff changeset
   230
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   231
subject:anObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   232
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   233
	subject removeDependent:self
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   234
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   235
    subject := anObject.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   236
    self changed:#value.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   237
    subject notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   238
	subject addDependent:self
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   239
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   240
!
69
claus
parents:
diff changeset
   241
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   242
subjectChannel
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   243
    ^ subjectChannel
69
claus
parents:
diff changeset
   244
!
claus
parents:
diff changeset
   245
claus
parents:
diff changeset
   246
subjectChannel:aValueHolder
claus
parents:
diff changeset
   247
    |oldChannel|
claus
parents:
diff changeset
   248
100
claus
parents: 96
diff changeset
   249
    subjectChannel notNil ifTrue:[
claus
parents: 96
diff changeset
   250
	subjectChannel removeDependent:self
claus
parents: 96
diff changeset
   251
    ].
69
claus
parents:
diff changeset
   252
    oldChannel := subjectChannel.
claus
parents:
diff changeset
   253
    subjectChannel := aValueHolder.
100
claus
parents: 96
diff changeset
   254
    subjectChannel notNil ifTrue:[
claus
parents: 96
diff changeset
   255
	subjectChannel addDependent:self
claus
parents: 96
diff changeset
   256
    ].
69
claus
parents:
diff changeset
   257
    oldChannel notNil ifTrue:[
claus
parents:
diff changeset
   258
	self changed:#value.
claus
parents:
diff changeset
   259
    ].
100
claus
parents: 96
diff changeset
   260
claus
parents: 96
diff changeset
   261
    "Modified: 6.9.1995 / 01:19:27 / claus"
69
claus
parents:
diff changeset
   262
!
claus
parents:
diff changeset
   263
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   264
subjectSendsUpdates
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   265
    "return true, if the subject sends updates itself
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   266
     If true, the receiver will not send updates on changes"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   267
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   268
    ^ subjectSendsUpdates
69
claus
parents:
diff changeset
   269
!
claus
parents:
diff changeset
   270
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   271
subjectSendsUpdates:aBoolean
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   272
    "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
   273
     If true, the receiver will not send updates on changes"
69
claus
parents:
diff changeset
   274
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   275
    subjectSendsUpdates := aBoolean.
69
claus
parents:
diff changeset
   276
! !
claus
parents:
diff changeset
   277
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   278
!ProtocolAdaptor methodsFor:'change & update'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   279
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   280
update:something with:aPArameter from:changedObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   281
    "translate updates from my subject into value-changes towards
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   282
     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
   283
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   284
    (changedObject == subject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   285
    or:[changedObject == subjectChannel]) ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   286
	self changed:#value.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   287
	^ self
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   288
    ].
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
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   291
!ProtocolAdaptor methodsFor:'change notification'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   292
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   293
changed:aspect
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   294
    subjectSendsUpdates ifFalse:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   295
	super changed:aspect
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   296
    ]
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
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   299
!ProtocolAdaptor methodsFor:'initialization'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   300
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   301
initialize
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   302
    super initialize.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   303
    subjectSendsUpdates := false. 
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   304
! !
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   305
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   306
!ProtocolAdaptor class methodsFor:'documentation'!
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   307
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   308
version
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   309
    ^ '$Header: /cvs/stx/stx/libview2/ProtocolAdaptor.st,v 1.11 1996-04-25 16:42:59 cg Exp $'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   310
! !