--- a/ProtocolAdaptor.st Sat Apr 27 19:56:35 1996 +0200
+++ b/ProtocolAdaptor.st Sat Apr 27 19:59:26 1996 +0200
@@ -46,52 +46,65 @@
the editField, returning a value from the complex model,
and forwards changes to the complex model.
- Notice: since you can specify the aspect- and changeSymbols in most ST/X
- widgets, ProtocolAdapters are not always needed (at least, if no access-
- path is required).
- However, if you want to apply widgets on objects which where not originally
- designed as models (such as Arrays), ProtocolAdapters are very useful.
+ Notice:
+ since you can specify the aspect- and changeSymbols in most ST/X
+ widgets, ProtocolAdapters are not always needed
+ (at least, if no accesspath is required).
+ However, if you want to apply widgets on objects which where not
+ originally designed as models (such as Arrays), ProtocolAdapters
+ are very handy.
- Notice: this class was implemented using protocol information
- from alpha testers - it may not be complete or compatible to
- the corresponding ST-80 class. If you encounter any incompatibilities,
- please forward a note to the ST/X team.
+ Notice:
+ this class was implemented using protocol information
+ from alpha testers - it may not be complete or compatible to
+ the corresponding ST-80 class.
+ If you encounter any incompatibilities, please forward a note
+ describing the incompatibility verbal (i.e. no code) to the ST/X team.
[author:]
Claus Gittinger
+
+ [see also:]
+ Model AspectAdaptor ValueHolder
"
!
examples
"
- |a obj|
+ [exBegin]
+ |a obj|
- a := ProtocolAdaptor accessPath:#(1 2 3).
- obj := Array with:#(11 (121 122 123) 13)
- with:#(21 (221 222 223) 23)
- with:#(33 (321 322 323) 33).
- a valueUsingSubject:obj
+ a := ProtocolAdaptor accessPath:#(1 2 3).
+ obj := Array with:#(11 (121 122 123) 13)
+ with:#(21 (221 222 223) 23)
+ with:#(33 (321 322 323) 33).
+ a valueUsingSubject:obj
+ [exEnd]
- |a obj|
+ [exBegin]
+ |a obj|
- a := ProtocolAdaptor accessPath:#(1 2 origin).
- obj := Array with:(Array with:1@1 with:(1@2 corner:100@100))
- with:(Array with:2@1 with:2@2)
- with:(Array with:3@1 with:3@2).
- a valueUsingSubject:obj
+ a := ProtocolAdaptor accessPath:#(1 2 origin).
+ obj := Array with:(Array with:1@1 with:(1@2 corner:100@100))
+ with:(Array with:2@1 with:2@2)
+ with:(Array with:3@1 with:3@2).
+ a valueUsingSubject:obj
+ [exEnd]
- |a model|
+ [exBegin]
+ |a model|
- a := ProtocolAdaptor accessPath:#(1 2 origin).
- model := (Array with:(Array with:1@1 with:(1@2 corner:100@100))
- with:(Array with:2@1 with:2@2)
- with:(Array with:3@1 with:3@2)) asValue.
- a subjectChannel:model.
- a value
+ a := ProtocolAdaptor accessPath:#(1 2 origin).
+ model := (Array with:(Array with:1@1 with:(1@2 corner:100@100))
+ with:(Array with:2@1 with:2@2)
+ with:(Array with:3@1 with:3@2)) asValue.
+ a subjectChannel:model.
+ a value
+ [exEnd]
"
! !
@@ -217,48 +230,71 @@
!ProtocolAdaptor methodsFor:'accessing-spec'!
accessPath
+ "return the access path"
+
^ accessPath
+
+ "Modified: 27.4.1996 / 16:20:48 / cg"
!
accessPath:aCollectionOfSelectors
+ "set the access path"
+
accessPath := aCollectionOfSelectors
+
+ "Modified: 27.4.1996 / 16:20:53 / cg"
!
subject
+ "return the subject"
+
^ subject
+
+ "Modified: 27.4.1996 / 16:21:03 / cg"
!
subject:anObject
+ "set the subject"
+
subject notNil ifTrue:[
- subject removeDependent:self
+ subject removeDependent:self
].
subject := anObject.
self changed:#value.
subject notNil ifTrue:[
- subject addDependent:self
+ subject addDependent:self
].
+
+ "Modified: 27.4.1996 / 16:21:09 / cg"
!
subjectChannel
+ "return the subjectChannel"
+
^ subjectChannel
+
+ "Modified: 27.4.1996 / 16:21:21 / cg"
!
subjectChannel:aValueHolder
+ "set the subjectChannel"
+
|oldChannel|
subjectChannel notNil ifTrue:[
- subjectChannel removeDependent:self
+ subjectChannel removeDependent:self
].
oldChannel := subjectChannel.
subjectChannel := aValueHolder.
subjectChannel notNil ifTrue:[
- subjectChannel addDependent:self
+ subjectChannel addDependent:self
].
oldChannel notNil ifTrue:[
- self changed:#value.
+ self changed:#value.
].
"Modified: 6.9.1995 / 01:19:27 / claus"
+ "Modified: 27.4.1996 / 16:21:26 / cg"
!
subjectSendsUpdates
@@ -291,20 +327,28 @@
!ProtocolAdaptor methodsFor:'change notification'!
changed:aspect
+ "redefined to suppress change notifications, if my subject already did it"
+
subjectSendsUpdates ifFalse:[
- super changed:aspect
+ super changed:aspect
]
+
+ "Modified: 27.4.1996 / 16:20:28 / cg"
! !
!ProtocolAdaptor methodsFor:'initialization'!
initialize
+ "setup, assuming that the subject does not send change notifications"
+
super initialize.
- subjectSendsUpdates := false.
+ subjectSendsUpdates := false.
+
+ "Modified: 27.4.1996 / 16:21:56 / cg"
! !
!ProtocolAdaptor class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/ProtocolAdaptor.st,v 1.11 1996-04-25 16:42:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/ProtocolAdaptor.st,v 1.12 1996-04-27 17:58:56 cg Exp $'
! !