generateAspectSelectorsMethod
authorca
Thu, 17 Feb 2000 13:16:18 +0100
changeset 1358 c0116e25a2ac
parent 1357 ba372586f899
child 1359 ea946edbf5fb
generateAspectSelectorsMethod
UIPainterView.st
--- a/UIPainterView.st	Thu Feb 17 13:15:58 2000 +0100
+++ b/UIPainterView.st	Thu Feb 17 13:16:18 2000 +0100
@@ -868,6 +868,53 @@
     "Modified: / 29.7.1998 / 12:21:19 / cg"
 !
 
+generateAspectSelectorsMethod
+    "generate aspectSelectors method.
+     Return a string ready to compile into the application class."
+
+    |cls code spec|
+
+    className isNil ifTrue:[
+        self warn:'Set first the class!!'.
+        ^ nil
+    ].
+
+    (cls := self resolveName:className) isNil ifTrue:[
+        self warn:'Class ', className asString, ' does not exist!!'.
+        ^ nil
+    ].
+    spec := treeView exportedAspects.
+    spec size == 0 ifTrue:[^ nil].
+
+    "/ make it an array ...
+    spec := spec collect:[:entry |
+                entry type isNil ifTrue:[
+                    entry subAspect
+                ] ifFalse:[
+                    Array with:entry subAspect with:entry type
+                ].
+            ].
+    spec := spec asArray.
+
+    code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' .
+
+    code := code , 'aspectSelectors
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this. If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "Return a description of exported aspects;
+     these can be connected to aspects of an embedding application
+     (if this app is embedded in a subCanvas)."
+
+    ^ ' , spec storeString , '\!!\'.
+    code := code withCRs.
+    ^ code
+
+!
+
 generateCodeFrom:aListOfSelectors in:aClass do:aBlock
 
     self class redefineAspectMethods ifTrue:[