overwriting existing method check (in #defineClass & selector);
authorClaus Gittinger <cg@exept.de>
Thu, 17 Aug 2000 17:38:27 +0200
changeset 1394 97a7eeabae40
parent 1393 c4a11a7d407f
child 1395 b14fb13132c2
overwriting existing method check (in #defineClass & selector); correctly set initial label & name for new applications
UIPainter.st
--- a/UIPainter.st	Wed Aug 16 19:25:32 2000 +0200
+++ b/UIPainter.st	Thu Aug 17 17:38:27 2000 +0200
@@ -2886,16 +2886,25 @@
 openInterface:aSymbol
     "opens the interface on the selector aSymbol"
 
-    |cls painterView painter topView galleryWindow icon|
+    |cls painterView painter topView galleryWindow icon name|
 
     modified := false.
 
     aspects := IdentityDictionary new.
 
+    specClass notNil ifTrue:[
+        specClass isBehavior ifTrue:[
+            name := specClass nameWithoutPrefix.
+        ] ifFalse:[
+            name := specClass printString string
+        ]
+    ].
+
     aspects at:#classNameChannel put:(
         (specClass notNil ifTrue:[specClass]
                          ifFalse:['NewApplication']) asValue
     ).
+
     specSuperclass isNil ifTrue:[
         specClass notNil ifTrue:[
             (cls := self resolveName:specClass) notNil ifTrue:[
@@ -2917,14 +2926,15 @@
 
     treeView    := TreeView new.
     painterView := StandardSystemView new.
-    painterView name: self class defaultNameOfCanvas.
-    painterView label: self class defaultNameOfCanvas.
+
+    painterView name: name.
+    painterView label: name.
     painterView extent:300@300.
 
     painter := UIPainterView in:painterView.
     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
 
-    treeView := treeView canvas:painter.
+    treeView := treeView canvas:painter specName:name.
     painter treeView:treeView.
     treeView model addDependent:self.
 
@@ -2959,7 +2969,6 @@
     galleryWindow icon:icon.
 
     painterView topView raise.
-
 !
 
 openOnClass:aClass
@@ -3230,10 +3239,19 @@
                 self painter className:specClass
                         superclassName:specSuperclass
                               selector:specSelector.
-            ]
-        ]
-        ifFalse:
-        [
+            ].
+
+            again ifFalse:[
+                ((Smalltalk at:specClass asSymbol) notNil
+                and:[ (Smalltalk at:specClass asSymbol) class implements:specSelector ])
+                ifTrue:[
+                    (self confirm:('%1 already implements %2. Overwrite ?' bindWith:specClass with:specSelector))
+                    ifFalse:[
+                        again := true.
+                    ].
+                ].
+            ].
+        ] ifFalse: [
             ^nil
         ]
 
@@ -3666,6 +3684,19 @@
 
 !
 
+canvas:aCanvas specName:nameOfSpec
+    "install canvas (UIPainterView)"
+
+    |props|
+
+    props := UIPainterView::ViewProperty new.
+    props view:aCanvas.
+    model root:(TreeItem name:nameOfSpec asBoldText contents:props).
+    model root expand.
+    self enableChannel:(aCanvas enableChannel).
+
+!
+
 canvasSpec
     "returns spec assigned to canvas"