changed: #switchToClassNameOrSelectorMatching:
authorClaus Gittinger <cg@exept.de>
Mon, 02 Nov 2009 14:00:11 +0100
changeset 9158 8f7b051d53a0
parent 9157 c8166dbf5a5a
child 9159 483f9635923b
changed: #switchToClassNameOrSelectorMatching:
NewSystemBrowser.st
Tools__NewSystemBrowser.st
--- a/NewSystemBrowser.st	Mon Nov 02 13:59:53 2009 +0100
+++ b/NewSystemBrowser.st	Mon Nov 02 14:00:11 2009 +0100
@@ -35765,7 +35765,7 @@
 !
 
 switchToClassNameOrSelectorMatching:aMatchString
-    |className class implementors answer|
+    |className class implementors answer classesMatchingCaseless|
 
     aMatchString knownAsSymbol ifTrue:[
         class := Smalltalk classNamed:aMatchString.
@@ -35773,6 +35773,8 @@
             self switchToClass:class.
             ^ self.
         ].
+        classesMatchingCaseless := Smalltalk keys select:[:nm | nm sameAs:aMatchString].
+
 "/        impl := Smalltalk allImplementorsOf:aMatchString asSymbol.
 "/        impl notEmptyOrNil ifTrue:[
 "/        ].
@@ -35780,7 +35782,7 @@
         or:[ aMatchString first isLowercase]) ifTrue:[
             implementors := SystemBrowser findImplementorsMatching:aMatchString in:(Smalltalk allClasses) ignoreCase:true.
             implementors size > 0 ifTrue:[
-                implementors size == 1 ifTrue:[
+                (classesMatchingCaseless isEmpty and:[implementors size == 1]) ifTrue:[
                     answer := Dialog 
                         confirm:(resources 
                                         stringWithCRs:'No class named "%1".\But "%2" implements it. Go there ?' 
@@ -35792,19 +35794,41 @@
                     ^ self.
                 ].
                 implementors := implementors asOrderedCollection sort:[:a :b | a mclass name < b mclass name].
-                answer := Dialog 
-                    choose:(resources 
-                                    stringWithCRs:'No class named "%1.\But there are %2 implementors of it. Goto one of them ?' 
-                                    with:aMatchString allBold
-                                    with:implementors size)
-                    fromList:(implementors collect:[:m | m mclass name])
-                    values:implementors 
-                    buttons:#('No, Search for a Class') values:#(searchClass) 
-                    lines:10 cancel:nil.
+                classesMatchingCaseless isEmpty ifTrue:[
+                    answer := Dialog 
+                        choose:(resources 
+                                        stringWithCRs:'No class named "%1.\But there are %2 implementors of it.\\Goto one of them ?' 
+                                        with:aMatchString allBold
+                                        with:implementors size)
+                        fromList:(implementors collect:[:m | m mclass name])
+                        values:implementors 
+                        buttons:#('No, Search for a Class') values:#(searchClass) 
+                        lines:10 cancel:nil
+                        postBuildBlock:[:box | box minExtent:300@250].
+                ] ifFalse:[
+                    answer := Dialog 
+                        choose:(resources 
+                                        stringWithCRs:'No class named "%1.\But there are %2 implementors of it and %3 classes with a similar name.\\Goto one of them ?' 
+                                        with:aMatchString allBold
+                                        with:implementors size
+                                        with:classesMatchingCaseless size)
+                        fromList:({'Implementors:' colorizeAllWith:Color grey}
+                                  ,(implementors collect:[:m | m mclass name])
+                                  ,{'Classes:' colorizeAllWith:Color grey}
+                                  ,classesMatchingCaseless)
+                        values:(#(nil),implementors,#(nil),classesMatchingCaseless) 
+                        buttons:#('No, Search for a Class') values:#(searchClass) 
+                        lines:10 cancel:nil
+                        postBuildBlock:[:box | box minExtent:300@250].
+                ].
 
                 answer isNil ifTrue:[^ self].
                 answer ~~ #searchClass ifTrue:[
-                    self switchToClass:(answer mclass) selector:(answer selector).
+                    answer isSymbol ifTrue:[
+                        self switchToClass:(Smalltalk classNamed:answer).
+                    ] ifFalse:[
+                        self switchToClass:(answer mclass) selector:(answer selector).
+                    ].
                     ^ self.
                 ].
             ].
@@ -43284,11 +43308,11 @@
 !NewSystemBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Attic/NewSystemBrowser.st,v 1.1391 2009-11-02 10:13:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Attic/NewSystemBrowser.st,v 1.1392 2009-11-02 13:00:11 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Attic/NewSystemBrowser.st,v 1.1391 2009-11-02 10:13:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Attic/NewSystemBrowser.st,v 1.1392 2009-11-02 13:00:11 cg Exp $'
 ! !
 
 NewSystemBrowser initialize!
--- a/Tools__NewSystemBrowser.st	Mon Nov 02 13:59:53 2009 +0100
+++ b/Tools__NewSystemBrowser.st	Mon Nov 02 14:00:11 2009 +0100
@@ -35765,7 +35765,7 @@
 !
 
 switchToClassNameOrSelectorMatching:aMatchString
-    |className class implementors answer|
+    |className class implementors answer classesMatchingCaseless|
 
     aMatchString knownAsSymbol ifTrue:[
         class := Smalltalk classNamed:aMatchString.
@@ -35773,6 +35773,8 @@
             self switchToClass:class.
             ^ self.
         ].
+        classesMatchingCaseless := Smalltalk keys select:[:nm | nm sameAs:aMatchString].
+
 "/        impl := Smalltalk allImplementorsOf:aMatchString asSymbol.
 "/        impl notEmptyOrNil ifTrue:[
 "/        ].
@@ -35780,7 +35782,7 @@
         or:[ aMatchString first isLowercase]) ifTrue:[
             implementors := SystemBrowser findImplementorsMatching:aMatchString in:(Smalltalk allClasses) ignoreCase:true.
             implementors size > 0 ifTrue:[
-                implementors size == 1 ifTrue:[
+                (classesMatchingCaseless isEmpty and:[implementors size == 1]) ifTrue:[
                     answer := Dialog 
                         confirm:(resources 
                                         stringWithCRs:'No class named "%1".\But "%2" implements it. Go there ?' 
@@ -35792,19 +35794,41 @@
                     ^ self.
                 ].
                 implementors := implementors asOrderedCollection sort:[:a :b | a mclass name < b mclass name].
-                answer := Dialog 
-                    choose:(resources 
-                                    stringWithCRs:'No class named "%1.\But there are %2 implementors of it. Goto one of them ?' 
-                                    with:aMatchString allBold
-                                    with:implementors size)
-                    fromList:(implementors collect:[:m | m mclass name])
-                    values:implementors 
-                    buttons:#('No, Search for a Class') values:#(searchClass) 
-                    lines:10 cancel:nil.
+                classesMatchingCaseless isEmpty ifTrue:[
+                    answer := Dialog 
+                        choose:(resources 
+                                        stringWithCRs:'No class named "%1.\But there are %2 implementors of it.\\Goto one of them ?' 
+                                        with:aMatchString allBold
+                                        with:implementors size)
+                        fromList:(implementors collect:[:m | m mclass name])
+                        values:implementors 
+                        buttons:#('No, Search for a Class') values:#(searchClass) 
+                        lines:10 cancel:nil
+                        postBuildBlock:[:box | box minExtent:300@250].
+                ] ifFalse:[
+                    answer := Dialog 
+                        choose:(resources 
+                                        stringWithCRs:'No class named "%1.\But there are %2 implementors of it and %3 classes with a similar name.\\Goto one of them ?' 
+                                        with:aMatchString allBold
+                                        with:implementors size
+                                        with:classesMatchingCaseless size)
+                        fromList:({'Implementors:' colorizeAllWith:Color grey}
+                                  ,(implementors collect:[:m | m mclass name])
+                                  ,{'Classes:' colorizeAllWith:Color grey}
+                                  ,classesMatchingCaseless)
+                        values:(#(nil),implementors,#(nil),classesMatchingCaseless) 
+                        buttons:#('No, Search for a Class') values:#(searchClass) 
+                        lines:10 cancel:nil
+                        postBuildBlock:[:box | box minExtent:300@250].
+                ].
 
                 answer isNil ifTrue:[^ self].
                 answer ~~ #searchClass ifTrue:[
-                    self switchToClass:(answer mclass) selector:(answer selector).
+                    answer isSymbol ifTrue:[
+                        self switchToClass:(Smalltalk classNamed:answer).
+                    ] ifFalse:[
+                        self switchToClass:(answer mclass) selector:(answer selector).
+                    ].
                     ^ self.
                 ].
             ].
@@ -43284,11 +43308,11 @@
 !NewSystemBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1391 2009-11-02 10:13:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1392 2009-11-02 13:00:11 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1391 2009-11-02 10:13:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.1392 2009-11-02 13:00:11 cg Exp $'
 ! !
 
 NewSystemBrowser initialize!