added: #aspectAt:ifAbsentPut: and #aspectAdaptorFor:on:
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 01 Sep 2011 11:32:25 +0200
changeset 2936 bb406f5441f1
parent 2935 c23f73a4b72e
child 2937 67ef44218dc0
added: #aspectAt:ifAbsentPut: and #aspectAdaptorFor:on:
ApplicationModel.st
--- a/ApplicationModel.st	Mon Jul 25 17:51:34 2011 +0200
+++ b/ApplicationModel.st	Thu Sep 01 11:32:25 2011 +0200
@@ -1247,6 +1247,7 @@
     "Modified: / 7.9.1998 / 23:37:00 / cg"
 ! !
 
+
 !ApplicationModel methodsFor:'binding access'!
 
 actionFor:aKey
@@ -2141,6 +2142,40 @@
 
 !ApplicationModel methodsFor:'easy bindings'!
 
+aspectAdaptorFor: aSymbolOrCollectionOfThose on:aValueModel
+
+    "Return an AspectAdaptor for given aspects on given value model. 
+
+     Aspects (aSymbolOrCollectionOfThose) may be a sigle aspect
+     or collection of aspects. In that case, a chain of AspectAdaptor
+     is build to access the value using given 'path'"
+
+
+    | adaptor path |
+
+    path := aSymbolOrCollectionOfThose isSymbol 
+                ifTrue:[Array with: aSymbolOrCollectionOfThose]
+                ifFalse:[aSymbolOrCollectionOfThose].
+    adaptor := aValueModel.
+    path do:
+        [:selector|
+        adaptor := (AspectAdaptor forAspect: selector)
+                        subjectChannel: adaptor].
+    ^adaptor
+
+    "Created: / 09-03-2010 / 08:44:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-03-2010 / 19:28:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 01-09-2011 / 10:30:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+aspectAt:aSymbol ifAbsentPut:aBlock
+
+    builder ifNil:[self createBuilder].
+    ^builder bindings at: aSymbol ifAbsentPut: aBlock
+
+    "Created: / 09-03-2010 / 08:37:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 registerInterestIn:aValueModel using:aSelectorOrArray
     "Register interest in a change in aValueModel using information in aSelectorOrArray.
      aSelectorOrArray can be one of three things:  
@@ -3876,7 +3911,7 @@
 !ApplicationModel class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.320 2011-07-25 14:00:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.321 2011-09-01 09:32:25 vrany Exp $'
 ! !
 
 ApplicationModel initialize!