uses now dynamic tree items
authortz
Sat, 14 Feb 1998 18:04:11 +0100
changeset 632 930b778d5e28
parent 631 52824496093d
child 633 11bbf4599843
uses now dynamic tree items
ResourceSelectionBrowser.st
--- a/ResourceSelectionBrowser.st	Sat Feb 14 17:50:43 1998 +0100
+++ b/ResourceSelectionBrowser.st	Sat Feb 14 18:04:11 1998 +0100
@@ -94,12 +94,12 @@
        #(#FullSpec
           #'window:' 
            #(#WindowSpec
-              #'name:' 'Resource Browser'
-              #'layout:' #(#LayoutFrame 252 0 290 0 851 0 639 0)
-              #'label:' 'Resource Browser'
+              #'name:' 'Resource Selection Browser'
+              #'layout:' #(#LayoutFrame 69 0 395 0 668 0 744 0)
+              #'label:' 'Resource Selection Browser'
               #'min:' #(#Point 400 300)
               #'max:' #(#Point 1152 864)
-              #'bounds:' #(#Rectangle 252 290 852 640)
+              #'bounds:' #(#Rectangle 69 395 669 745)
               #'usePreferredExtent:' false
           )
           #'component:' 
@@ -126,11 +126,14 @@
                                         #'hasHorizontalScrollBar:' true
                                         #'hasVerticalScrollBar:' true
                                         #'miniScrollerHorizontal:' true
-                                        #'showRoot:' false
                                         #'showDirectoryIndicatorForRoot:' false
                                         #'showDirectoryIndicator:' true
                                         #'valueChangeSelector:' #'classSelected:'
                                         #'hierarchicalList:' #listOfClasses
+                                        #'contentsSelector:' #treeViewContents
+                                        #'labelSelector:' #treeViewLabel
+                                        #'childrenSelector:' #treeViewChildren
+                                        #'iconSelector:' #treeViewIcon
                                     )
                                      #(#InputFieldSpec
                                         #'name:' 'classNameInputField'
@@ -203,6 +206,44 @@
       )
 ! !
 
+!ResourceSelectionBrowser class methodsFor:'resources'!
+
+iconClass
+    "Generated by the Image Editor"
+    "
+    ImageEditor openOnClass:self andSelector:#iconClass
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:#'ResourceSelectionBrowser iconClass'
+        ifAbsentPut:[(Depth2Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[0 0 0 0 0 21 85 85 85 5 26 170 170 170 0 26 170 170 170 0 26 170 170 170 0 26 170 170 170 0 26 170 170 170 0 26 170 170 170 0 26 170 170 170 12 26 170 170 170 5 26 170 170 170 0 26 170 170 170 0 26 170 170 170 0 26 170 170 170 0 0 0 0 0 0 0 0 0 0 0]) ; colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color grey:66.9978); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[127 255 128 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 127 255 128]) ; yourself); yourself]!
+
+iconHidingSubclasses
+    "Generated by the Image Editor"
+    "
+    ImageEditor openOnClass:self andSelector:#iconHidingSubclasses
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:#'ResourceSelectionBrowser iconHidingSubclasses'
+        ifAbsentPut:[(Depth4Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(#[0 0 0 0 0 0 0 0 0 1 17 17 17 17 17 17 17 48 1 51 51 51 51 51 51 51 32 1 48 0 0 0 51 51 51 32 1 48 68 68 64 51 51 51 32 1 48 0 0 0 51 51 51 32 1 51 50 51 51 51 51 51 32 1 51 50 51 0 0 0 3 32 1 51 50 34 2 34 34 3 32 1 51 50 51 0 0 0 3 32 1 51 50 51 51 51 51 51 32 1 51 50 51 0 0 0 3 32 1 51 50 34 2 34 34 3 32 1 51 51 51 0 0 0 3 32 3 34 34 34 34 34 34 34 32 0 0 0 0 0 0 0 0 0]) ; colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color grey:49.9962); add:(Color grey:66.9978); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9962 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9962); add:(Color red:0.0 green:49.9962 blue:49.9962); add:(Color red:49.9962 green:49.9962 blue:0.0); add:(Color red:49.9962 green:0.0 blue:49.9962); yourself)); mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[127 255 128 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 127 255 128]) ; yourself); yourself]!
+
+iconShowingSubclasses
+    "Generated by the Image Editor"
+    "
+    ImageEditor openOnClass:self andSelector:#iconShowingSubclasses
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:#'ResourceSelectionBrowser iconShowingSubclasses'
+        ifAbsentPut:[(Depth4Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(#[0 0 0 0 0 0 0 0 0 1 17 17 17 17 17 17 17 48 1 51 51 51 51 51 51 51 32 1 48 0 0 0 51 51 51 32 1 48 68 68 64 51 51 51 32 1 48 0 0 0 51 51 51 32 1 51 50 51 51 51 51 51 32 1 51 50 51 0 0 0 3 32 1 51 50 34 5 85 85 3 32 1 51 50 51 0 0 0 3 32 1 51 50 51 51 51 51 51 32 1 51 50 51 0 0 0 3 32 1 51 50 34 8 136 136 3 32 1 51 51 51 0 0 0 3 32 3 34 34 34 34 34 34 34 32 0 0 0 0 0 0 0 0 0]) ; colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color grey:49.9962); add:(Color grey:66.9978); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9962 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9962); add:(Color red:0.0 green:49.9962 blue:49.9962); add:(Color red:49.9962 green:49.9962 blue:0.0); add:(Color red:49.9962 green:0.0 blue:49.9962); yourself)); mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[127 255 128 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 127 255 128]) ; yourself); yourself]! !
+
 !ResourceSelectionBrowser methodsFor:'accessing - views'!
 
 classNameInputField
@@ -221,11 +262,7 @@
 
     |holder|
     (holder := builder bindingAt:#listOfClasses) isNil ifTrue:[
-        builder aspectAt:#listOfClasses put:
-            (holder := 
-                (TreeItem name: (resourceSuperclass ? #Object))
-                    children: (OrderedCollection with:
-                        (TreeItem newAsTreeFromSmalltalkClass: (Smalltalk at:(resourceSuperclass ? #Object)))))
+        builder aspectAt:#listOfClasses put: (holder := TreeItem new)
     ].
     ^ holder
 
@@ -277,7 +314,48 @@
     ^ holder
 ! !
 
-!ResourceSelectionBrowser methodsFor:'callbacks'!
+!ResourceSelectionBrowser methodsFor:'callbacks - tree view'!
+
+treeViewChildren
+
+    ^[:aTreeItem| aTreeItem contents subclasses asSortedCollection: [:i1 :i2| i1 name < i2 name]]
+
+
+!
+
+treeViewContents
+
+    ^Smalltalk at: resourceSuperclass ? #Object
+
+
+!
+
+treeViewIcon
+
+    ^[:aTreeItem|  
+        aTreeItem contents subclasses notEmpty 
+        ifTrue: 
+        [
+            aTreeItem hide 
+                ifTrue:  [self class iconHidingSubclasses] 
+                ifFalse: [self class iconShowingSubclasses]] 
+        ifFalse: 
+        [
+            self class iconClass
+        ]
+     ]
+
+
+!
+
+treeViewLabel
+
+    ^[:aTreeItem|aTreeItem contents name]
+
+
+! !
+
+!ResourceSelectionBrowser methodsFor:'callbacks - user'!
 
 classSelected: anIndex
     
@@ -315,7 +393,7 @@
 
 openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withResourceTypes: aResourceTypes
 
-    |cls sel|
+    |cls|
     resourceMethod := aSelector.
     resourceTypes := aResourceTypes.
     resourceSuperclass := aSuperclassOrSymbol isClass ifTrue: [aSuperclassOrSymbol name] ifFalse: [aSuperclassOrSymbol].
@@ -324,10 +402,11 @@
 
     self open.
 
-    (self selectionOfClass value notNil 
-     and:[(cls := Smalltalk at: self selectionOfClass value name) isClass 
-          and:[accept value]]
-    ) ifTrue:[
+    (self selectionOfClass value notNil and:
+    [(cls := Smalltalk at: self selectionOfClass value name) isClass and:
+    [accept value]]) 
+    ifTrue:
+    [
         ^cls name, ' ', self valueOfSelector value
     ].
     ^nil
@@ -373,7 +452,7 @@
         ].
         self valueOfClassName value: clsPattern
     ].
-    classSelectionBlock value: classSelection.
+
     self valueOfClassName value: classSelection.
     self selectionOfResource value: (self listOfResources detect: [:m| m selector == resourceMethod] ifNone: nil).
     self classNameInputField entryCompletionBlock:
@@ -384,8 +463,10 @@
         (what at:2) size ~~ 1 ifTrue:[Display beep].
         classSelectionBlock value: self classNameInputField contents
     ].
+    self listOfClassesView validateDoubleClickBlock: [:aTreeItem | aTreeItem contents ~~ self treeViewContents].
+    self listOfClassesView selectedNodeExpand: true.
 
-    self listOfClassesView selectedNodeExpand: true.
+    [classSelectionBlock value: classSelection] forkAt: 4.
 
     ^super postBuildWith:aBuilder