slightly refactored to allow for more redefinition in a subclass
authorClaus Gittinger <cg@exept.de>
Mon, 19 Nov 2007 19:30:01 +0100
changeset 2197 873c7b960233
parent 2196 7e4e066ca7f5
child 2198 804e778590fc
slightly refactored to allow for more redefinition in a subclass (Expecco-UI-Painter)
UIPainterView.st
--- a/UIPainterView.st	Mon Nov 19 15:53:43 2007 +0100
+++ b/UIPainterView.st	Mon Nov 19 19:30:01 2007 +0100
@@ -1348,37 +1348,45 @@
     "Modified: / 25.10.1997 / 19:22:17 / cg"
 !
 
-generateWindowSpecMethodSource
-    |spec str code category cls mthd specCode|
+generateWindowSpec
+    |spec|
 
     spec := OrderedCollection new.
 
     self subViews do:[:aView|
-	|vSpec|
-
-	"/ care for wrapped views ...
-	vSpec := self fullSpecFor:aView.
-	vSpec isNil ifTrue:[
-	    aView subViews size == 1 ifTrue:[
-		vSpec := self fullSpecFor:(aView subViews first).
-	    ]
-	].
-	vSpec isNil ifTrue:[
-	    self warn:'Oops - could not create spec for some view'
-	].
-	spec add:vSpec
+        |vSpec|
+
+        "/ care for wrapped views ...
+        vSpec := self fullSpecFor:aView.
+        vSpec isNil ifTrue:[
+            aView subViews size == 1 ifTrue:[
+                vSpec := self fullSpecFor:(aView subViews first).
+            ]
+        ].
+        vSpec isNil ifTrue:[
+            self warn:'Oops - could not create spec for some view'
+        ].
+        spec add:vSpec
     ].
 
     spec := treeView generateFullSpecForComponents:spec named:methodName.
+    ^ spec
+!
+
+generateWindowSpecMethodSource
+    |spec str code category cls mthd specCode|
+
+    spec := self generateWindowSpec.
+
     str  := WriteStream on:String new.
     UISpecification prettyPrintSpecArray:spec on:str indent:5.
     specCode := str contents.
 
     (specCode includes:$!!) ifTrue:[
-	"/ oops - must be chunk format ...
-	str  := WriteStream on:String new.
-	str nextPutAllAsChunk:specCode.
-	specCode := str contents.
+        "/ oops - must be chunk format ...
+        str  := WriteStream on:String new.
+        str nextPutAllAsChunk:specCode.
+        specCode := str contents.
     ].
 
     "/ if that method already exists, do not overwrite the category
@@ -1387,37 +1395,37 @@
     cls := self resolveName:className.
 
     cls notNil ifTrue:[
-	(mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[
-	    category := mthd category.
-	]
+        (mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[
+            category := mthd category.
+        ]
     ].
 
     code := '!!'
-	    , className , ' class methodsFor:' , category storeString
-	    , '!!' , '\\'
-
-	    , methodName , '\'
-	    , ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!')
-	    , '\\    "\'
-	    , ('     UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\').
+            , className , ' class methodsFor:' , category storeString
+            , '!!' , '\\'
+
+            , methodName , '\'
+            , ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!')
+            , '\\    "\'
+            , ('     UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\').
 
     (cls notNil and:[cls isSubclassOf:ApplicationModel]) ifTrue:[
-	code := code
-	    , ('     ' , className , ' new openInterface:#' , methodName , '\').
+        code := code
+            , ('     ' , className , ' new openInterface:#' , methodName , '\').
     ].
 
     code := code
-	    ,(methodName = 'windowSpec'
-		ifTrue:['     ' , className , ' open\'] ifFalse: [''])
-	    , '    "\'.
+            ,(methodName = 'windowSpec'
+                ifTrue:['     ' , className , ' open\'] ifFalse: [''])
+            , '    "\'.
 
     code := code
-	    , '\'
-	    , '    <resource: #canvas>\\'
-	    , '    ^ ' , specCode
-	    , '\'
-	    , '!! !!'
-	    , '\\'.
+            , '\'
+            , '    <resource: #canvas>\\'
+            , '    ^ ' , specCode
+            , '\'
+            , '!! !!'
+            , '\\'.
 
     ^ code withCRs
 
@@ -1609,27 +1617,29 @@
 !
 
 setupFromSpec:specOrSpecArray
-
-    |spec builder|
+    |spec builder specWindow|
 
     Cursor wait showWhile: [
-	self removeAll.
-	specOrSpecArray notNil ifTrue:[
-	    spec    := UISpecification from:specOrSpecArray.
-	].
-	builder := UIBuilder new isEditing:true.
-	"set applicationClass, in order that subspecifications may be resolved"
-	className notNil ifTrue:[
-	    builder applicationClass:(self resolveName:className).
-	].
-	spec notNil ifTrue:[
-	    spec window setupView:self topView for:builder.
-	    self addSpec:(spec component) builder:builder in:self.
-	].
-	self realizeAllSubViews.
-	spec notNil ifTrue:[
-	    treeView setAttributesFromWindowSpec:(spec window)
-	].
+        self removeAll.
+        specOrSpecArray notNil ifTrue:[
+            spec    := UISpecification from:specOrSpecArray.
+        ].
+        builder := UIBuilder new isEditing:true.
+        "set applicationClass, in order that subspecifications may be resolved"
+        className notNil ifTrue:[
+            builder applicationClass:(self resolveName:className).
+        ].
+        spec notNil ifTrue:[
+            specWindow := spec window.
+        ].
+        specWindow notNil ifTrue:[
+            specWindow setupView:self topView for:builder.
+            self addSpec:(spec component) builder:builder in:self.
+        ].
+        self realizeAllSubViews.
+        specWindow notNil ifTrue:[
+            treeView setAttributesFromWindowSpec:specWindow
+        ].
     ].
 !