bug fix - update tree-selection when entering a className
authorClaus Gittinger <cg@exept.de>
Wed, 26 Jul 2000 14:44:13 +0200
changeset 1384 ff417bf5f8d8
parent 1383 179597c2abed
child 1385 cbe7e7763105
bug fix - update tree-selection when entering a className
ResourceSelectionBrowser.st
--- a/ResourceSelectionBrowser.st	Wed Jul 26 14:14:21 2000 +0200
+++ b/ResourceSelectionBrowser.st	Wed Jul 26 14:44:13 2000 +0200
@@ -11,6 +11,8 @@
 "
 
 
+"{ Package: 'stx:libtool2' }"
+
 SelectionBrowser subclass:#ResourceSelectionBrowser
 	instanceVariableNames:'resourceMethod resourceClass resourceSuperclass resourceTypes
 		allClasses classSelectionBlock'
@@ -258,193 +260,197 @@
 
     <resource: #canvas>
 
-    ^
-     
-       #(#FullSpec
-          #window: 
-           #(#WindowSpec
-              #name: 'Resource Selection Browser'
-              #layout: #(#LayoutFrame 194 0 307 0 793 0 656 0)
-              #label: 'Resource Selection Browser'
-              #min: #(#Point 400 300)
-              #max: #(#Point 1152 864)
-              #bounds: #(#Rectangle 194 307 794 657)
-              #usePreferredExtent: false
-          )
-          #component: 
-           #(#SpecCollection
-              #collection: 
-               #(
-                 #(#VariableHorizontalPanelSpec
-                    #name: 'VariableHorizontalPanel'
-                    #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -36 1.0)
+    ^ 
+     #(#FullSpec
+        #name: #windowSpec
+        #window: 
+       #(#WindowSpec
+          #label: 'Resource Selection Browser'
+          #name: 'Resource Selection Browser'
+          #min: #(#Point 400 300)
+          #max: #(#Point 1152 864)
+          #bounds: #(#Rectangle 145 206 745 556)
+        )
+        #component: 
+       #(#SpecCollection
+          #collection: #(
+           #(#VariableHorizontalPanelSpec
+              #name: 'VariableHorizontalPanel'
+              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -36 1.0)
+              #component: 
+             #(#SpecCollection
+                #collection: #(
+                 #(#ViewSpec
+                    #name: 'Box1'
                     #component: 
-                     #(#SpecCollection
-                        #collection: 
-                         #(
-                           #(#ViewSpec
-                              #name: 'Box1'
-                              #component: 
-                               #(#SpecCollection
-                                  #collection: 
-                                   #(
-                                     #(#HorizontalPanelViewSpec
-                                        #name: 'HorizontalPanel2'
-                                        #layout: #(#LayoutFrame 0 0 2 0 297 0 23 0)
-                                        #component: 
-                                         #(#SpecCollection
-                                            #collection: 
-                                             #(
-                                               #(#RadioButtonSpec
-                                                  #name: 'ClassCategoriesRadioButton'
-                                                  #label: 'Categories'
-                                                  #translateLabel: true
-                                                  #model: #selectionOfClassPresentation
-                                                  #isTriggerOnDown: true
-                                                  #lampColor: #(#Color 0.0 0.0 0.0)
-                                                  #select: #'Class Categories'
-                                                  #extent: #(#Point 124 21)
-                                              )
-                                               #(#RadioButtonSpec
-                                                  #name: 'ClassHierarchyRadioButton'
-                                                  #label: 'Hierarchy'
-                                                  #translateLabel: true
-                                                  #model: #selectionOfClassPresentation
-                                                  #isTriggerOnDown: true
-                                                  #lampColor: #(#Color 0.0 0.0 0.0)
-                                                  #select: #'Class Hierarchy'
-                                                  #extent: #(#Point 145 21)
-                                              )
-                                            )
-                                        )
-                                        #horizontalLayout: #leftSpace
-                                        #verticalLayout: #fit
-                                        #horizontalSpace: 3
-                                        #verticalSpace: 3
-                                    )
-                                     #(#SelectionInTreeViewSpec
-                                        #name: 'listOfClassHierarchyView'
-                                        #layout: #(#LayoutFrame 0 0.0 23 0.0 0 1.0 -24 1.0)
-                                        #tabable: true
-                                        #model: #selectionOfClassHierarchy
-                                        #hasHorizontalScrollBar: true
-                                        #hasVerticalScrollBar: true
-                                        #miniScrollerHorizontal: true
-                                        #showDirectoryIndicatorForRoot: false
-                                        #showDirectoryIndicator: true
-                                        #valueChangeSelector: #classSelected
-                                        #hierarchicalList: #rootOfClassHierarchy
-                                        #validateDoubleClickSelector: #validateDoubleClick:
-                                        #contentsSelector: #treeViewClassHierarchyContents
-                                        #labelSelector: #treeViewClassHierarchyLabel
-                                        #childrenSelector: #treeViewClassHierarchyChildren
-                                        #iconSelector: #treeViewClassHierarchyIcon
-                                    )
-                                     #(#SelectionInTreeViewSpec
-                                        #name: 'listOfClassCategoriesView'
-                                        #layout: #(#LayoutFrame 0 0.0 23 0.0 0 1.0 -24 1.0)
-                                        #tabable: true
-                                        #model: #selectionOfClassCategories
-                                        #hasHorizontalScrollBar: true
-                                        #hasVerticalScrollBar: true
-                                        #miniScrollerHorizontal: true
-                                        #showRoot: false
-                                        #showDirectoryIndicator: true
-                                        #valueChangeSelector: #classSelected
-                                        #hierarchicalList: #rootOfClassCategories
-                                        #validateDoubleClickSelector: #validateDoubleClick:
-                                        #childrenSelector: #treeViewClassCategoryChildren
-                                        #iconSelector: #treeViewClassCategoryIcon
-                                    )
-                                     #(#InputFieldSpec
-                                        #name: 'classNameInputField'
-                                        #layout: #(#LayoutFrame 2 0.0 -22 1 -1 1.0 0 1)
-                                        #tabable: true
-                                        #model: #valueOfClassName
-                                    )
-                                  )
+                   #(#SpecCollection
+                      #collection: #(
+                       #(#HorizontalPanelViewSpec
+                          #name: 'HorizontalPanel2'
+                          #layout: #(#LayoutFrame 0 0 2 0 297 0 23 0)
+                          #horizontalLayout: #leftSpace
+                          #verticalLayout: #fit
+                          #horizontalSpace: 3
+                          #verticalSpace: 3
+                          #component: 
+                         #(#SpecCollection
+                            #collection: #(
+                             #(#RadioButtonSpec
+                                #label: 'Categories'
+                                #name: 'ClassCategoriesRadioButton'
+                                #translateLabel: true
+                                #model: #selectionOfClassPresentation
+                                #isTriggerOnDown: true
+                                #lampColor: #(#Color 0.0 0.0 0.0)
+                                #select: #'Class Categories'
+                                #extent: #(#Point 124 21)
                               )
-                          )
-                           #(#ViewSpec
-                              #name: 'Box2'
-                              #component: 
-                               #(#SpecCollection
-                                  #collection: 
-                                   #(
-                                     #(#DataSetSpec
-                                        #name: 'resourcesDataSetView'
-                                        #layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0)
-                                        #model: #selectionOfResourceMethod
-                                        #hasHorizontalScrollBar: true
-                                        #hasVerticalScrollBar: true
-                                        #miniScrollerHorizontal: true
-                                        #rowClassName: 'ResourceSelectionBrowser::Row'
-                                        #dataList: #listOfResourceMethods
-                                        #useIndex: false
-                                        #has3Dsepartors: true
-                                        #has3Dseparators: true
-                                        #doubleClickSelector: #resourceDoubleClicked
-                                        #columnHolder: #resourceMethodColumns
-                                        #valueChangeSelector: #resourceSelected
-                                        #verticalSpacing: 1
-                                    )
-                                     #(#InputFieldSpec
-                                        #name: 'selectorInputField'
-                                        #layout: #(#LayoutFrame 2 0.0 -22 1 -2 1.0 0 1)
-                                        #tabable: true
-                                        #model: #valueOfResourceSelector
-                                    )
-                                  )
+                             #(#RadioButtonSpec
+                                #label: 'Hierarchy'
+                                #name: 'ClassHierarchyRadioButton'
+                                #translateLabel: true
+                                #model: #selectionOfClassPresentation
+                                #isTriggerOnDown: true
+                                #lampColor: #(#Color 0.0 0.0 0.0)
+                                #select: #'Class Hierarchy'
+                                #extent: #(#Point 145 21)
                               )
+                             )
+                           
                           )
                         )
+                       #(#SelectionInTreeViewSpec
+                          #name: 'listOfClassHierarchyView'
+                          #layout: #(#LayoutFrame 0 0.0 23 0.0 0 1.0 -24 1.0)
+                          #tabable: true
+                          #model: #selectionOfClassHierarchy
+                          #hasHorizontalScrollBar: true
+                          #hasVerticalScrollBar: true
+                          #miniScrollerHorizontal: true
+                          #showDirectoryIndicatorForRoot: false
+                          #showDirectoryIndicator: true
+                          #valueChangeSelector: #classSelected
+                          #hierarchicalList: #rootOfClassHierarchy
+                          #validateDoubleClickSelector: #validateDoubleClick:
+                          #contentsSelector: #treeViewClassHierarchyContents
+                          #labelSelector: #treeViewClassHierarchyLabel
+                          #childrenSelector: #treeViewClassHierarchyChildren
+                          #iconSelector: #treeViewClassHierarchyIcon
+                          #highlightMode: #line
+                        )
+                       #(#SelectionInTreeViewSpec
+                          #name: 'listOfClassCategoriesView'
+                          #layout: #(#LayoutFrame 0 0.0 23 0.0 0 1.0 -24 1.0)
+                          #tabable: true
+                          #model: #selectionOfClassCategories
+                          #hasHorizontalScrollBar: true
+                          #hasVerticalScrollBar: true
+                          #miniScrollerHorizontal: true
+                          #showRoot: false
+                          #showDirectoryIndicator: true
+                          #valueChangeSelector: #classSelected
+                          #hierarchicalList: #rootOfClassCategories
+                          #validateDoubleClickSelector: #validateDoubleClick:
+                          #childrenSelector: #treeViewClassCategoryChildren
+                          #iconSelector: #treeViewClassCategoryIcon
+                          #highlightMode: #line
+                        )
+                       #(#InputFieldSpec
+                          #name: 'classNameInputField'
+                          #layout: #(#LayoutFrame 2 0.0 -22 1 -1 1.0 0 1)
+                          #tabable: true
+                          #model: #valueOfClassName
+                          #acceptOnLeave: true
+                          #acceptOnLostFocus: true
+                          #acceptOnPointerLeave: true
+                        )
+                       )
+                     
                     )
-                    #handles: #(#Any 0.5 1.0)
-                )
-                 #(#HorizontalPanelViewSpec
-                    #name: 'HorizontalPanel1'
-                    #layout: #(#LayoutFrame 2 0.0 -30 1 -2 1.0 -4 1.0)
+                  )
+                 #(#ViewSpec
+                    #name: 'Box2'
                     #component: 
-                     #(#SpecCollection
-                        #collection: 
-                         #(
-                           #(#ActionButtonSpec
-                              #name: 'HelpButton'
-                              #activeHelpKey: #dss
-                              #label: 'Help'
-                              #model: #openHTMLDocument:
-                              #initiallyDisabled: true
-                              #enableChannel: #helpEnabled
-                              #actionValue: 'tools/uipainter/ResourceSelectionBrowser.html'
-                              #extent: #(#Point 196 26)
-                          )
-                           #(#ActionButtonSpec
-                              #name: 'cancelButton'
-                              #activeHelpKey: #commitCancel
-                              #label: 'Cancel'
-                              #tabable: true
-                              #model: #cancel
-                              #extent: #(#Point 196 26)
-                          )
-                           #(#ActionButtonSpec
-                              #name: 'okButton'
-                              #activeHelpKey: #commitOK
-                              #label: 'OK'
-                              #tabable: true
-                              #model: #accept
-                              #isDefault: true
-                              #extent: #(#Point 196 24)
-                          )
+                   #(#SpecCollection
+                      #collection: #(
+                       #(#DataSetSpec
+                          #name: 'resourcesDataSetView'
+                          #layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0)
+                          #model: #selectionOfResourceMethod
+                          #hasHorizontalScrollBar: true
+                          #hasVerticalScrollBar: true
+                          #miniScrollerHorizontal: true
+                          #rowClassName: 'ResourceSelectionBrowser::Row'
+                          #dataList: #listOfResourceMethods
+                          #useIndex: false
+                          #has3Dsepartors: true
+                          #has3Dseparators: true
+                          #doubleClickSelector: #resourceDoubleClicked
+                          #columnHolder: #resourceMethodColumns
+                          #valueChangeSelector: #resourceSelected
+                          #verticalSpacing: 1
+                        )
+                       #(#InputFieldSpec
+                          #name: 'selectorInputField'
+                          #layout: #(#LayoutFrame 2 0.0 -22 1 -2 1.0 0 1)
+                          #tabable: true
+                          #model: #valueOfResourceSelector
+                          #acceptOnLeave: true
+                          #acceptOnLostFocus: true
+                          #acceptOnPointerLeave: true
                         )
+                       )
+                     
                     )
-                    #horizontalLayout: #fit
-                    #verticalLayout: #fit
-                )
+                  )
+                 )
+               
               )
-          )
+              #handles: #(#Any 0.5 1.0)
+            )
+           #(#HorizontalPanelViewSpec
+              #name: 'HorizontalPanel1'
+              #layout: #(#LayoutFrame 2 0.0 -30 1 -2 1.0 -4 1.0)
+              #horizontalLayout: #fit
+              #verticalLayout: #fit
+              #component: 
+             #(#SpecCollection
+                #collection: #(
+                 #(#ActionButtonSpec
+                    #label: 'Help'
+                    #name: 'HelpButton'
+                    #activeHelpKey: #dss
+                    #model: #openHTMLDocument:
+                    #initiallyDisabled: true
+                    #enableChannel: #helpEnabled
+                    #actionValue: 'tools/uipainter/ResourceSelectionBrowser.html'
+                    #extent: #(#Point 196 26)
+                  )
+                 #(#ActionButtonSpec
+                    #label: 'Cancel'
+                    #name: 'cancelButton'
+                    #activeHelpKey: #commitCancel
+                    #tabable: true
+                    #model: #cancel
+                    #extent: #(#Point 196 26)
+                  )
+                 #(#ActionButtonSpec
+                    #label: 'OK'
+                    #name: 'okButton'
+                    #activeHelpKey: #commitOK
+                    #tabable: true
+                    #model: #accept
+                    #isDefault: true
+                    #extent: #(#Point 196 24)
+                  )
+                 )
+               
+              )
+            )
+           )
+         
+        )
       )
-
-    "Modified: / 27.7.1998 / 18:05:40 / cg"
 ! !
 
 !ResourceSelectionBrowser class methodsFor:'list specs'!
@@ -603,6 +609,7 @@
     |holder|                   
     (holder := builder bindingAt:#valueOfClassName) isNil ifTrue:[
         builder aspectAt:#valueOfClassName put:(holder :=  '' asValue).
+        holder onChangeEvaluate:[self classSelectionUpdate:holder value].
     ].
     ^ holder
 !
@@ -743,6 +750,53 @@
     ]
 !
 
+classSelectionUpdate:clsPattern
+    |foundClass classes|  
+
+    clsPattern notNil ifTrue:[
+        foundClass := Smalltalk at:(clsPattern printString asSymbol).
+    ].
+    (foundClass isClass not or:[foundClass name ~= clsPattern])
+    ifTrue:
+    [
+        classes := allClasses select: [:cls| cls name size >= clsPattern size].
+        1 to: clsPattern size do: 
+        [:i|    
+             classes := classes select: [:cls| (cls name at: i) == (clsPattern at: i)].
+        ].    
+        foundClass := classes at: 1 ifAbsent: [nil] 
+    ].          
+    foundClass notNil
+    ifTrue:
+    [           
+        ClassPresentation = #'Class Hierarchy'
+        ifTrue:  
+        [
+            |searchArgs nonSuperclasses|
+            foundClass isPrivate
+                ifFalse: [searchArgs := foundClass withAllSuperclasses reverse]
+                ifTrue:  [searchArgs := foundClass owningClass withAllSuperclasses reverse. searchArgs add: foundClass]
+.                                  
+            (nonSuperclasses := self treeViewClassHierarchyContents allSuperclasses) notNil 
+                ifTrue: [searchArgs := searchArgs reject: [:cls| nonSuperclasses includes: cls]].
+
+            self selectionOfClassHierarchy value: (self rootOfClassHierarchy detectChild:[:child :arg| child contents == arg] arguments:searchArgs).
+        ]
+        ifFalse: 
+        [
+            |searchArgs|
+            foundClass isPrivate
+                ifTrue:  [searchArgs := Array with: 'Categories' with: foundClass category with: foundClass owningClass name with: foundClass name]
+                ifFalse: [searchArgs := Array with: 'Categories' with: foundClass category with: foundClass name].
+
+            self selectionOfClassCategories value: (self rootOfClassCategories detectChild:[:child :arg| (child name upTo: $ ) = arg] arguments:searchArgs).
+        ].
+    ].
+    self valueOfClassName value: clsPattern
+
+
+!
+
 resourceDoubleClicked
     "after a double click on resource method, accept it and close"
 
@@ -829,51 +883,7 @@
     (classSelection isNil or:[Smalltalk at: classSelection]) isNil 
         ifTrue: [classSelection :=  self treeViewContents].
 
-    classSelectionBlock := 
-    [:clsPattern|                                  
-        |foundClass classes|  
-
-        clsPattern notNil ifTrue:[
-            foundClass := Smalltalk at:(clsPattern printString asSymbol).
-        ].
-        (foundClass isClass not or:[foundClass name ~= clsPattern])
-        ifTrue:
-        [
-            classes := allClasses select: [:cls| cls name size >= clsPattern size].
-            1 to: clsPattern size do: 
-            [:i|    
-                 classes := classes select: [:cls| (cls name at: i) == (clsPattern at: i)].
-            ].    
-            foundClass := classes at: 1 ifAbsent: [nil] 
-        ].          
-        foundClass notNil
-        ifTrue:
-        [           
-            ClassPresentation = #'Class Hierarchy'
-            ifTrue:  
-            [
-                |searchArgs nonSuperclasses|
-                foundClass isPrivate
-                    ifFalse: [searchArgs := foundClass withAllSuperclasses reverse]
-                    ifTrue:  [searchArgs := foundClass owningClass withAllSuperclasses reverse. searchArgs add: foundClass]
-    .                                  
-                (nonSuperclasses := self treeViewClassHierarchyContents allSuperclasses) notNil 
-                    ifTrue: [searchArgs := searchArgs reject: [:cls| nonSuperclasses includes: cls]].
-
-                self selectionOfClassHierarchy value: (self rootOfClassHierarchy detectChild:[:child :arg| child contents == arg] arguments:searchArgs).
-            ]
-            ifFalse: 
-            [
-                |searchArgs|
-                foundClass isPrivate
-                    ifTrue:  [searchArgs := Array with: 'Categories' with: foundClass category with: foundClass owningClass name with: foundClass name]
-                    ifFalse: [searchArgs := Array with: 'Categories' with: foundClass category with: foundClass name].
-
-                self selectionOfClassCategories value: (self rootOfClassCategories detectChild:[:child :arg| (child name upTo: $ ) = arg] arguments:searchArgs).
-            ].
-        ].
-        self valueOfClassName value: clsPattern
-    ].
+    classSelectionBlock := [:clsPattern | self classSelectionUpdate:clsPattern].
     self valueOfClassName value: classSelection.  
 
     (classNameInputField := builder componentAt: #classNameInputField) entryCompletionBlock: