--- a/AspectAdaptor.st Thu Mar 31 10:49:15 2022 +0100
+++ b/AspectAdaptor.st Tue Aug 09 21:18:05 2022 +0100
@@ -1,5 +1,6 @@
"
COPYRIGHT (c) 1995 by Claus Gittinger
+ COPYRIGHT (c) 2022 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -25,6 +26,7 @@
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
+ COPYRIGHT (c) 2022 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -69,7 +71,7 @@
examples
"
- a dialog on a points x/y coordinates:
+ a dialog on a point's x/y coordinates:
[exBegin]
|dialog data f|
@@ -141,6 +143,40 @@
Transcript showCR:'data now: ' , data printString
]
[exEnd]
+
+ a dialog on elements of a dictionary:
+ (notice: the dicationary elements change as soon as a field of the dialog is
+ left - i.e. I write immediately to the model)
+ [exBegin]
+ |dialog data|
+
+ data := JSONObject new
+ at:'Name' put:'Fritz';
+ at:'Tel' put:'1234567';
+ at:'City' put:'Stuttgart';
+ yourself.
+
+ dialog := DialogBox new.
+ dialog addTextLabel:'Name:'.
+ dialog addInputFieldOn:(AspectAdaptor new
+ subject:data;
+ accessWith:#Name
+ assignWith:#Name:).
+ dialog addTextLabel:'Tel:'.
+ dialog addInputFieldOn:(AspectAdaptor new
+ subject:data;
+ forAspect:#Tel).
+ dialog addTextLabel:'City:'.
+ dialog addInputFieldOn:(AspectAdaptor new
+ subject:data;
+ forAspect:#City).
+ dialog addOkButton.
+ data inspect.
+ dialog open.
+ dialog accepted ifTrue:[
+ Transcript showCR:'data now: ' , data printString
+ ]
+ [exEnd]
"
! !
@@ -148,19 +184,47 @@
accessWith:getSelector assignWith:putSelector
"create and return an adaptor which uses getSelector to fetch a value
- and setSelector to change it."
+ from the subject and setSelector to change it.
+ The returned object can be used in place of a ValueHolder"
^ (self new) accessWith:getSelector assignWith:putSelector
+
+ "Modified (comment): / 25-07-2022 / 08:21:28 / cg"
!
forAspect:anAspect
"create and return a new adaptor, which forwards requests
- to anObject, using anAspect as get-selector and anAspect-colon as putSelector
- for access. The returned object can be used in place of a ValueHolder"
+ to the subject, using anAspect as get-selector and anAspect-colon as putSelector
+ for access.
+ The returned object can be used in place of a ValueHolder"
^ self new forAspect:anAspect
- "Modified: 22.1.1997 / 12:00:42 / cg"
+ "Modified: / 22-01-1997 / 12:00:42 / cg"
+ "Modified (comment): / 25-07-2022 / 08:20:55 / cg"
+!
+
+forAspect:anAspect subject:anObject
+ "create and return a new adaptor, which forwards requests
+ to anObject, using anAspect as get-selector and anAspect-colon as putSelector
+ for access.
+ The returned object can be used in place of a ValueHolder"
+
+ ^ (self new forAspect:anAspect) subject:anObject
+
+ "Created: / 25-07-2022 / 08:20:17 / cg"
+!
+
+forAspect:anAspect subjectChannel:aSubjectProvider
+ "create and return a new adaptor, which forwards requests
+ to the object provided by aSubjectProvider,
+ accessing the subject via #value from aSubjectProvider.
+ using anAspect as get-selector and anAspect-colon as putSelector for access.
+ The returned object can be used in place of a ValueHolder"
+
+ ^ (self new forAspect:anAspect) subjectChannel:aSubjectProvider
+
+ "Created: / 25-07-2022 / 08:22:33 / cg"
!
subject:anObject sendsUpdates:aBoolean accessWith:getSel assignWith:putSel aspect:aspect
@@ -198,31 +262,35 @@
!
aspect:aSelector
- "set the adapters change aspect - this is the aspect of the update message,
+ "set the adaptor's change aspect - this is the aspect of the update message,
on which the adaptor reacts"
myAspect := aSelector.
+
+ "Modified (comment): / 25-07-2022 / 08:19:45 / cg"
!
forAspect
- "get the adapters aspect - if none was defined, the getMsg is returned"
+ "get the adaptor's aspect - if none was defined, the getMsg is returned"
myAspect isNil ifTrue:[
^ getMsg
].
^ myAspect
- "Modified: 22.1.1997 / 18:27:24 / cg"
+ "Modified: / 22-01-1997 / 18:27:24 / cg"
+ "Modified (comment): / 25-07-2022 / 08:19:53 / cg"
!
forAspect:aSelector
- "set the adapters aspect - this sets both the get- and put-Messages
+ "set the adaptor's aspect - this sets both the get- and put-Messages
(the putMessage is the aspect with a colon)"
getMsg := myAspect := aSelector.
putMsg := aSelector asMutator.
- "Modified: 22.1.1997 / 18:29:05 / cg"
+ "Modified: / 22-01-1997 / 18:29:05 / cg"
+ "Modified (comment): / 25-07-2022 / 08:19:49 / cg"
! !
!AspectAdaptor methodsFor:'accessing-value'!
@@ -298,9 +366,29 @@
].
! !
+!AspectAdaptor methodsFor:'printing'!
+
+displayOn:aStreamOrGC
+ aStreamOrGC isStream ifFalse:[
+ ^ super displayOn:aStreamOrGC
+ ].
+ aStreamOrGC nextPutAll:(self class name); nextPutAll:'('.
+ aStreamOrGC store:getMsg.
+ aStreamOrGC nextPutAll:' to '.
+ (subject ? subjectChannel) displayOn:aStreamOrGC.
+ aStreamOrGC nextPutAll:')'.
+
+ "Created: / 10-03-2022 / 08:25:24 / exept MBP"
+! !
+
!AspectAdaptor class methodsFor:'documentation'!
version
^ '$Header$'
+!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
! !