more changes to allow for non-class/selector (i.e. spec-only) use
authorClaus Gittinger <cg@exept.de>
Mon, 18 Feb 2008 09:37:53 +0100
changeset 2276 485bda17023f
parent 2275 b0f6890e73cf
child 2277 342f25e2c276
more changes to allow for non-class/selector (i.e. spec-only) use
UIPainterView.st
--- a/UIPainterView.st	Mon Feb 11 15:21:58 2008 +0100
+++ b/UIPainterView.st	Mon Feb 18 09:37:53 2008 +0100
@@ -14,7 +14,7 @@
 UIObjectView subclass:#UIPainterView
 	instanceVariableNames:'treeView listHolder superclassName className methodName
 		categoryName handleColorBlack handleColorWhite handleMasterColor
-		sketchPainter'
+		sketchPainter listOfAspectsHolder'
 	classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances
 		GenerateCommentedCode'
 	poolDictionaries:''
@@ -170,6 +170,10 @@
     methodName     := aSelector.
 !
 
+listOfAspectsHolder:something
+    listOfAspectsHolder := something.
+!
+
 methodName
     ^ methodName
 !
@@ -424,6 +428,8 @@
     (self canPaste:aSpecificationOrList into:containerToPasteInto)
     "(self canPaste:aSpecificationOrList)" 
     ifFalse:[
+self halt.
+(self canPaste:aSpecificationOrList into:containerToPasteInto).
         Dialog warn:'Cannot paste into selected component (not a container ?)'.
         ^ nil
     ].
@@ -611,23 +617,19 @@
 canPaste:something into:containerToPasteInto
     "returns true if something could be pasted"
 
-    |el size|
-
-    ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[
+    (self enabled) ifFalse:[
         ^ false
     ].
-    something isCollection 
-        ifTrue:[something notEmpty ifTrue:[el := something first]]
-        ifFalse:[el := something].
-
-    (el isKindOf:UISpecification) ifFalse:[
+    something isCollection ifTrue:[
+        something isEmpty ifTrue:[ ^ false].
+        ^ something conform:[:el | (self canPaste:el into:containerToPasteInto)]
+    ].
+
+    (something isKindOf:UISpecification) ifFalse:[
         ^ false
     ].
 
-    size == 1 ifTrue:[
-        ^ self canPasteInto:containerToPasteInto
-    ].
-    ^ true
+    ^ self canPasteInto:containerToPasteInto
 !
 
 canPasteInto:aView
@@ -1454,23 +1456,23 @@
 
     |cls code menuSelector thisCode
      definedMethodSelectors
-     specArray fullSpec winSpec menuSpec
-     |
+     spec specArray fullSpec winSpec menuSpec|
 
     cls := self targetClass.
     cls isNil ifTrue:[
-	^ nil
+        ^ nil
     ].
 
-    specArray := treeView generateFullSpecForComponents:#() named:nil.
+    spec := treeView generateFullSpecForComponents:#() named:nil.
+    specArray := spec literalArrayEncoding.
     fullSpec := specArray decodeAsLiteralArray.
     winSpec := fullSpec window.
     menuSelector := winSpec menu.
 
     (menuSelector notNil
     and:[ (cls respondsTo:menuSelector) ]) ifFalse:[
-	self warn:'No menu defined (yet)'.
-	^ nil.
+        self warn:'No menu defined (yet)'.
+        ^ nil.
     ].
     menuSpec := cls perform:menuSelector.
     menuSpec := menuSpec decodeAsLiteralArray.
@@ -1479,24 +1481,24 @@
     code := ''.
 
     menuSpec allItemsDo:[:item |
-	|sel|
-
-	(sel := item value) notNil ifTrue:[
-	    (definedMethodSelectors includes:sel) ifFalse:[
-		self generateCodeFrom:(Array with:sel) in:cls do:[:aSel|
-		    thisCode := (self generateMenuMethodFor:aSel inClass:cls).
-		    code := code, thisCode.
-		].
-		definedMethodSelectors add:sel.
-	    ].
-	]
+        |sel|
+
+        (sel := item value) notNil ifTrue:[
+            (definedMethodSelectors includes:sel) ifFalse:[
+                self generateCodeFrom:(Array with:sel) in:cls do:[:aSel|
+                    thisCode := (self generateMenuMethodFor:aSel inClass:cls).
+                    code := code, thisCode.
+                ].
+                definedMethodSelectors add:sel.
+            ].
+        ]
     ].
 
     (definedMethodSelectors includes:#menuOpen) ifTrue:[
-	self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel|
-	    thisCode := (self generateMenuMethodFor:aSel inClass:cls).
-	    code := code, thisCode.
-	].
+        self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel|
+            thisCode := (self generateMenuMethodFor:aSel inClass:cls).
+            code := code, thisCode.
+        ].
     ].
 
     ^ code
@@ -1548,12 +1550,13 @@
 !
 
 generateWindowSpecMethodSource
-    |spec str code category cls mthd specCode|
+    |spec specArray str code category cls mthd specCode|
 
     spec := self generateWindowSpec.
+    specArray := spec literalArrayEncoding.
 
     str  := WriteStream on:String new.
-    UISpecification prettyPrintSpecArray:spec on:str indent:5.
+    UISpecification prettyPrintSpecArray:specArray on:str indent:5.
     specCode := str contents.
 
     (specCode includes:$!!) ifTrue:[
@@ -1610,6 +1613,10 @@
 listOfAspects
     |cls aspects|
 
+    listOfAspectsHolder notNil ifTrue:[
+        ^ listOfAspectsHolder value
+    ].
+
     aspects := IdentitySet new.
 
     cls := self targetClass.
@@ -1971,6 +1978,14 @@
 
 !UIPainterView methodsFor:'queries'!
 
+isEditingSpecOnly
+    self halt.
+!
+
+isNotEditingSpecOnly
+    self halt.
+!
+
 resolveName:aName
     |appl|