--- a/PlugAdptr.st Fri Feb 21 19:09:11 1997 +0100
+++ b/PlugAdptr.st Fri Feb 21 20:38:15 1997 +0100
@@ -137,31 +137,29 @@
- extract values from a point into different labels:
+ extract values from an association into different labels:
[exBegin]
- |p t l|
+ |assoc t l|
- p := 10 @ 20.
+ assoc := 'hello' -> 'world'.
t := HorizontalPanelView new.
t extent:200@50.
t horizontalLayout:#fitSpace.
l := Label in:t.
- l model:((PluggableAdaptor on:p) getSelector:#x putSelector:#x:);
+ l model:((PluggableAdaptor on:assoc) getSelector:#key putSelector:#key:);
labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
+ level:-1.
l := Label in:t.
- l model:((PluggableAdaptor on:p) getSelector:#y putSelector:#y:);
+ l model:((PluggableAdaptor on:assoc) getSelector:#value putSelector:#value:);
labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
+ level:-1.
t open.
- (Delay forSeconds:5) wait.
- p x:100.
- p changed.
+ (Delay forSeconds:3) wait.
+ assoc key:'goodbye'.
+ assoc changed.
[exEnd]
extract values from an array into different labels:
@@ -191,7 +189,7 @@
sizeFixed:true.
t open.
- (Delay forSeconds:5) wait.
+ (Delay forSeconds:3) wait.
a at:1 put:'1'.
a changed.
[exEnd]
@@ -201,7 +199,12 @@
!PluggableAdaptor class methodsFor:'instance creation'!
on:anObject
+ "create & return a new protocolAdaptor.
+ Any get/put and updateBlocks are still to be defined"
+
^ self new model:anObject
+
+ "Modified: 21.2.1997 / 18:31:22 / cg"
! !
!PluggableAdaptor methodsFor:'accessing'!
@@ -218,20 +221,29 @@
^ getBlock value:model
].
^ model value "/ stupid default
+!
+
+valueUsingSubject:someObject
+ someObject isNil ifTrue:[^ nil].
+
+ ^ getBlock value:someObject
+
+ "Created: 21.2.1997 / 18:28:35 / cg"
! !
!PluggableAdaptor methodsFor:'changes'!
update:something with:aParameter from:changedObject
changedObject == model ifTrue:[
- updateBlock notNil ifTrue:[
- (updateBlock value:model value:something value:aParameter)
- ifTrue:[
-"/ self notifyChange:#value
- self changed:#value
- ]
- ]
+ updateBlock notNil ifTrue:[
+ (updateBlock value:model value:something value:aParameter)
+ ifTrue:[
+ self changed:#value
+ ]
+ ]
].
+
+ "Modified: 21.2.1997 / 18:28:52 / cg"
! !
!PluggableAdaptor methodsFor:'initialize-release'!
@@ -240,14 +252,16 @@
"configure the adaptor to translate #value/#value:-messages into
indexed accesses via #at:/#at:put:, using the supplied index"
- getBlock := [:model | model at:idx].
- putBlock := [:model :newValue | model at:idx put:newValue].
+ getBlock := [:model | model value at:idx].
+ putBlock := [:model :newValue | model value at:idx put:newValue].
updateBlock := [:model :aspect :parameter |
- aspect isNil or:[aspect == #value]
- ]
+ aspect isNil or:[aspect == #value]
+ ]
+
+ "Modified: 21.2.1997 / 18:20:24 / cg"
!
-getBlock:block1 putBlock:block2 updateBlock:block3
+getBlock:newGetBlock putBlock:newPutBlock updateBlock:newUpdateBlock
"configure the adaptor to translate #value/#value:-messages into
evaluation of the corresponding block1/block2.
The getBlock argument block1 is called with one argument, the model, and is
@@ -259,9 +273,11 @@
is called when the adaptor receives an update message from the model,
and should return true if a new value should be fetched from the model."
- getBlock := block1.
- putBlock := block2.
- updateBlock := block3.
+ getBlock := newGetBlock.
+ putBlock := newPutBlock.
+ updateBlock := newUpdateBlock.
+
+ "Modified: 21.2.1997 / 18:18:38 / cg"
!
getSelector:getSelector putSelector:putSelector
@@ -271,10 +287,12 @@
getBlock := [:model | model perform:getSelector].
putBlock := [:model :newValue | model perform:putSelector with:newValue].
updateBlock := [:model :aspect :parameter |
- aspect isNil
- or:[aspect == getSelector
- or:[aspect == #value]]
- ]
+ aspect isNil
+ or:[aspect == getSelector
+ or:[aspect == #value]]
+ ]
+
+ "Modified: 21.2.1997 / 18:21:27 / cg"
!
model:anObject
@@ -298,21 +316,43 @@
"configure the adaptor to behave like a boolean value, returning
true whenever the models value equals something"
- getBlock := [:model | model value = something].
- putBlock := [:model :newValue | newValue ifTrue:[model value:something]].
- updateBlock := [:model :aspect :parameter |
- aspect isNil or:[aspect == #value]
+"/ getBlock := [:model | model value = something].
+"/ putBlock := [:model :newValue | newValue ifTrue:[model value:something]].
+"/ updateBlock := [:model :aspect :parameter |
+"/ aspect isNil or:[aspect == #value]
+"/ ]
+
+ "/ changed for vw compatibility
+
+ |lastValue|
+
+ lastValue := nil.
+
+ getBlock := [:model | lastValue := (model value = something)].
+ putBlock := [:model :newValue | newValue
+ ifTrue:[model value:something]
+ ifFalse:[model value = something
+ ifTrue:[model value:nil]
+ ]
+ ].
+ updateBlock := [:model :aspect :parameter |
+ ((model value = something) = lastValue) not
]
"Modified: 31.12.1996 / 13:58:09 / stefan"
+ "Modified: 21.2.1997 / 18:27:26 / cg"
!
subjectChannel:aValueHolder
+ "setup to use aValueHolder as model"
+
self model:aValueHolder
+
+ "Modified: 21.2.1997 / 18:19:46 / cg"
! !
!PluggableAdaptor class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/Attic/PlugAdptr.st,v 1.13 1996-12-31 14:01:08 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/Attic/PlugAdptr.st,v 1.14 1997-02-21 19:38:15 cg Exp $'
! !
--- a/PluggableAdaptor.st Fri Feb 21 19:09:11 1997 +0100
+++ b/PluggableAdaptor.st Fri Feb 21 20:38:15 1997 +0100
@@ -137,31 +137,29 @@
- extract values from a point into different labels:
+ extract values from an association into different labels:
[exBegin]
- |p t l|
+ |assoc t l|
- p := 10 @ 20.
+ assoc := 'hello' -> 'world'.
t := HorizontalPanelView new.
t extent:200@50.
t horizontalLayout:#fitSpace.
l := Label in:t.
- l model:((PluggableAdaptor on:p) getSelector:#x putSelector:#x:);
+ l model:((PluggableAdaptor on:assoc) getSelector:#key putSelector:#key:);
labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
+ level:-1.
l := Label in:t.
- l model:((PluggableAdaptor on:p) getSelector:#y putSelector:#y:);
+ l model:((PluggableAdaptor on:assoc) getSelector:#value putSelector:#value:);
labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
+ level:-1.
t open.
- (Delay forSeconds:5) wait.
- p x:100.
- p changed.
+ (Delay forSeconds:3) wait.
+ assoc key:'goodbye'.
+ assoc changed.
[exEnd]
extract values from an array into different labels:
@@ -191,7 +189,7 @@
sizeFixed:true.
t open.
- (Delay forSeconds:5) wait.
+ (Delay forSeconds:3) wait.
a at:1 put:'1'.
a changed.
[exEnd]
@@ -201,7 +199,12 @@
!PluggableAdaptor class methodsFor:'instance creation'!
on:anObject
+ "create & return a new protocolAdaptor.
+ Any get/put and updateBlocks are still to be defined"
+
^ self new model:anObject
+
+ "Modified: 21.2.1997 / 18:31:22 / cg"
! !
!PluggableAdaptor methodsFor:'accessing'!
@@ -218,20 +221,29 @@
^ getBlock value:model
].
^ model value "/ stupid default
+!
+
+valueUsingSubject:someObject
+ someObject isNil ifTrue:[^ nil].
+
+ ^ getBlock value:someObject
+
+ "Created: 21.2.1997 / 18:28:35 / cg"
! !
!PluggableAdaptor methodsFor:'changes'!
update:something with:aParameter from:changedObject
changedObject == model ifTrue:[
- updateBlock notNil ifTrue:[
- (updateBlock value:model value:something value:aParameter)
- ifTrue:[
-"/ self notifyChange:#value
- self changed:#value
- ]
- ]
+ updateBlock notNil ifTrue:[
+ (updateBlock value:model value:something value:aParameter)
+ ifTrue:[
+ self changed:#value
+ ]
+ ]
].
+
+ "Modified: 21.2.1997 / 18:28:52 / cg"
! !
!PluggableAdaptor methodsFor:'initialize-release'!
@@ -240,14 +252,16 @@
"configure the adaptor to translate #value/#value:-messages into
indexed accesses via #at:/#at:put:, using the supplied index"
- getBlock := [:model | model at:idx].
- putBlock := [:model :newValue | model at:idx put:newValue].
+ getBlock := [:model | model value at:idx].
+ putBlock := [:model :newValue | model value at:idx put:newValue].
updateBlock := [:model :aspect :parameter |
- aspect isNil or:[aspect == #value]
- ]
+ aspect isNil or:[aspect == #value]
+ ]
+
+ "Modified: 21.2.1997 / 18:20:24 / cg"
!
-getBlock:block1 putBlock:block2 updateBlock:block3
+getBlock:newGetBlock putBlock:newPutBlock updateBlock:newUpdateBlock
"configure the adaptor to translate #value/#value:-messages into
evaluation of the corresponding block1/block2.
The getBlock argument block1 is called with one argument, the model, and is
@@ -259,9 +273,11 @@
is called when the adaptor receives an update message from the model,
and should return true if a new value should be fetched from the model."
- getBlock := block1.
- putBlock := block2.
- updateBlock := block3.
+ getBlock := newGetBlock.
+ putBlock := newPutBlock.
+ updateBlock := newUpdateBlock.
+
+ "Modified: 21.2.1997 / 18:18:38 / cg"
!
getSelector:getSelector putSelector:putSelector
@@ -271,10 +287,12 @@
getBlock := [:model | model perform:getSelector].
putBlock := [:model :newValue | model perform:putSelector with:newValue].
updateBlock := [:model :aspect :parameter |
- aspect isNil
- or:[aspect == getSelector
- or:[aspect == #value]]
- ]
+ aspect isNil
+ or:[aspect == getSelector
+ or:[aspect == #value]]
+ ]
+
+ "Modified: 21.2.1997 / 18:21:27 / cg"
!
model:anObject
@@ -298,21 +316,43 @@
"configure the adaptor to behave like a boolean value, returning
true whenever the models value equals something"
- getBlock := [:model | model value = something].
- putBlock := [:model :newValue | newValue ifTrue:[model value:something]].
- updateBlock := [:model :aspect :parameter |
- aspect isNil or:[aspect == #value]
+"/ getBlock := [:model | model value = something].
+"/ putBlock := [:model :newValue | newValue ifTrue:[model value:something]].
+"/ updateBlock := [:model :aspect :parameter |
+"/ aspect isNil or:[aspect == #value]
+"/ ]
+
+ "/ changed for vw compatibility
+
+ |lastValue|
+
+ lastValue := nil.
+
+ getBlock := [:model | lastValue := (model value = something)].
+ putBlock := [:model :newValue | newValue
+ ifTrue:[model value:something]
+ ifFalse:[model value = something
+ ifTrue:[model value:nil]
+ ]
+ ].
+ updateBlock := [:model :aspect :parameter |
+ ((model value = something) = lastValue) not
]
"Modified: 31.12.1996 / 13:58:09 / stefan"
+ "Modified: 21.2.1997 / 18:27:26 / cg"
!
subjectChannel:aValueHolder
+ "setup to use aValueHolder as model"
+
self model:aValueHolder
+
+ "Modified: 21.2.1997 / 18:19:46 / cg"
! !
!PluggableAdaptor class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/PluggableAdaptor.st,v 1.13 1996-12-31 14:01:08 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/PluggableAdaptor.st,v 1.14 1997-02-21 19:38:15 cg Exp $'
! !