browse/generate aspect methods
authorClaus Gittinger <cg@exept.de>
Fri, 11 Jan 2008 12:42:47 +0100
changeset 2235 ac5b46f34c53
parent 2234 f59c729ef3b2
child 2236 cc2b26c0d7f0
browse/generate aspect methods
UIPainter.st
--- a/UIPainter.st	Fri Jan 11 12:41:10 2008 +0100
+++ b/UIPainter.st	Fri Jan 11 12:42:47 2008 +0100
@@ -3958,6 +3958,52 @@
     UserPreferences current systemBrowserClass openInClass:cls selector:aspect
 !
 
+doBrowseAspectMethod:aspectSelector
+    self doBrowseAspectMethod:aspectSelector nameAs:aspectSelector
+!
+
+doBrowseAspectMethod:aspectSelector nameAs:aspectNameShown
+    |cls spec aspect code|
+
+    cls := self specClass.
+    cls isNil ifTrue:[
+        Dialog information:'No Application Class defined.'.
+        ^ self
+    ].
+
+    spec := painter specForSelection.
+    spec isNil ifTrue:[^ self].
+    aspect := spec perform:aspectSelector.
+    aspect isNil ifTrue:[
+        Dialog information:(resources 
+                                string:'Please enter a Method name for "%1" first.'
+                                with:(resources string:aspectNameShown) allBold).
+        ^ self
+    ].
+        
+    (cls implements:aspect asSymbol) ifFalse:[
+        (Dialog confirm:(resources 
+                            stringWithCRs:'%1 does not implement %2.\\Create ?'
+                            with:(cls name allBold)
+                            with:aspect allBold)) 
+        ifFalse:[
+            (Dialog confirm:(resources 
+                                stringWithCRs:'Browse implementors of %1 ?'
+                                with:aspect allBold)) 
+            ifTrue:[
+                UserPreferences current systemBrowserClass browseImplementorsOf:aspect
+            ].
+            ^ self
+        ].
+        code := painter
+            generateAspectMethodFor:aspect 
+            spec:nil 
+            inClass:cls.
+        code readStream fileIn.
+    ].
+    UserPreferences current systemBrowserClass openInClass:cls selector:aspect
+!
+
 doBrowseAspectMethods
     "opens a browser on the aspect methods"
 
@@ -4113,10 +4159,15 @@
     aspectList := OrderedCollection new.
 
     self aspectSelectorsAndTypesDo:
-        [:selector :type | 
+        [:selector :type |
+            |newEntry|
+
             ( #(#modelAspect channelAspect actionSelector valueSelector) includes:type) ifTrue:[
                 (cls includesSelector:selector) ifFalse:[
-                    aspectList add:( Array with:selector with:type ).
+                    newEntry := Array with:selector with:type.    
+                    (aspectList contains:[:entry | entry = newEntry]) ifFalse:[    
+                        aspectList add:newEntry.
+                    ]
                 ]
             ]
         ].