prettyPrintSpecArray:on:indent: to UISpecification class
authorca
Thu, 06 Mar 1997 15:58:30 +0100
changeset 86 06bdbae8bd8e
parent 85 23e9aebcbe35
child 87 cc6d70449622
prettyPrintSpecArray:on:indent: to UISpecification class generate unique name also for instances without any name
UIPainterView.st
--- a/UIPainterView.st	Thu Mar 06 15:56:42 1997 +0100
+++ b/UIPainterView.st	Thu Mar 06 15:58:30 1997 +0100
@@ -250,52 +250,6 @@
 
 !UIPainterView methodsFor:'generating output'!
 
-XXgenerateWindowSpecMethodSource
-    |spec specArray str code|
-
-    subViews remove:inputView.
-    [
-        spec := FullSpec fromView:self
-    ] valueNowOrOnUnwindDo:[
-        subViews addFirst:inputView.
-    ].
-    specArray := spec literalArrayEncoding.
-
-    str := WriteStream on:String new.
-    self prettyPrintSpecArray:specArray on:str indent:5.
-
-    code := Character excla asString 
-            , className , ' class methodsFor:''interface specs'''
-            , Character excla asString , '\\'
-
-            , methodName , '\'
-            , '    "this window spec was automatically generated by the ST/X UIPainter"\\'
-            , '    "do not manually edit this - the painter/builder may not be able to\'
-            , '     handle the specification if its corrupted."\\'
-            , '    "\'
-            , '     UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\'
-            , '     ' , className , ' new openInterface:#' , methodName , '\'
-            , '    "\'.
-
-    methodName = 'windowSpec' ifTrue:[
-        code := code , '    "' , className , ' open"\'
-    ].
-    code := code 
-            , '\'
-            , '    <resource: #canvas>\\'
-            , '    ^\' 
-            , '     ', str contents
-            , '\'
-            , Character excla asString
-            , ' '
-            , Character excla asString
-            , '\\'.
-
-    ^ code withCRs
-
-    "Modified: 5.9.1995 / 21:01:35 / claus"
-!
-
 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
     ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
       aspect , '\' ,
@@ -578,7 +532,7 @@
     specArray := spec literalArrayEncoding.
 
     str := WriteStream on:String new.
-    self prettyPrintSpecArray:specArray on:str indent:5.
+    UISpecification prettyPrintSpecArray:specArray on:str indent:5.
 
     code := Character excla asString 
             , className , ' class methodsFor:''interface specs'''
@@ -642,80 +596,6 @@
 
 !
 
-prettyPrintSpecArray:spec on:aStream indent:i
-    "just for your convenience: prettyPrint a specArray to aStream - it looks better that way"
-
-    |what oneLine|
-
-    spec isArray ifFalse:[
-        spec isLiteral ifTrue:[
-            aStream nextPutAll:spec storeString
-        ] ifFalse:[
-            self halt.
-        ].
-        ^ self
-    ].
-
-    spec isEmpty ifTrue:[
-        aStream nextPutAll:'#()'.
-        ^ self
-    ].
-
-    what := spec at:1.
-    what isArray ifTrue:[
-        aStream cr; spaces:i+2.
-        aStream nextPutAll:'#('.
-        "/ a spec-collection
-        spec do:[:element |
-            self prettyPrintSpecArray:element on:aStream indent:i+2.
-        ].
-        aStream cr.
-        aStream spaces:i+1.
-        aStream nextPutAll:')'.
-        ^ self.
-    ].
-
-    oneLine := false.
-    (#(#LayoutFrame #LayoutOrigin #AlignmentOrigin 
-       #Rectangle #Point
-       #Color #ColorValue
-    ) 
-    includesIdentical:what) ifTrue:[
-        oneLine := true
-    ].
-
-    oneLine ifFalse:[
-        aStream cr.
-        aStream spaces:i+2.
-    ].
-    aStream nextPutAll:'#('.
-
-
-    aStream nextPutAll:what storeString.
-
-    oneLine ifFalse:[
-        aStream cr.
-        aStream spaces:i+4.
-    ].
-
-    2 to:spec size do:[:index |
-        aStream space.
-        self prettyPrintSpecArray:(spec at:index) on:aStream indent:i+4.
-        oneLine ifFalse:[
-            (index odd and:[index ~~ (spec size)]) ifTrue:[
-                aStream cr; spaces:i+4.
-            ]
-        ]
-    ].
-    oneLine ifFalse:[
-        aStream cr.
-        aStream spaces:i+1.
-    ].
-    aStream nextPutAll:')'.
-
-    "Modified: 5.9.1995 / 17:44:20 / claus"
-!
-
 storeContentsOn:aStream
     viewProperties do:[:p| p storeOn:aStream]
 !
@@ -1223,14 +1103,20 @@
 !
 
 uniqueNameOf:aView
-    |prop|
+    |name prop|
 
     aView notNil ifTrue:[
         prop := self propertyOfView:aView
     ].
+    prop isNil ifTrue:[
+        ^ 'self'
+    ].
+    (name := prop name) isNil ifTrue:[
+        name := self uniqueNameFor:(aView class).
+        prop name:name.
+    ].
+    ^ name
 
-    prop notNil ifTrue:[^ prop name]
-               ifFalse:[^ 'self']
 ! !
 
 !UIPainterView methodsFor:'selection'!